melwyn.ai
← All playbooks
Free playbook
12 minVerified June 30, 2026

Run Claude Code directly on GLM, Kimi, or DeepSeek

Skip the middleman. Point Claude Code straight at a provider's own endpoint for the lowest price, often a flat coding plan, with the trade-offs mapped.

claude-codeopen-sourcedeepseekglmkimivscodedirect

Distilled from DeepSeek's Anthropic API documentation.

The outcome

By the end you'll have Claude Code driving GLM, Kimi, or DeepSeek through the provider's own endpoint, on the cheapest plan each one offers.

  • Claude Code installed (the terminal CLI, or the VS Code extension)
  • An account and API key from at least one of GLM, Kimi, or DeepSeek
  • Ten minutes and a text editor for one config file

OpenRouter is the easy on-ramp: one key, every model. But it takes a small cut and bills by the token. Once you know which open model you like, going straight to its maker is usually cheaper, and GLM, Kimi, and DeepSeek each sell a flat monthly coding plan that undercuts per-token rates. Each one runs its own Claude Code endpoint, so the move is always the same: change the address and the key in one file. New to all this? Start with the OpenRouter guide, then come back here to cut the bill.

  1. 1. Put your config in one file

    Direct providers use the exact same file as the OpenRouter setup: ~/.claude/settings.json, read by Claude Code everywhere it runs. You'll fill in an env block with three values: the provider's address, your key, and a blank Anthropic key. Never opened this file? The walkthrough below has the exact commands, or copy the prompt at the top to let Claude do it.

    ~/.claude/settings.json. The next steps fill in the values.
    {
      "env": {
        "ANTHROPIC_BASE_URL": "...",
        "ANTHROPIC_AUTH_TOKEN": "...",
        "ANTHROPIC_API_KEY": ""
      }
    }
    Never opened this file? Create and open it, step by step

    The file sits in a hidden .claude folder in your home directory. Run these in a terminal to create it, then open it in an editor. On Windows, use PowerShell.

    macOS or Linux: create the folder and the empty file
    mkdir -p ~/.claude
    touch ~/.claude/settings.json
    Then open it in an editor
    code ~/.claude/settings.json     # opens it in VS Code
    
    # "code" not found? In VS Code press Cmd+Shift+P and run
    # "Shell Command: Install 'code' command in PATH", then try again.
    # No VS Code? Open it in TextEdit instead:
    open -e ~/.claude/settings.json
    Windows (PowerShell): create it, then open it in Notepad
    mkdir "$HOME\.claude" -Force
    notepad "$HOME\.claude\settings.json"

    Paste your provider's env block from step 3 into the file, then save and close. If the file already had something in it, keep it and add the env block inside the outer curly braces.

  2. 2. Pick a provider and get a key

    Three good options, each with its own Claude Code endpoint. GLM 5.2 from Z.AI is the strongest all-rounder and the most tuned for coding agents. Kimi K2 from Moonshot is fast and cheap. DeepSeek is the budget pick with a generous coding plan. Pick one, make an account, and create an API key. The links go to each provider's setup docs, which show where to get the key and confirm the current endpoint.

  3. 3. Paste your provider's endpoint

    Same file, same env block, only two values change: the address and the key. Pick your provider's block, paste it into ~/.claude/settings.json, and drop in your key. You usually don't set a model name at all, because these endpoints map Claude's own names (Opus, Sonnet, Haiku) onto their models for you. Each block also sets two safety lines for a non-Claude model: CLAUDE_CODE_DISABLE_1M_CONTEXT (stops the [1m] tag these endpoints reject) and CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING (stops the thinking mode the VS Code sidebar errors on). After you paste, fully quit and reopen Claude Code, since it reads the file only at startup, then run /status to confirm the endpoint is your provider.

    GLM (Z.AI). For Kimi or DeepSeek, open the block below.
    {
      "env": {
        "ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
        "ANTHROPIC_AUTH_TOKEN": "your-z-ai-key",
        "ANTHROPIC_API_KEY": "",
        "CLAUDE_CODE_DISABLE_1M_CONTEXT": "1",
        "CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING": "1"
      }
    }
    Kimi and DeepSeek blocks
    Kimi (Moonshot)
    {
      "env": {
        "ANTHROPIC_BASE_URL": "https://api.moonshot.ai/anthropic",
        "ANTHROPIC_AUTH_TOKEN": "your-moonshot-key",
        "ANTHROPIC_API_KEY": "",
        "CLAUDE_CODE_DISABLE_1M_CONTEXT": "1",
        "CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING": "1"
      }
    }
    DeepSeek
    {
      "env": {
        "ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
        "ANTHROPIC_AUTH_TOKEN": "your-deepseek-key",
        "ANTHROPIC_API_KEY": "",
        "CLAUDE_CODE_DISABLE_1M_CONTEXT": "1",
        "CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING": "1"
      }
    }
    Restart Claude Code, then check /status. The endpoint should be your provider.
    Claude Code

    claude

    /status

    Endpoint api.z.ai/api/anthropic

    # Endpoint points at the provider. Build exactly as you would on Claude.

  4. 4. Use it in VS Code, terminal and sidebar

    VS Code has two ways to run Claude Code, and they read your settings differently. The integrated terminal is just a terminal: open it, type claude, and you're on the provider, because it runs the same command that reads your file. The sidebar, the chat panel, is the catch. It checks your login before it ever reads ~/.claude/settings.json, so on a custom endpoint it never sees your key and bounces to the Anthropic sign-in screen. The fix is to give the extension its own copy of the values: open VS Code's own settings with Cmd+Shift+P and "Preferences: Open User Settings (JSON)," add them under claudeCode.environmentVariables as below, then reload with Cmd+Shift+P and "Developer: Reload Window." If you don't need the sidebar, the simpler move is to keep your provider work in the integrated terminal, which just works.

    To put the VS Code sidebar on the provider too, add this to VS Code's own settings (not the file above), then reload the window. GLM shown; swap the URL for Kimi or DeepSeek.
    // VS Code settings.json, not ~/.claude/settings.json
    {
      "claudeCode.environmentVariables": [
        { "name": "ANTHROPIC_BASE_URL", "value": "https://api.z.ai/api/anthropic" },
        { "name": "ANTHROPIC_AUTH_TOKEN", "value": "your-z-ai-key" },
        { "name": "ANTHROPIC_API_KEY", "value": "" }
      ]
    }
  5. 5. Know when to switch back to Claude

    The trade-offs match any open model: prompt caching may not carry through, so watch the provider's own dashboard for the true cost, and weaker models wander on long, tool-heavy runs. One thing weighs heavier going direct: GLM, Kimi, and DeepSeek are all hosted in China, so for client work or anything sensitive, check each provider's data and retention terms before you send real code. Send routine, high-volume work here, and keep deep, sensitive, multi-file work on Claude.

The takeaway

Going direct swaps two values: the provider's own Anthropic endpoint and your key. It is the cheapest way to run an open model in Claude Code, as long as the work is not sensitive enough to mind where it is hosted.

Prefer to learn by doing?

The interactive version of this playbook lives on melwyn Class, with animated terminal demos, Claude Code walkthroughs, and a library that saves your takeaways.