Skip to content

Use with Third-Party Providers

Connect Chimera to any LLM backend — cloud APIs, local servers, or OpenAI-compatible endpoints — by setting a few environment variables or passing arguments to create_provider().


chimera.create_provider() resolves a provider in this order:

  1. Explicit provider_type — if you pass "anthropic", "openai", "ollama", "compatible", etc., that is used directly.
  2. Model name prefixclaude-* maps to Anthropic, gpt-* / o1-* / o3-* to OpenAI, gemini-* to Google, llama* / mistral* / qwen* / phi* to Ollama.
  3. Provider catalog — checks the built-in model catalog.
  4. Environment variables — if ANTHROPIC_BASE_URL or ANTHROPIC_AUTH_TOKEN is set, falls back to the Anthropic provider. If OPENAI_API_KEY is set, falls back to OpenAI.

The model name itself comes from the model= argument, or from the ANTHROPIC_MODEL / OPENAI_MODEL environment variable when omitted.


Set the three environment variables that the Anthropic provider reads:

Terminal window
export ANTHROPIC_BASE_URL="https://api.z.ai/api/anthropic"
export ANTHROPIC_AUTH_TOKEN="your-token"
export ANTHROPIC_MODEL="glm-5"

Then create a provider with zero arguments:

import chimera
provider = chimera.create_provider() # picks up all three env vars

Or pass the model explicitly and let the env vars supply the rest:

provider = chimera.create_provider(model="glm-5")

Because glm-5 does not match any known prefix, the factory sees ANTHROPIC_BASE_URL in the environment and routes to the Anthropic provider with the custom base URL.


OpenRouter exposes an Anthropic-compatible API, so the same env vars apply:

Terminal window
export ANTHROPIC_BASE_URL="https://openrouter.ai/api"
export ANTHROPIC_AUTH_TOKEN="your-openrouter-key"
export ANTHROPIC_MODEL="anthropic/claude-sonnet-4-20250514"
import chimera
provider = chimera.create_provider()

Model names use OpenRouter’s provider/model format (e.g. google/gemini-2.0-flash, meta-llama/llama-3-70b). Any model listed on OpenRouter works — the Anthropic provider forwards the name as-is. OpenRouter handles failover and load balancing on their side.


For servers that expose /v1/chat/completions (vLLM, LiteLLM, Together, Fireworks, Groq), use the compatible provider type:

import chimera
provider = chimera.create_provider(
"compatible",
model="my-local-model",
base_url="http://localhost:8000/v1",
)

base_url is required for compatible. An optional api_key can be passed if the server requires authentication:

provider = chimera.create_provider(
"compatible",
model="meta-llama/Llama-3-70B",
base_url="https://api.together.xyz/v1",
api_key="your-together-key",
)

Models whose names start with llama, mistral, qwen, or phi are auto-detected as Ollama:

import chimera
provider = chimera.create_provider(model="llama3.2")

For other model names, specify the provider type explicitly:

provider = chimera.create_provider(
"ollama",
model="deepseek-r1",
base_url="http://localhost:11434",
)

The default base URL is http://localhost:11434, so you can omit it when Ollama runs on the standard port.


chimera.providers.catalog.ProviderCatalog.default() ships with entries for popular hosted and local model lines so you can bring up a provider with a single string. The catalog auto-resolves base URLs, env vars, context windows, and per-Mtok pricing. New entries added across W11-W15:

Catalog idProviderSource / env varsContext
bedrock/claude-sonnet-4, bedrock/claude-haiku-3.5compatible (AWS Bedrock)AWS_BEDROCK_ENDPOINT, AWS_BEDROCK_KEY200k
azure/gpt-4o, azure/gpt-4o-minicompatible (Azure OpenAI)AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_KEY128k
groq/llama-3.3-70bcompatible (Groq)GROQ_API_KEY128k
deepseek-chat, deepseek-reasonercompatible (DeepSeek API)DEEPSEEK_API_KEY64k
deepseek-v4, deepseek-v4-procompatible (DeepSeek API)DEEPSEEK_API_KEY128k
deepseek-v4-pro:cloudollama (local cloud passthrough)OLLAMA_HOST262k
deepseek-v3.1-terminus, deepseek-coder-v3compatible (DeepSeek API)DEEPSEEK_API_KEY128k
qwen3-coder, qwen3-coder-30b, qwen3-32bollamaOLLAMA_HOST131k
glm-4.6, glm-5.1anthropic (api.z.ai)ANTHROPIC_AUTH_TOKEN200k
gpt-oss-120b, gpt-oss-20bollamaOLLAMA_HOST131k
kimi-k2-0905-preview, kimi-k2.5anthropic (api.moonshot.ai)MOONSHOT_API_KEY200k
mistral-codestral-2511ollamaOLLAMA_HOST256k
gemma3-27b-instructollamaOLLAMA_HOST131k

Use a catalog entry directly:

from chimera.providers.catalog import ProviderCatalog
catalog = ProviderCatalog.default()
provider = catalog.create("deepseek-coder-v3") # reads $DEEPSEEK_API_KEY

Or register your own entry:

from chimera.providers.catalog import ModelConfig, ProviderCatalog
catalog = ProviderCatalog.default()
catalog.register(ModelConfig(
model="acme/internal-llm",
provider_type="compatible",
base_url="https://llm.acme.internal/v1",
api_key_env="ACME_LLM_KEY",
context_window=64_000,
cost=(0.50, 1.50), # USD per Mtok input / output
))
provider = catalog.create("acme/internal-llm")

create_provider() falls through to the catalog automatically when a model name matches a registered entry, so most code paths can keep using chimera.create_provider(model="deepseek-coder-v3") and the right provider/base-url/key combination is wired up for them.


Keep credentials out of your shell history by storing them in a .env file at the project root:

.env
ANTHROPIC_BASE_URL="https://api.z.ai/api/anthropic"
ANTHROPIC_AUTH_TOKEN="your-token"
ANTHROPIC_MODEL="glm-5"

Source it before running Chimera:

Terminal window
source .env
chimera code