Skip to main content

What are Models?

Models in Standard Agents define the LLM configurations that your agents and prompts use for AI responses. Each model configuration specifies which provider to use, the specific model ID, capabilities, fallback models for resilience, and optional pricing for cost tracking.

Quick Example

agents/models/heavy_thinking.ts
Reference in a prompt:
agents/prompts/my_prompt.ts

Naming Models

Best Practice: Name your models based on their use case, not the underlying model ID.
This approach provides several benefits:
  • Swap models easily - Change the underlying model without updating prompts
  • Clear intent - Team members understand what each model is for
  • Environment flexibility - Use different models in dev vs production
Good model names:
  • heavy-thinking - Complex reasoning tasks
  • fast-response - Quick, simple responses
  • code-generation - Code-focused tasks
  • eval - Evaluation and scoring
  • budget - Cost-conscious general use
  • creative-writing - Creative content generation
Avoid:
  • gpt-5.4 - Ties the name to a specific model
  • claude-sonnet - Same issue, hard to swap later
  • model-1 - No indication of purpose

Model Providers

Standard Agents uses provider factory functions imported from provider packages. This enables typed providerOptions, runtime validation, and local provider definitions.

OpenAI

API Key: Set OPENAI_API_KEY environment variable Package: @standardagents/openai

User-Defined Providers

Use defineProvider when another API is compatible with a base provider but needs its own endpoint, API key, icon, model list, or pricing behavior.
agents/providers/darkbloom.ts
agents/models/darkbloom_chat.ts
Sub-providers inherit the base provider’s providerOptions type. They can override any provider method with overrides; call next() inside an override to compose with the base provider, or return your own value to replace it.

Anthropic

Anthropic’s Claude models are available through a dedicated provider package built on the official @anthropic-ai/sdk:
API Key: Set ANTHROPIC_API_KEY environment variable
Known Anthropic pricing fallback: Standard Agents derives the exact request cost for documented Claude models from the API’s token usage buckets (including prompt-cache reads and writes), so inputPrice and outputPrice are optional for known Claude models. Set them yourself only for custom or unlisted model IDs.
Package: @standardagents/anthropic

Cerebras

Cerebras exposes an OpenAI-compatible Chat Completions API with a dedicated provider package:
API Key: Set CEREBRAS_API_KEY environment variable
Known Cerebras pricing fallback: Standard Agents can derive request cost for documented Cerebras models when the API response includes token usage but no explicit dollar cost. For custom or private Cerebras models, keep setting inputPrice and outputPrice yourself.
Package: @standardagents/cerebras

Google Gemini / Imagen

Google’s dedicated provider uses the official @google/genai SDK for Gemini text generation and Imagen image generation/editing:
API Key: Set GOOGLE_API_KEY environment variable Package: @standardagents/google

Groq

Groq exposes low-latency chat completions through the official groq-sdk:
API Key: Set GROQ_API_KEY environment variable Package: @standardagents/groq

Novita AI

Novita AI exposes an OpenAI-compatible Chat Completions API with live model catalog pricing:
API Key: Set NOVITA_API_KEY environment variable
No pricing required for catalog models: Novita’s provider reads model prices from /openai/v1/models, including cache-read prices when available, and attaches provider-owned usage.pricing / usage.cost values. For custom or private Novita models, set inputPrice, outputPrice, and cachedPrice yourself.
Package: @standardagents/novita

Cloudflare Workers AI

Cloudflare Workers AI exposes an OpenAI-compatible Chat Completions endpoint scoped to your Cloudflare account:
Environment: Set both CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID Package: @standardagents/cloudflare

OpenRouter

OpenRouter provides access to models from multiple providers (OpenAI, Anthropic, Google, Meta, etc.) through a single API:
No pricing required: OpenRouter models automatically fetch pricing data from the OpenRouter API at runtime. You do not need to specify inputPrice or outputPrice for OpenRouter models.
Model ID format: provider/model-name Example models:
  • openai/gpt-5.4
  • anthropic/claude-sonnet-4
  • google/gemini-2.0-flash-exp
  • meta-llama/llama-3.3-70b-instruct
API Key: Set OPENROUTER_API_KEY environment variable Package: @standardagents/openrouter

xAI

xAI uses the official @ai-sdk/xai provider for Grok chat and image models:
API Key: Set XAI_API_KEY environment variable Package: @standardagents/xai

Provider Options

Each provider has typed options that are validated at build time and runtime:

OpenAI Provider Options

OpenRouter Provider Options

Cerebras Provider Options

Google Provider Options

Groq Provider Options

Cloudflare Provider Options

xAI Provider Options

See the Anthropic, Baseten, Cloudflare Workers AI, Cerebras, Google, Groq, Novita AI, OpenAI, OpenRouter, and xAI documentation for complete options.

Model Capabilities

Set capabilities to help the framework understand what features the model supports:

Provider Tools

Some providers offer built-in tools. Enable the provider-defined tool names on the model with providerTools:
OpenAI Provider Tools:
  • web_search - Search the web with citations
  • file_search - Search uploaded files (requires vectorStoreId tenv)
  • code_interpreter - Execute Python code
  • image_generation - Generate images with GPT-image-1
OpenRouter Provider Tools:
  • web_search - Search the web through OpenRouter server tools
  • web_fetch - Fetch and extract URL content through OpenRouter
  • datetime - Resolve the current date and time through OpenRouter
  • image_generation - Generate images through OpenRouter server tools
Provider packages translate these names into their native request format and execute them through the provider API. AgentBuilder discovers and selects the tools, but does not execute provider tools locally. Completed calls are recorded through the generic provider-tool log path.

Fallback Models

Fallback models provide resilience when the primary model is unavailable or fails. The system automatically retries with fallback models for:
  • Network errors
  • Rate limits (429)
  • Server errors (5xx)
  • Authentication errors (401)
Fallbacks reference other models you’ve defined with defineModel by their name:

Retry Sequence

When a request fails:
  1. Primary model (attempt 1) → Failed? Retry…
  2. Primary model (attempt 2) → Failed? Try fallback…
  3. Fallback 1 (attempt 1) → Failed? Retry…
  4. Fallback 1 (attempt 2) → Failed? Try next fallback…
  5. Fallback 2 (attempt 1) → Failed? Retry…
  6. Fallback 2 (attempt 2) → Failed? Throw error
Configure fallbacks for production deployments to ensure high availability. Choose fallback models from different providers to avoid provider-specific outages.

Pricing Configuration

Configure pricing to track token costs across your application:
Pricing units: All prices are in USD per 1 million tokens

Current Pricing Examples

Prices shown may change. Check provider websites for current pricing. OpenRouter models fetch pricing automatically.

Type Safety

After defining models, Standard Agents generates the StandardAgents.Models type:
This enables type-safe model references in prompts:

Common Patterns

Cost-Optimized Chain

Use cheaper models with expensive fallbacks:

Multi-Provider Resilience

Fallbacks across providers for maximum uptime:

Environment Setup

Configure provider API keys as environment variables:
.dev.vars
For hosted projects, configure production provider keys through the Standard Agents platform environment settings. For self-managed Worker deployments, use Cloudflare secrets:

File Organization

Models are auto-discovered from the agents/models/ directory:
Requirements:
  • Use snake_case for file names: heavy_thinking.ts, fast_response.ts
  • One model per file
  • Default export required

Next Steps

Model API Reference

Complete defineModel specification

Baseten Provider

Baseten Model APIs

Cloudflare Provider

Workers AI chat completions

Cerebras Provider

OpenAI-compatible chat completions

Google Provider

Gemini and Imagen

Groq Provider

Groq chat completions

Novita Provider

OpenAI-compatible Novita models

OpenAI Provider

OpenAI-specific configuration

OpenRouter Provider

Multi-provider gateway

xAI Provider

Grok chat and image models

Prompts

Learn how to use models in prompts