Overview
TheConfig struct allows you to customize how the AI models behave. You can adjust reasoning effort levels and enable web search capabilities.
Basic Configuration
The simplest way to use configuration:Configuration Options
TheConfig struct (config.rs:27-47) has two main fields:
Default Values
When you callConfig::new(), you get:
include_search:falsereasoning_effort:ReasoningEffort::Low
Reasoning Effort Levels
TheReasoningEffort enum (config.rs:1-24) controls how much computational effort the model uses:
When to Use Each Level
Low (Default)
Low (Default)
Best for:
- Quick responses
- Simple questions
- Casual conversations
- High-volume requests
- Fastest response time
- Lower computational cost
- Suitable for most use cases
Medium
Medium
Best for:
- Moderate complexity tasks
- Technical questions
- Code explanations
- Balanced speed/quality
- Balanced performance
- More thorough reasoning
- Slightly longer response time
High
High
Best for:
- Complex problem-solving
- Research questions
- Critical analysis
- Maximum accuracy needed
- Slowest response time
- Most thorough reasoning
- Highest quality output
Setting Reasoning Effort
Enabling Web Search
Wheninclude_search is enabled, the model can search the web for current information:
Web search is useful for questions about current events, prices, weather, or any information that changes over time. However, it may increase response time.
Complete Configuration Examples
Example 1: High Effort with Search
For complex research questions:Example 2: Low Effort without Search
For quick, simple responses:Example 3: Medium Effort with Search
Balanced approach for technical questions:How Configuration Works
When you send a request, the configuration is serialized into the API payload (client.rs:397-400):
as_str() method (config.rs:17-23) converts the enum to the API format:
Reusing Configurations
You can clone and reuse configurations:Configuration Presets
You can create helper functions for common configurations:Optional Configuration
Thesend() method accepts Option<Config>. If you pass None, it uses default values (client.rs:365):
Configuration with Image Generation
Configuration also works with image generation:Performance Considerations
Response Time Impact
| Reasoning Effort | Typical Response Time | Use Case |
|---|---|---|
| Low | 1-3 seconds | Simple questions |
| Medium | 3-8 seconds | Technical discussions |
| High | 8-20+ seconds | Complex analysis |
Search Impact
Enablinginclude_search typically adds 2-5 seconds to response time as the model:
- Formulates search queries
- Retrieves web results
- Synthesizes information
Best Practices
- Start with defaults -
Config::new()works well for most cases - Use high effort sparingly - Reserve it for truly complex tasks
- Enable search when needed - Only for questions requiring current information
- Match effort to model - Reasoning models benefit more from high effort
- Create presets - Define reusable configurations for common patterns
Debugging Configuration
Print configuration values to verify settings:Next Steps
Basic Chat
Apply configuration to basic chat requests
Multi-turn Conversations
Use configuration across conversation turns