Model Configuration

Copy page

Configure AI models for your Agents and Sub Agents

Configure models at Project (required), Agent, or Sub Agent levels. Settings inherit down the hierarchy.

Configuration Hierarchy

You must configure at least the base model at the project level:

// inkeep.config.ts
export default defineConfig({
  models: {
    base: {
      model: "anthropic/claude-sonnet-4-5",
      providerOptions: { temperature: 0.7, maxOutputTokens: 2048 }
    }
  }
});

Override at agent or sub agent level:

const myAgent = agent({
  models: {
    base: { model: "openai/gpt-5.2" }  // Override project default
  }
});

const mySubAgent = subAgent({
  models: {
    structuredOutput: { model: "openai/gpt-4.1-mini" }  // Override for JSON output
  }
});

Model Types

TypePurposeFallback
baseText generation and reasoningRequired at project level
structuredOutputJSON/structured output onlyFalls back to base
summarizerSummaries and status updatesFalls back to base

Supported Models

ProviderExample ModelsAPI Key
Anthropicanthropic/claude-sonnet-4-6
anthropic/claude-sonnet-4-5
anthropic/claude-haiku-4-5
anthropic/claude-opus-4-6
ANTHROPIC_API_KEY
OpenAIopenai/gpt-5.4-pro
openai/gpt-5.4
openai/gpt-5.4-mini
openai/gpt-5.4-nano
openai/gpt-5.2
openai/gpt-5.1
openai/gpt-4.1
openai/gpt-4.1-mini
openai/gpt-4.1-nano
openai/gpt-5*
OPENAI_API_KEY
Azure OpenAIazure/my-gpt4-deployment
azure/my-gpt35-deployment
AZURE_API_KEY
Googlegoogle/gemini-3.1-pro-preview
google/gemini-2.5-flash
google/gemini-2.5-flash-lite
GOOGLE_GENERATIVE_AI_API_KEY
OpenRouteropenrouter/anthropic/claude-sonnet-4-0
openrouter/meta-llama/llama-3.1-405b
OPENROUTER_API_KEY
Gatewaygateway/openai/gpt-4.1-miniAI_GATEWAY_API_KEY
NVIDIA NIMnim/nvidia/llama-3.3-nemotron-super-49b-v1.5
nim/nvidia/nemotron-4-340b-instruct
NIM_API_KEY
Custom OpenAI-compatiblecustom/my-custom-model
custom/llama-3-custom
CUSTOM_LLM_API_KEY
Mockmock/defaultNone required
Note
Note
*openai/gpt-5, openai/gpt-5-mini, and openai/gpt-5-nano require a verified OpenAI organization. If your organization is not yet verified, these models will not be available.

Pinned vs Unpinned Models

Pinned models include a specific date or version (e.g., anthropic/claude-sonnet-4-20250514) and always use that exact version.

Unpinned models use generic identifiers (e.g., anthropic/claude-sonnet-4-5) and let the provider choose the latest version, which may change over time as providers update their models.

models: {
  base: {
    model: "anthropic/claude-sonnet-4-5",  // Unpinned - provider chooses version
    // vs
    model: "anthropic/claude-sonnet-4-20250514"  // Pinned - exact version
  }
}

The TypeScript SDK also provides constants for common models:

import { Models } from "@inkeep/agents-sdk";

models: {
  base: {
    model: Models.ANTHROPIC_CLAUDE_SONNET_4_5,  // Type-safe constants
  }
}

Provider Options

Inkeep Agents supports all Vercel AI SDK provider options.

How providerOptions works

providerOptions accepts two types of values:

  • Scalars (temperature, topP, maxOutputTokens, seed, maxDuration) — standard generation parameters applied to every call
  • Objects (anthropic: {}, openai: {}, gateway: {}, etc.) — provider-specific options for that provider

This means you can mix them freely:

providerOptions: {
  temperature: 0.7,            // generation param
  anthropic: {                 // Anthropic-specific options
    thinking: { type: 'enabled', budgetTokens: 8000 }
  }
}
Note
Note

Constructor-level config (baseURL, headers, resourceName, apiVersion) is always specified at the top level of providerOptions, not nested under a provider key.

Complete Examples

Basic configuration:

OpenAI with reasoning:

Anthropic with thinking:

Google with thinking:

Vercel AI Gateway:

When AI_GATEWAY_API_KEY is set, Anthropic, OpenAI, and Google models are automatically routed through Vercel AI Gateway for per-request cost tracking. No configuration changes are needed — your existing model strings work as-is. See AI Gateway below for fallback models, allowed providers, and advanced gateway configuration.

Azure OpenAI:

Note
Note

Azure OpenAI requires either resourceName (for standard Azure OpenAI deployments) or baseURL (for custom endpoints) in providerOptions. The AZURE_API_KEY environment variable must be set for authentication. Note that only one Azure OpenAI resource can be used at a time since authentication is handled via a single environment variable.

Custom OpenAI-compatible provider:

Note
Note

Custom OpenAI-compatible providers require a base URL to be specified in providerOptions.baseURL or providerOptions.baseUrl. The CUSTOM_LLM_API_KEY environment variable will be automatically used for authentication if present.

Context Window Override

For custom or unlisted models, you can explicitly specify the context window size:

Note
Note

The contextWindowSize option is useful when:

  • Using a custom model not in the built-in registry
  • The framework incorrectly detects the context window size
  • You want to artificially limit the context window for testing

This affects compression triggers and oversized artifact detection (artifacts exceeding 30% of the context window).

AI Gateway

Vercel AI Gateway provides intelligent model routing, automatic failover, and per-request cost tracking. All AI Gateway features require AI_GATEWAY_API_KEY to be set in your environment.

When the gateway is active, Anthropic, OpenAI, and Google models are automatically routed through it — no configuration changes needed. This enables fallback models and allowed providers for those providers. Per-request cost tracking is available for any model routed through the gateway.

For self-hosted deployments, you can bring your own API keys (BYOK) for any provider by configuring them in your Vercel AI Gateway team settings.

Fallback Models

Configure an ordered list of backup models that the gateway tries if the primary model fails or is unavailable:

If the primary model (anthropic/claude-sonnet-4-5) fails, the gateway automatically tries openai/gpt-5.2, then google/gemini-2.5-flash. If all models fail, the request errors.

Fallback models can be configured on any model slot (base, structuredOutput, summarizer). They inherit through the project → agent → sub agent hierarchy — even when a sub agent overrides the model itself, it still inherits fallbackModels from its parent unless it explicitly sets its own. All entries must use the provider/model format (e.g., "openai/gpt-5.2").

Allowed Providers

Restrict and prioritize which providers can serve requests. The order determines preference — the first provider in the list has the highest priority:

The gateway will try to serve the request via AWS Bedrock first. If Bedrock is unavailable, it falls back to Anthropic's direct API. When allowedProviders is set, the model string should omit the provider prefix (e.g., "claude-sonnet-4-5" instead of "anthropic/claude-sonnet-4-5") since the gateway determines which provider to use.

Available providers include: anthropic, openai, google, bedrock, azure, vertex.

Like fallbackModels, allowedProviders inherits through the project → agent → sub agent hierarchy even when the model is overridden at a lower level.

Combining Both

Both features can be used together. With this configuration, allowedProviders restricts and prioritizes which providers can serve the primary model, while fallbackModels defines alternative models to try if the primary model is unavailable:

models: {
  base: {
    model: "claude-sonnet-4-5",
    allowedProviders: ["bedrock", "anthropic"],
    fallbackModels: ["openai/gpt-5.2", "google/gemini-2.5-flash"],
  }
}

Advanced: Manual Gateway Provider Options

You can also configure gateway routing directly via providerOptions for access to the full gateway provider options (order, only, models, byok, providerTimeouts, tags, zeroDataRetention):

models: {
  base: {
    model: "gateway/openai/gpt-4.1",
    providerOptions: {
      gateway: {
        models: ["openai/gpt-4.1", "anthropic/claude-sonnet-4-5"],
      }
    }
  }
}
Note
Note

If you set both fallbackModels and providerOptions.gateway.models, fallbackModels takes precedence.

CLI Defaults

When using inkeep init, defaults are set based on your chosen provider:

ProviderBaseStructured OutputSummarizer
Anthropicclaude-sonnet-4-5claude-sonnet-4-5claude-sonnet-4-5
OpenAIgpt-4.1gpt-4.1-minigpt-4.1-nano
Googlegemini-2.5-flashgemini-2.5-flash-litegemini-2.5-flash-lite