Docs · Guide
Use DeepSeek, Kimi, GLM or your Claude and ChatGPT subscription in OpenCode
OpenCode reaches a model through a provider in its config. magpie adds one provider, named magpie, that leads to a gateway on your computer. Every model you have in magpie is listed under it: DeepSeek, Kimi, GLM and Qwen keys, and the models of a Claude, ChatGPT or Copilot sign-in.
The gateway runs at 127.0.0.1:3425. OpenCode sends it OpenAI Chat Completions, and magpie passes each request on in the API its provider speaks, translating the request and the reply where they differ, streaming and tool calls included. OpenCode’s own providers stay as they were, next to magpie’s.
Chinese models
DeepSeek, Kimi and Kimi Code, Zhipu GLM (pay as you go or Coding Plan), Z.ai, MiniMax and Qwen.
Subscriptions
Claude Pro/Max, ChatGPT Plus/Pro and GitHub Copilot, signed in once in magpie.
Anything else
Any OpenAI- or Anthropic-compatible URL and key, Ollama and LM Studio.
Set it up
- Add the providerIn magpie’s Providers tab, press + Add provider, pick DeepSeek, Kimi, Zhipu GLM, MiniMax or Qwen, paste your API key and save. magpie asks the vendor which models it serves.
- Pick the model for OpenCodeIn the Agents tab, click the model on OpenCode’s row and choose one, such as
deepseek/deepseek-v4-pro. magpie writes"model": "magpie/deepseek/deepseek-v4-pro"into OpenCode’s config, with themagpieprovider beside it. - Or pick it in OpenCodeOnce the provider is there, magpie’s models are in OpenCode’s own
/modelslist undermagpie, so you can switch there too.
The same from a terminal:
magpie provider add deepseek sk-… magpie models # every model, as provider/model magpie opencode deepseek/deepseek-v4-pro # OpenCode's model magpie opencode small deepseek/deepseek-v4-flash # its small_model
OpenCode’s small_model is a field of its own on the row, so it can run on a cheaper model than the main one.
Subscriptions
Sign in once in magpie, from + Add provider or a terminal, and the subscription’s models are listed under magpie in OpenCode like any other. No API key.
| Subscription | Models are | From a terminal |
|---|---|---|
| Claude (Pro, Max, Team) | claude/… | magpie accounts add claudemagpie opencode claude/claude-opus-5-5 |
| ChatGPT (Plus, Pro, Business) | codex/… | magpie accounts add codexmagpie opencode codex/gpt-5.5 |
| GitHub Copilot | copilot/… | magpie accounts add copilot |
Requests on a Claude subscription run through the Claude Code installed on your computer, so keep it installed. Copilot gives you a code to enter on GitHub’s page. Several accounts of one subscription can share the load and fail over; see Subscriptions in any agent.
What changes in opencode.json
magpie writes to the config file OpenCode reads from its config folder, $OPENCODE_CONFIG_DIR when that is set and ~/.config/opencode otherwise: the first of opencode.jsonc, opencode.json and config.json that exists, or a new opencode.json. It changes only these keys; your other settings stay.
| Key | Set to |
|---|---|
model | magpie/<provider>/<model> |
small_model | The same form, when you set one |
provider.magpie.npm | @ai-sdk/openai-compatible |
provider.magpie.options.baseURL | http://127.0.0.1:3425/v1 |
provider.magpie.options.apiKey | The gateway’s key |
provider.magpie.models | Every model magpie lists for OpenCode |
Each model carries its context window and output limit, so OpenCode knows when to compact; whether it takes images; its reasoning levels; and its price. magpie keeps the list up to date as you add providers and accounts. If the file also has the provider under providers, where OpenCode 2 keeps it, magpie writes it there as well. OpenCode in a WSL distro on Windows is set up the same way, in the distro’s ~/.config/opencode.
Reasoning levels and cost
- Reasoning levels. A model’s reasoning efforts are written as its variants in OpenCode, each one asking for that
reasoningEffort. A model that offers fast processing, such as a GPT model from a ChatGPT plan, also gets afastvariant for each level. - Cost. magpie writes each model’s price per million tokens, input, output, cache read and cache write, so OpenCode’s session cost counts, where without it every model costs 0.
- Prompt caching. magpie turns on OpenCode’s prompt cache key for its provider, so a provider that caches by it keeps the cache between turns.
A shorter model list
By default OpenCode is shown every model you have in magpie. To show it only some providers or groups:
magpie visible opencode deepseek,claude # only these providers magpie visible opencode all # every model again
A model left out of the list still answers when OpenCode asks for it by name.
Switch back
On OpenCode’s row in magpie, the model picker lists OpenCode’s own providers too, the ones signed in in its auth.json. Pick one of them, or run:
magpie opencode default
It puts back the model and small_model OpenCode had before magpie, and takes the magpie provider out of the file.
By provider: DeepSeek · Kimi and Kimi Code · GLM Coding Plan · Qwen · MiniMax
FAQ
How do I use DeepSeek in OpenCode?
Add DeepSeek with your API key in magpie, then pick a DeepSeek model on OpenCode’s row in the Agents tab, or run magpie opencode deepseek/deepseek-v4-pro. magpie adds a magpie provider to opencode.json and sets the model.
Can I use Kimi or GLM in OpenCode?
Yes. Add Kimi or Zhipu GLM in magpie and pick its model for OpenCode. For a GLM Coding Plan key, pick the Coding Plan when you add it, since it has its own endpoints.
Can I use my Claude Pro or Max subscription in OpenCode?
Yes. Sign in to Claude in magpie (magpie accounts add claude) and pick a claude/… model for OpenCode. Requests on a Claude subscription run through the Claude Code installed on your computer, so keep it installed.
Can I use my ChatGPT Plus or Pro subscription in OpenCode?
Yes. Sign in to ChatGPT in magpie (magpie accounts add codex) and pick a codex/… model, such as codex/gpt-5.5. Its reasoning levels show as the model’s variants in OpenCode.
Which file does magpie change?
OpenCode’s config in ~/.config/opencode (or $OPENCODE_CONFIG_DIR): the first of opencode.jsonc, opencode.json and config.json, or a new opencode.json. It sets model and small_model and adds provider.magpie; other settings stay.
How do I switch back to OpenCode’s own model?
Pick one of OpenCode’s own models on its row in magpie, or run magpie opencode default. It puts back the model and small_model you had and removes magpie’s provider.
Other agents: Models in Claude Code, Models in Codex, Models in Gemini CLI. Stuck? Ask on Discord.