Skip to main content
LLM Config lets you set the model, API endpoint, and fallback chain so your agent always has a working model.
The user sends a prompt; the agent tries the primary model and transparently falls back if the provider fails.

Quick Start

1

Primary Model Only

Set just the model to get started:
2

With Fallback Chain

Add fallback models for reliability — if the primary fails, the agent automatically tries the next:
3

With LiteLLM Provider Prefix


How It Works


Configuration Options

LLMConfig SDK Reference

Full parameter reference for LLMConfig

Common Patterns

Pattern 1 — Self-hosted model via custom endpoint

Pattern 2 — Multi-provider fallback for resilience

Self-hosted model via Ollama:

Pattern 3 — Multi-provider fallback for business continuity


Best Practices

Even one fallback prevents your agent from failing completely during rate limits or outages. Use a smaller, cheaper model as the fallback — it costs less and is often available when the primary isn’t.
Never hardcode api_key in your code. Leave it as None and set OPENAI_API_KEY, ANTHROPIC_API_KEY, etc. in your environment instead. LLMConfig picks them up automatically via LiteLLM.
Prefix models with the provider name (anthropic/, openai/, ollama/) to avoid ambiguity when using multiple providers in a fallback chain.
Deliberately trigger a failure (e.g., invalid primary model name) and verify your fallback fires correctly before going to production.

LLM Gateways

Route requests through a unified LLM gateway

LLM Endpoint Config

Fine-tune endpoint parameters per model

LLM Error Classification

How errors trigger fallback in the chain

Failover

Automatic failover strategies for reliability