> For the complete documentation index, see [llms.txt](https://axar-ai.gitbook.io/axar/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://axar-ai.gitbook.io/axar/advanced/configuration.md).

# Configuration

When using the `@model` decorator, you can optionally provide a configuration object to customize the model's behavior:

```typescript
@model('openai:gpt-4', {
  maxTokens: 100,
  temperature: 0.5,
  maxRetries: 3,
  maxSteps: 3,
  toolChoice: 'auto'
})
class MyAgent extends Agent<string, string> {}
```

### Configuration options

| Option        | Type                 | Default | Description                                                                                                                                                |
| ------------- | -------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `maxTokens`   | `number`             | -       | Maximum number of tokens to generate in the response. Use this to control response length.                                                                 |
| `temperature` | `number`             | -       | Sampling temperature between 0 and 1. Lower values make responses more focused and deterministic, while higher values make them more creative and diverse. |
| `maxRetries`  | `number`             | -       | Maximum number of retries for failed API requests before giving up.                                                                                        |
| `maxSteps`    | `number`             | 3       | Maximum number of conversation steps (tool calls) the agent can take to complete a task.                                                                   |
| `toolChoice`  | `'auto'` \| `'none'` | -       | Controls how the model uses tools. Set to 'none' to disable tool usage, or 'auto' to let the model decide when to use tools.                               |

### Example usage

```typescript
// Basic usage without configuration
@model('openai:gpt-4')
class SimpleAgent extends Agent<string, string> {}

// With partial configuration
@model('openai:gpt-4', {
    maxTokens: 100,
    temperature: 0.7
})
class ConfiguredAgent extends Agent<string, string> {}

// With full configuration
@model('openai:gpt-4', {
    maxTokens: 150,
    temperature: 0.5,
    maxRetries: 3,
    maxSteps: 5,
    toolChoice: 'auto'
})
class FullyConfiguredAgent extends Agent<string, string> {}
```

### Best practices

1. Set `maxTokens` based on your expected response length needs to optimize costs
2. Use lower `temperature` (0.1-0.4) for tasks requiring precise, factual responses
3. Use higher `temperature` (0.6-0.9) for tasks requiring creativity
4. Adjust `maxSteps` based on task complexity - simple tasks may only need 1-2 steps
5. Consider setting `maxRetries` for improved reliability in production environments
