Add providers and API keys
A provider is a place that runs models: a cloud service, a local engine, or a logged-in subscription CLI. This page shows how to add each kind to prism.yaml and how to handle API keys safely.
The four provider types
type | Use it for | Needs |
|---|---|---|
openai | OpenAI, DeepSeek, Qwen, Mistral, Groq, OpenRouter, Moonshot, and local engines (Ollama, vLLM, LM Studio, llama.cpp server) | base_url, and a key for cloud services |
anthropic | The Anthropic API (Claude) | base_url and a key |
claude-code | Your Claude subscription, through the logged-in claude CLI | The CLI installed and logged in |
codex-cli | Your ChatGPT subscription, through the logged-in codex CLI | The CLI installed and logged in |
Keep API keys out of the file
Never paste a real API key into prism.yaml. Name an environment variable instead, and Prism reads the key from it when it starts:
api_key_env: ANTHROPIC_API_KEYThen set the variable in the terminal that runs prism serve:
export ANTHROPIC_API_KEY=your-key-here
prism serveYou can also write api_key: ${ANTHROPIC_API_KEY}; Prism replaces the ${...} part with the variable's value. Keys never appear in Prism's logs or API responses.
DANGER
Do not commit prism.yaml to a public repository if it contains a literal key. The desktop companion's Providers card writes keys into the file as literal api_key values; it restricts the file so only your user can read it, but the key is still stored in plain text.
Add a cloud provider
Add a block under
providers:. For Anthropic:yaml- name: anthropic type: anthropic base_url: https://api.anthropic.com api_key_env: ANTHROPIC_API_KEY models: - id: claude-sonnet-4-5 aliases: [claude-sonnet] context_window: 200000 capabilities: [code, reasoning, vision, tools] speed: fast cost: {input_per_mtok: 3.00, output_per_mtok: 15.00}For an OpenAI-compatible service, use
type: openaiand the service's base URL. For DeepSeek:yaml- name: deepseek type: openai base_url: https://api.deepseek.com/v1 api_key_env: DEEPSEEK_API_KEY models: - id: deepseek-chat aliases: [deepseek] context_window: 128000 capabilities: [code, reasoning, tools] cost: {input_per_mtok: 0.27, output_per_mtok: 1.10}Set the environment variables and check the result:
bashprism models
The model id must be the exact name the provider expects. Prices in cost are US dollars per million tokens. Copy them from the provider's price list; Prism uses them only for its cost records and budget. The values above are examples from the project's sample config and may be out of date.
Add a local engine
Any local engine with an OpenAI-compatible API works like Ollama in the beginner guide. Use its address as base_url and add local: true:
- name: lmstudio
type: openai
base_url: http://127.0.0.1:1234/v1
local: true
models:
- id: your-model-name
context_window: 32768
capabilities: [code]The address and model name here are placeholders: use the ones your engine shows. local: true matters: offline mode and local:any targets only use local providers.
Use your subscription as a provider
If you pay for Claude Pro or Max, or a ChatGPT plan, the logged-in CLI on your machine can answer requests. Prism runs the CLI's headless mode once per request. Nothing is billed per token; usage comes out of your plan.
- name: claude-subscription
type: claude-code
models:
- id: sonnet # sonnet, opus, haiku, or a full model name
aliases: [claude-sub]
context_window: 200000
capabilities: [code, reasoning]
- name: codex-subscription
type: codex-cli
models:
- id: gpt-5.1-codex
aliases: [codex-sub]
context_window: 400000- Do not set
base_urlor a key. Prism refuses them for these types. - The CLI must be installed and logged in. Check with
claude -p hi. - If the CLI is not on the
PATHthe gateway sees, addcommand: [/home/you/.local/bin/claude]with your real path. - Leave
costat zero, since you pay a flat fee.
Limits of subscription providers:
- Images and tool definitions are refused with a
400error. - Answers come from the CLI, with its own instructions in the context, so they may read like an agent's replies.
- Each request starts the CLI, which adds a delay.
- When your plan's limit is reached, the CLI fails and Prism moves to the next model in the failover chain.
Model fields
| Field | What it is for |
|---|---|
id | The model name the provider expects. Required |
aliases | Short names for routing and requests. Every id and alias must be unique across all providers |
context_window | Largest request in tokens. Prism skips a model when the estimated request is bigger |
capabilities | Tags such as code, reasoning, vision, tools. Used by targets like local:code |
speed | A label such as fast or medium, returned by GET /v1/models |
cost | input_per_mtok and output_per_mtok in US dollars. Zero for local models |
Other provider fields: headers adds HTTP headers to every request to that provider, and local marks it as local. All fields are in the reference.