Files
coder/docs/ai-coder/ai-gateway/clients/claude-code.md
T
Ben Potter cc001ccaf0 docs(docs/ai-coder/ai-gateway/clients): fix enable_aibridge -> enable_ai_gateway (#25098)
The Claude Code and Codex CLI registry modules expose the variable as
`enable_ai_gateway`, not `enable_aibridge`. Templates using the docs as
written fail Terraform init with `An argument named "enable_aibridge" is
not expected here.`

Verified in
[`registry/coder/modules/claude-code/main.tf`](https://github.com/coder/registry/blob/main/registry/coder/modules/claude-code/main.tf)
and
[`registry/coder-labs/modules/codex/main.tf`](https://github.com/coder/registry/blob/main/registry/coder-labs/modules/codex/main.tf),
where the variable is declared as `enable_ai_gateway` and gates the
`ANTHROPIC_BASE_URL` / `ANTHROPIC_AUTH_TOKEN` injection.

_Generated with the help of Coder Agents._
2026-05-12 08:18:41 -05:00

3.2 KiB

Claude Code

Note

AI Gateway requires the AI Governance Add-On. As of Coder v2.32, deployments without the add-on will not be able to access AI Gateway.

Claude Code can be configured using environment variables. All modes require a Coder API token for authentication with AI Gateway.

Centralized API Key

# AI Gateway base URL.
export ANTHROPIC_BASE_URL="<your-deployment-url>/api/v2/aibridge/anthropic"

# Your Coder API token, used for authentication with AI Gateway.
export ANTHROPIC_AUTH_TOKEN="<your-coder-api-token>"

BYOK (Personal API Key)

# AI Gateway base URL.
export ANTHROPIC_BASE_URL="<your-deployment-url>/api/v2/aibridge/anthropic"

# Your personal Anthropic API key, forwarded to Anthropic.
export ANTHROPIC_API_KEY="<your-anthropic-api-key>"

# Your Coder API token, used for authentication with AI Gateway.
export ANTHROPIC_CUSTOM_HEADERS="X-Coder-AI-Governance-Token: <your-coder-api-token>"

# Ensure no auth token is set so Claude Code uses the API key instead.
unset ANTHROPIC_AUTH_TOKEN

BYOK (Claude Subscription)

# AI Gateway base URL.
export ANTHROPIC_BASE_URL="<your-deployment-url>/api/v2/aibridge/anthropic"

# Your Coder API token, used for authentication with AI Gateway.
export ANTHROPIC_CUSTOM_HEADERS="X-Coder-AI-Governance-Token: <your-coder-api-token>"

# Ensure no auth token is set so Claude Code uses subscription login instead.
unset ANTHROPIC_AUTH_TOKEN

When you run Claude Code, it will prompt you to log in with your Anthropic account.

Pre-configuring in Templates

Template admins can pre-configure Claude Code for a seamless experience. Admins can automatically inject the user's Coder session token and the AI Gateway base URL into the workspace environment.

module "claude-code" {
  source            = "registry.coder.com/coder/claude-code/coder"
  version           = "4.7.3"
  agent_id          = coder_agent.main.id
  workdir           = "/path/to/project"  # Set to your project directory
  enable_ai_gateway = true
}

Coder Tasks

Coder Tasks provides a framework for agents to complete background development operations autonomously. Claude Code can be configured in your Tasks automatically:

resource "coder_ai_task" "task" {
  count  = data.coder_workspace.me.start_count
  app_id = module.claude-code.task_app_id
}

data "coder_task" "me" {}

module "claude-code" {
  source            = "registry.coder.com/coder/claude-code/coder"
  version           = "4.7.3"
  agent_id          = coder_agent.main.id
  workdir           = "/path/to/project"  # Set to your project directory
  ai_prompt         = data.coder_task.me.prompt

  # Route through AI Gateway (AI Governance Add-On)
  enable_ai_gateway = true
}

VS Code Extension

The Claude Code VS Code extension is also supported.

  1. If pre-configured in the workspace environment variables (as shown above), it typically respects them.
  2. You may need to sign in once; afterwards, it respects the workspace environment variables.

References: Claude Code Settings