> ## Documentation Index
> Fetch the complete documentation index at: https://docs.a2agent.me/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect Claude Code to A2Agent for Budget LLM Access

> Route Claude Code through A2Agent to access DeepSeek, Kimi, GLM, and more at a fraction of the official price. One config file is all it takes.

Claude Code is Anthropic's agentic coding assistant. By pointing it at A2Agent, you replace the default Anthropic backend with models like DeepSeek, Kimi, or GLM — at a fraction of the official price — without changing how you use Claude Code day-to-day.

## Prerequisites

* Claude Code installed (see Step 1 if you haven't installed it yet)
* An A2Agent API key — [sign up at a2agent.me/register](https://a2agent.me/register) to get one

## Setup

<Steps>
  <Step title="Install Claude Code">
    If you haven't already, install Claude Code globally via npm:

    ```bash theme={null}
    npm install -g @anthropic-ai/claude-code
    ```
  </Step>

  <Step title="Locate or create the config file">
    Claude Code reads environment and permission settings from `~/.claude/settings.json`. Create the file if it doesn't exist:

    ```bash theme={null}
    mkdir -p ~/.claude && touch ~/.claude/settings.json
    ```
  </Step>

  <Step title="Add the A2Agent configuration">
    Open `~/.claude/settings.json` in your editor and paste the following, replacing the placeholder with your actual A2Agent key:

    ```json ~/.claude/settings.json theme={null}
    {
      "env": {
        "ANTHROPIC_AUTH_TOKEN": "sk-your-a2agent-key",
        "ANTHROPIC_BASE_URL": "https://api.a2agent.me",
        "CLAUDE_CODE_MAX_OUTPUT_TOKENS": "32000"
      },
      "permissions": { "allow": [], "deny": [] }
    }
    ```

    <Note>
      `ANTHROPIC_AUTH_TOKEN` must be your **A2Agent** API key — not a key from Anthropic. A2Agent accepts requests in the Anthropic API format and handles routing to the underlying model for you.
    </Note>

    <Tip>
      Setting `CLAUDE_CODE_MAX_OUTPUT_TOKENS` to `32000` allows Claude Code to produce longer, more complete responses. Lower this value if you want to keep individual completions shorter.
    </Tip>
  </Step>

  <Step title="Start Claude Code and verify the connection">
    Launch Claude Code from your terminal:

    ```bash theme={null}
    claude
    ```

    Send a short prompt to confirm it responds correctly. If you see a reply, A2Agent is handling your requests successfully.
  </Step>
</Steps>

## Recommended models

For coding tasks, these A2Agent models deliver the best results:

| Model             | Best for                             |
| ----------------- | ------------------------------------ |
| `deepseek-v4-pro` | Complex refactoring and architecture |
| `glm-5.1`         | General-purpose coding assistance    |
| `kimi-k2.7-code`  | Code generation and debugging        |
| `minimax-m2.5`    | Long-context code analysis           |

## Troubleshooting

<AccordionGroup>
  <Accordion title="401 Unauthorized">
    Claude Code is sending your request but A2Agent is rejecting the credentials. Open `~/.claude/settings.json` and confirm that `ANTHROPIC_AUTH_TOKEN` contains your full A2Agent key with no extra spaces or quotes.
  </Accordion>

  <Accordion title="Connection refused or network error">
    Verify that `ANTHROPIC_BASE_URL` is set to exactly `https://api.a2agent.me` — no trailing slash, no extra path segments. Any deviation will cause the connection to fail.
  </Accordion>

  <Accordion title="Model not found">
    If you are specifying a model explicitly, the model name must match an A2Agent model ID exactly — for example, `deepseek-v4-pro`, `kimi-k2.7-code`, `glm-5.1`, or `minimax-m2.5`. Check the [A2Agent model list](https://a2agent.me) for the full catalogue of available IDs.
  </Accordion>

  <Accordion title="Config changes not taking effect">
    Claude Code reads `~/.claude/settings.json` at startup. If you edited the file while Claude Code was already running, quit and relaunch it for the new settings to take effect.
  </Accordion>
</AccordionGroup>
