LanternDOCS

Models

Lantern uses capability-based routing — your agent code asks for a capability (e.g. reasoning-large), and the model router maps it to the best concrete model from your configured providers at runtime. You never hardcode a vendor model name in agent code.

In plain termsInstead of telling Lantern "use GPT-4o" or "use Claude", you tell it what kind of intelligence the task needs — deep reasoning, quick chat, image understanding, code. Lantern picks the best available model that fits. The payoff: when a better or cheaper model ships, or a provider has an outage, your agents keep working without a single code change.

Supported providers

Lantern currently supports two LLM providers:

  • Anthropic — Claude models (Opus, Sonnet, Haiku)
  • OpenAI — GPT models (GPT-4o, GPT-4o-mini, etc.)

Both are supported equally in the model router and in LLM idempotency key derivation. Add a provider key under Settings > Models — the router only considers providers whose key you have configured.

Capability names

Use these capability strings in model fields or capability arguments:

CapabilityDescription
autoRouter picks the best model for each step (cost + quality)
reasoning-frontierHighest-capability reasoning (Opus, GPT-o1)
reasoning-largeLarge reasoning model (Sonnet, GPT-4o)
reasoning-smallFast, cheap reasoning (Haiku, GPT-4o-mini)
chat-largeConversational, large context
chat-smallLightweight chat, low latency
chat-edgeSmallest footprint for edge/embedded use
vision-largeImage understanding, large context
vision-smallLightweight vision
code-largeCode generation and analysis, large
code-smallCode generation, lightweight
embed-largeHigh-dimensional text embeddings
embed-smallFast, lower-dimensional embeddings

How auto works

With auto, the router scores every available model using a balanced formula (quality, speed, cost efficiency) and picks the winner at call time. It only considers models whose provider API key you have configured, and it respects your LANTERN_ROUTE_STRATEGY setting.

Routing strategies

# Default — best balance of quality, speed, and cost
LANTERN_ROUTE_STRATEGY=balanced

# Cheapest available (e.g., GPT-4o-mini, Haiku)
LANTERN_ROUTE_STRATEGY=cheap

# Highest quality regardless of cost
LANTERN_ROUTE_STRATEGY=quality

# Fastest response time
LANTERN_ROUTE_STRATEGY=fast

Failover

The model router handles provider failures automatically:

  • 5xx errors — immediate retry on the next provider in the failover chain
  • Rate limits (429) — exponential backoff with automatic rotation to an alternative provider
  • No mid-sentence swap — failover only happens before the first token; once streaming begins an error is a clean message_error, never a splice

LLM idempotency

Every LLM provider call carries an idempotency key so that a rate-limit backoff retry or crash-replay does not double-bill. The key is derived from sha256("runID|stepID|attempt") and sent as the Idempotency-Key request header. Failover targets get a per-provider-suffixed variant so the same logical call to two different providers is always distinguishable.

Adding API keys

Add your provider API key from the dashboard under Settings > Models, or via the API:

POST /v1/settings/llm-providers
{ "provider": "anthropic", "apiKey": "sk-ant-..." }

POST /v1/settings/llm-providers
{ "provider": "openai", "apiKey": "sk-..." }

Keys are AES-256-GCM encrypted at rest and never appear in logs, traces, or run state. They are resolved inside the microVM at execution time.