Overview
defineModel creates a model configuration that can be referenced by prompts and agents.
Type Definition
Parameters
Unique identifier for this model configuration. Used to reference the model in prompts and agents.Best Practice: Name models by use case, not by model ID:
heavy-thinking- Complex reasoning tasksfast-response- Quick, simple responsescode-generation- Code-focused tasks
The model provider to use.
openai- Direct OpenAI API accessopenrouter- Access to multiple providers via OpenRouter
The specific model identifier.OpenAI examples:
gpt-4ogpt-4o-minio1-mini
provider/model-nameanthropic/claude-sonnet-4google/gemini-2.0-flash-expmeta-llama/llama-3.3-70b-instruct
Price per 1 million input tokens in USD. Required for OpenAI provider.OpenRouter models fetch pricing automatically from the API.
Price per 1 million output tokens in USD. Required for OpenAI provider.
Price per 1 million cached tokens in USD (if provider supports caching).
Array of model names to try if the primary model fails. Must reference other models defined with
defineModel.Fallbacks are tried for:- Network errors
- Rate limits (429)
- Server errors (5xx)
- Authentication errors (401)
OpenRouter only. Only use specific providers for this model.
Return Value
Returns the sameModelConfig object passed in, enabling the build system to register it.
Examples
OpenAI Model
OpenRouter Model
OpenRouter models automatically fetch pricing from the OpenRouter API. You do not need to specify
inputPrice or outputPrice.With Fallbacks
File Location
Models are auto-discovered fromagents/models/:
- Use snake_case for file names
- One model per file
- Default export required
Generated Types
After running the build,StandardAgents.Models type is generated: