> ## Documentation Index
> Fetch the complete documentation index at: https://copilot-api.nick3.top/llms.txt
> Use this file to discover all available pages before exploring further.

# Use Copilot API with Claude Code

> Configure Claude Code to route requests through Copilot API, using your GitHub Copilot subscription as its AI backend instead of a separate Anthropic account.

This integration lets Claude Code route all its requests through Copilot API, so your existing GitHub Copilot subscription powers Claude Code without a separate Anthropic API key. This page covers two setup methods: an interactive one-command setup and a persistent manual configuration using `settings.json`.

<Warning>
  Set your model to `claude-opus-4-6` or `claude-opus-4.6` — without the `[1m]` suffix. Requesting a context window that exceeds GitHub Copilot's limit may trigger account restrictions.
</Warning>

## Method 1: Interactive setup with `--claude-code`

The quickest way to get started is the `--claude-code` flag. It starts the proxy, prompts you to pick models, and copies a ready-to-run Claude Code launch command to your clipboard.

<Steps>
  <Step title="Start the proxy with the flag">
    Run the following command in your terminal:

    ```bash theme={null}
    npx @nick3/copilot-api@latest start --claude-code
    ```
  </Step>

  <Step title="Select your models">
    The CLI prompts you to choose a primary model and a small, fast model for background tasks. Select the models you want to use.
  </Step>

  <Step title="Launch Claude Code">
    After you select models, the proxy copies a launch command to your clipboard. Paste and run it in a new terminal window to start Claude Code with the proxy already configured.
  </Step>
</Steps>

<Note>
  If you have API key authentication enabled (`auth.apiKeys` in `config.json`), set `ANTHROPIC_AUTH_TOKEN` to one of your configured keys so Claude Code can authenticate with the proxy.
</Note>

## Method 2: Manual configuration with `settings.json`

For a persistent setup that survives reboots without re-running the interactive flow, create a `.claude/settings.json` file at the root of your project.

<Steps>
  <Step title="Start the proxy">
    In one terminal, start the Copilot API proxy:

    ```bash theme={null}
    npx @nick3/copilot-api@latest start
    ```
  </Step>

  <Step title="Create the settings file">
    Create `.claude/settings.json` in your project root with the following content:

    ```json theme={null}
    {
      "env": {
        "ANTHROPIC_BASE_URL": "http://localhost:4141",
        "ANTHROPIC_AUTH_TOKEN": "dummy",
        "ANTHROPIC_MODEL": "gpt-5.4",
        "ANTHROPIC_DEFAULT_SONNET_MODEL": "gpt-5.4",
        "ANTHROPIC_DEFAULT_HAIKU_MODEL": "gpt-5-mini",
        "DISABLE_NON_ESSENTIAL_MODEL_CALLS": "1",
        "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
        "CLAUDE_CODE_ATTRIBUTION_HEADER": "0",
        "CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION": "false",
        "CLAUDE_CODE_DISABLE_TERMINAL_TITLE": "true",
        "CLAUDE_PLUGIN_ENABLE_QUESTION_RULES": "true"
      },
      "permissions": {
        "deny": [
          "WebSearch",
          "mcp__ide__executeCode"
        ]
      }
    }
    ```
  </Step>

  <Step title="Launch Claude Code">
    Start Claude Code in the same project directory. It will automatically pick up the settings file and route requests through the proxy.
  </Step>
</Steps>

### Key environment variables

| Variable                            | Value                   | Purpose                                                                                                                |
| ----------------------------------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `ANTHROPIC_BASE_URL`                | `http://localhost:4141` | Points Claude Code at the local proxy                                                                                  |
| `ANTHROPIC_AUTH_TOKEN`              | `dummy` (or a real key) | Required by Claude Code; use a real key if `auth.apiKeys` is configured                                                |
| `ANTHROPIC_MODEL`                   | e.g. `gpt-5.4`          | Primary model for most tasks                                                                                           |
| `ANTHROPIC_DEFAULT_SONNET_MODEL`    | e.g. `gpt-5.4`          | Model used for Sonnet-tier requests                                                                                    |
| `ANTHROPIC_DEFAULT_HAIKU_MODEL`     | e.g. `gpt-5-mini`       | Fast model for background and lightweight tasks                                                                        |
| `DISABLE_NON_ESSENTIAL_MODEL_CALLS` | `1`                     | Prevents warmup calls from consuming premium quota                                                                     |
| `CLAUDE_CODE_ATTRIBUTION_HEADER`    | `0`                     | Stops Claude Code from injecting billing and version info into system prompts, which would invalidate the prompt cache |

<Note>
  Set `ANTHROPIC_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` to consistent values. Keeping them aligned ensures Claude Code behaves like a native GitHub Copilot Claude agent.
</Note>

<Warning>
  Do not enable `ENABLE_TOOL_SEARCH`. Claude Code uses client-side tool search mode, which requires an extra request per deferred tool load and reduces cache hit rates. The proxy has known compatibility issues with client tool search mode that can cause errors.
</Warning>

## CLAUDE.md recommended content

Add the following reminders to your `CLAUDE.md` file. They instruct the model to use the `question` tool for user interactions instead of outputting free-form questions, which helps maintain clean tool semantics:

```
- Prohibited from directly asking questions to users, MUST use question tool.
- Once you can confirm that the task is complete, MUST use question tool to make user confirm. The user may respond with feedback if they are not satisfied with the result, which you can use to make improvements and try again, after try again, MUST use question tool to make user confirm again.
```

<Tip>
  If you set `CLAUDE_PLUGIN_ENABLE_QUESTION_RULES=1` in your settings, the Claude Code plugin injects these reminders automatically at session start — you do not need to add them to `CLAUDE.md` manually.
</Tip>

## Install the Claude Code plugin

After configuring the proxy, install the Claude Code plugin to enable subagent marker injection and session tracking. The plugin helps the proxy correctly classify subagent-originated traffic and preserve session context.

See the [Plugin Integrations guide](/guides/plugin-integrations) for installation instructions.
