Providers and gateways
Every provider, gateway and local runtime Cusp supports, how it detects them, and how it adapts to each model family.
Cusp talks to models through four wire protocols. Almost every provider, gateway and local server speaks at least one of them, which is how one runtime covers so many models.
| Wire protocol | Endpoint | Used for |
|---|---|---|
| Anthropic Messages | POST {root}/v1/messages | Anthropic, and the Anthropic-compatible endpoints of Z.ai, Moonshot, MiniMax, DeepSeek, Qwen, OpenRouter, Vercel, LiteLLM, Ollama and others |
| OpenAI Responses | POST {base}/responses | OpenAI, Azure OpenAI, xAI, and gateways that support it |
| OpenAI Chat Completions | POST {base}/chat/completions | Everything OpenAI-compatible: Groq, Together, Fireworks, Mistral, vLLM, LM Studio, … |
| Google Gemini | …/models/{model}:streamGenerateContent | Google AI Studio and Vertex AI |
When a provider speaks more than one, Cusp prefers the one that preserves the most: Responses for OpenAI and xAI, Messages for Anthropic, Z.ai, Moonshot and MiniMax, and generateContent for Gemini.
Providers
| Provider | Protocols | Key prefix | Environment variable | Notes |
|---|---|---|---|---|
| Anthropic | Messages | sk-ant- | ANTHROPIC_API_KEY | Prompt caching, token counting and documents fully supported |
| OpenAI | Responses, Chat | sk-proj-, sk-svcacct- | OPENAI_API_KEY | Native apply_patch tool and encrypted reasoning replay on Responses |
| Google Gemini | Gemini, Chat | AIza | GEMINI_API_KEY, GOOGLE_API_KEY | Thought signatures round-tripped |
| xAI | Responses, Chat | xai- | XAI_API_KEY | Conversation id header for cache affinity |
| DeepSeek | Chat, Messages | — | DEEPSEEK_API_KEY | Reasoning content replayed as required |
| Z.ai (GLM) | Messages, Chat | — | ZAI_API_KEY, ZHIPU_API_KEY | Coding plan endpoint; api.z.ai and open.bigmodel.cn |
| Moonshot (Kimi) | Messages, Chat | — | MOONSHOT_API_KEY, KIMI_API_KEY | .ai and .cn hosts |
| Alibaba Qwen (DashScope) | Chat, Messages | sk-sp- | DASHSCOPE_API_KEY | International, US and China regions |
| MiniMax | Messages, Chat | — | MINIMAX_API_KEY | Messages is MiniMax's recommended path |
| Xiaomi MiMo | Chat, Messages | tp- | MIMO_API_KEY | |
| Mistral | Chat | — | MISTRAL_API_KEY | Tool call ids normalized to Mistral's format |
| Groq | Chat | gsk_ | GROQ_API_KEY | |
| Cerebras | Chat | csk- | CEREBRAS_API_KEY | |
| Together AI | Chat | — | TOGETHER_API_KEY | |
| Fireworks AI | Chat, Messages | fw_ | FIREWORKS_API_KEY | |
| DeepInfra | Chat, Messages | — | DEEPINFRA_API_KEY | |
| Novita AI | Chat, Messages | — | NOVITA_API_KEY | |
| SiliconFlow | Chat, Messages | — | SILICONFLOW_API_KEY |
A dash in the key prefix column means the key format isn't distinctive. Cusp still identifies the provider by probing, or from the base URL.
Cloud platforms
| Platform | How to connect | Status |
|---|---|---|
| Azure OpenAI | Use your resource URL (https://{resource}.openai.azure.com/openai/v1/) with an API key. The model id is your deployment name | Supported through the Responses protocol |
| Amazon Bedrock | Use a Bedrock OpenAI-compatible or Anthropic-compatible endpoint with a Bedrock API key (bearer token) | Preview. SigV4 signing with AWS credentials is coming soon |
| Google Vertex AI | Use the Vertex endpoint with an access token, or express mode with an API key | Preview. Application Default Credentials are coming soon |
Cusp recognizes these from the host name (*.openai.azure.com, bedrock…, aiplatform.googleapis.com) and applies each platform's request differences automatically.
Gateways
A gateway gives you many models behind one key. Cusp treats each gateway as a provider and reads its model list, so you pick models by their gateway slug.
| Gateway | Protocols | Key prefix | Environment variable | Notes |
|---|---|---|---|---|
| OpenRouter | Chat, Messages, Responses | sk-or- | OPENROUTER_API_KEY | Session id for sticky routing; reasoning details replayed; prompt caching for Claude models |
| Vercel AI Gateway | Chat, Messages, Responses | vck_ | AI_GATEWAY_API_KEY | Prompt caching for Claude models |
| LiteLLM proxy | Chat, Messages | — | — | Self-hosted; default http://localhost:4000 |
Other OpenAI-compatible gateways (Portkey, Cloudflare AI Gateway, Helicone, and so on) work as a custom endpoint: give Cusp the base URL and any extra headers the gateway needs.
Local models
| Runtime | Default URL | Protocols |
|---|---|---|
| Ollama | http://localhost:11434 | Chat, Messages |
| LM Studio | http://localhost:1234 | Chat, Messages |
| vLLM | http://localhost:8000 | Chat |
| llama.cpp server, SGLang | Your server's URL | Chat |
No key is required for local runtimes. For local models Cusp picks the largest loaded model that supports tool calling with at least a 32k context window.
Small local models struggle with long agentic sessions. Cusp gives them the edit format that suits them best (see below), but expect more retries than with a frontier model. Give the server enough context length; many runtimes default to 4k or 8k tokens, which is too short for an agent.
Auto-detection
When you paste a key, with or without a base URL, Cusp runs a short pipeline:
- Hints. The key prefix (
sk-ant-,sk-or-,AIza, …) and the host of the base URL each point to a provider. - Probes. Cusp sends cheap, token-free requests (such as listing models) to each candidate protocol in parallel, with a 6-second timeout per probe.
- Fingerprints. Even a
401tells Cusp something: error bodies and headers identify the provider behind an unknown URL. - Models. The model list comes from the endpoint, enriched from Cusp's built-in catalog (context window, pricing, capabilities) and public sources.
- Pick. Cusp chooses a main model (the highest agentic score among models with tool calling) and a small model for auxiliary work: session titles, the auto-mode classifier, compaction and web page extraction.
You can override every result. Auto-detection only fills in a configuration; nothing is hidden.
Per-model-family adapters
The protocol is only half the story. Models from different labs were trained with different tool conventions, and they behave best when the harness speaks their dialect. Cusp keeps a profile per model family and adapts to it.
Edit format
| Family | Edit tool | Why |
|---|---|---|
| Claude, Gemini | Edit and MultiEdit (str_replace: exact old text → new text) | The format these models were trained on |
| GPT | ApplyPatch, sent as apply_patch (the V4A patch format) | OpenAI's models are trained on it; on OpenAI and Azure it is sent as the native tool |
| Weaker or local models | EditLines with hash-anchored lines | Each line in Read output carries a short content hash. The model edits by anchor (12:a3) instead of reproducing exact text, which removes the most common failure mode for small models |
Write is available to every family. Fuzzy matching for Edit goes through a ladder (exact, normalized whitespace, trimmed, re-indented, block-anchored) and reports which tier it used, so a near miss doesn't silently edit the wrong place.
Reasoning round-trip
Reasoning models return state that must be sent back on the next turn: Anthropic thinking signatures, OpenAI encrypted reasoning, Gemini thought signatures, and reasoning_content from DeepSeek, Kimi and GLM. Dropping it causes errors on some providers and a quiet loss of quality on others. Cusp stores this state opaquely with each message and replays it byte-exact to the same model. When you switch models mid-session, it sends a safe projection instead and notes the change.
Other adaptations
- Tool names and descriptions. GPT models see
update_planinstead ofTodoWrite. Hooks and permission rules always see the canonical name. - Strict schemas. On OpenAI, tool schemas are sent in strict mode, with optional fields made nullable and mapped back.
- Broken tool calls. Open models sometimes emit malformed JSON or tool calls embedded in text (Hermes, Qwen, GLM, MiniMax and Kimi markup). Cusp repairs JSON, coerces types against the schema, and extracts text-embedded calls before giving up.
- Parallel calls. Turned off for runtimes that don't support them.
- System prompts. Dynamic context goes where each provider handles it best: a mid-conversation system message on Claude, a
developeritem on OpenAI, a system reminder elsewhere.
Caching and cost
Cusp keeps the system prompt and tool list byte-stable across turns so providers can cache them. It sets the cache key each provider understands (prompt_cache_key on OpenAI, the session id on OpenRouter, a conversation header on xAI) and places Anthropic cache breakpoints automatically. Cost is computed per turn from the model's pricing, counting cache reads and writes separately. /cost in the CLI shows the running total.
Retries and fallbacks
Transient errors (rate limits, overloaded servers, dropped streams) are retried with backoff, and the UI tells you what happened: "Rate limited by Anthropic — retrying in 8 s." If a request fails because the endpoint rejects a parameter, Cusp learns from the error and retries without it. You can configure a fallback model (fallbackModel in settings); Cusp stays on one route as long as it works, to keep the cache warm.
Environment variables
The CLI and daemon pick up keys from these variables:
ANTHROPIC_API_KEY OPENAI_API_KEY GEMINI_API_KEY GOOGLE_API_KEY
OPENROUTER_API_KEY AI_GATEWAY_API_KEY XAI_API_KEY DEEPSEEK_API_KEY
ZAI_API_KEY ZHIPU_API_KEY MOONSHOT_API_KEY KIMI_API_KEY
MINIMAX_API_KEY DASHSCOPE_API_KEY MIMO_API_KEY MISTRAL_API_KEY
GROQ_API_KEY CEREBRAS_API_KEY TOGETHER_API_KEY FIREWORKS_API_KEY
DEEPINFRA_API_KEY NOVITA_API_KEY SILICONFLOW_API_KEYIn the desktop app, keys you paste are stored in the OS keychain instead.