Skip to main content

Configuring Call Options

Call options allow you to pass type-safe structured inputs to your agent. Use them to dynamically modify any agent setting based on the specific request.

Why Use Call Options?

When you need agent behavior to change based on runtime context:
  • Add dynamic context - Inject retrieved documents, user preferences, or session data into prompts
  • Select models dynamically - Choose faster or more capable models based on request complexity
  • Configure tools per request - Pass user location to search tools or adjust tool behavior
  • Customize provider options - Set reasoning effort, temperature, or other provider-specific settings
Without call options, you’d need to create multiple agents or handle configuration logic outside the agent.

How It Works

Define call options in three steps:
  1. Define the schema - Specify what inputs you accept using callOptionsSchema
  2. Configure with prepareCall - Use those inputs to modify agent settings
  3. Pass options at runtime - Provide the options when calling generate() or stream()

Basic Example

Add user context to your agent’s prompt at runtime:
The options parameter is now required and type-checked. If you don’t provide it or pass incorrect types, TypeScript will error.

Modifying Agent Settings

Use prepareCall to modify any agent setting. Return only the settings you want to change.

Dynamic Model Selection

Choose models based on request characteristics:

Dynamic Tool Configuration

Configure tools based on runtime context:

Provider-Specific Options

Configure provider settings dynamically:

Advanced Patterns

Retrieval Augmented Generation (RAG)

Fetch relevant context and inject it into your prompt:
The prepareCall function can be async, enabling you to fetch data before configuring the agent.

Combining Multiple Modifications

Modify multiple settings together:

Using with createAgentUIStreamResponse

Pass call options through API routes to your agent:

Next Steps