Skip to content

docs(docs/ai-coder): configure Claude API key helpers for AI Gateway - #31169

Closed
matifali wants to merge 2 commits into
mainfrom
docs-claude-api-key-helper
Closed

matifali wants to merge 2 commits into
mainfrom
docs-claude-api-key-helper

Conversation

@matifali

@matifali matifali commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Document one Claude Code API key helper for AI Gateway that tries coder login token and falls back to ANTHROPIC_AUTH_TOKEN when the CLI fails or returns an empty token. The helper reads credentials at runtime without copying token values into Claude settings.

Update the template example to module 5.5.3, which sets the helper automatically in user settings and preserves existing custom helpers. Depends on coder/registry#1204 and publication of that version. Related template bump: https://github.com/coder/dogfood/pull/739.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Docs preview

Check off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here.

@matifali
matifali requested a review from dannykopping October 23, 2026 10:37
@linear-code
linear-code Bot marked this pull request as ready for review October 23, 2026 10:37
@linear-code
linear-code Bot requested a review from nickvigilante as a code owner October 23, 2026 10:37
}
"ANTHROPIC_BASE_URL": "<your-deployment-url>/api/v2/ai-gateway/anthropic"
},
"apiKeyHelper": "token=$(coder login token 2>/dev/null) && [ -n \"$token\" ] && printf \"%s\" \"$token\" || printenv ANTHROPIC_AUTH_TOKEN"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This preferentially uses coder login token, meaning that if ANTHROPIC_AUTH_TOKEN is set it won't be used.

Don't we want to first try the env then fall back?
Using the login token is probably not ideal since it may have more permissions than needed (in the future, since we don't downscope the keys at the moment).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair call. I opted for coder login token as we can not be sure if ANTHROPIC_BASE_URL is set and points to the correct deployment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove coder login token from module configuration but want to keep it for the genetic config as its easier for users to use it if they ave Coder CLI instaleld and logged in locally.
Will move it as the falback as oer the suggestion.

@nickvigilante nickvigilante left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation Check

Blocking

  • docs/ai-coder/ai-gateway/clients/claude-code.md (open) - The example pins the module to ~> 5.5.3 (line 82), but that version is not published to the Coder Registry; it only exists in the open coder/registry#1204. Merging this PR first would make terraform init fail to resolve the module.
  • docs/ai-coder/ai-gateway/clients/claude-code.md (open) - The sentence on line 89 says the module configures the helper automatically, but no published module version has that behavior; it lands with coder/registry#1204, which is not merged.

Related open PRs

  • coder/registry#1204 (open) publishes module 5.5.3 and adds the setup_gateway_api_key_helper auto-config that this page documents. Both findings above resolve if this PR merges after coder/registry#1204 is published.
  • coder/dogfood#739 (open) bumps the dogfood template to module 5.5.3.
Findings for agents
- id: accuracy-1
  persona: accuracy
  class: wrong
  blocking: true
  file: docs/ai-coder/ai-gateway/clients/claude-code.md
  line: 82
  quote: '  version           = "~> 5.5.3"'
  evidence:
    - "gh api repos/coder/registry/tags (pages 1-7): latest claude-code module tag is release/coder/claude-code/v5.5.2; no release/coder/claude-code/v5.5.3 exists"
    - "curl registry main install.sh.tftpl: 0 occurrences of setup_gateway_api_key_helper; all README examples still pin 5.5.2"
    - "gh pr view 1204 --repo coder/registry: state OPEN, mergedAt null. The 5.5.3 bump and the helper auto-config live only in this unmerged PR."
  rule: null
  problem: The Terraform example pins the module to `~> 5.5.3`, but the Coder Registry has not published that version. If this PR merges first, a reader who copies the block gets a `terraform init` that cannot resolve the module, because the latest published tag is 5.5.2.
  fix: Merge coder/registry#1204 and publish release/coder/claude-code/v5.5.3 before or with this PR. Merging after coder/registry#1204 is published resolves it.
  verified: true
- id: accuracy-2
  persona: accuracy
  class: wrong
  blocking: true
  file: docs/ai-coder/ai-gateway/clients/claude-code.md
  line: 89
  quote: 'The module configures the helper in `~/.claude/settings.json` automatically when you set `enable_ai_gateway = true`.'
  evidence:
    - "curl registry main install.sh.tftpl: 0 occurrences of setup_gateway_api_key_helper, the function that writes apiKeyHelper to ~/.claude/settings.json"
    - "gh pr view 1204 --repo coder/registry: state OPEN, not merged; setup_gateway_api_key_helper is added only in this PR"
  rule: null
  problem: The sentence says the module configures the helper automatically when `enable_ai_gateway = true`, but that behavior does not exist in any published module version. It only exists once coder/registry#1204 merges, which is still open. If this PR merges first, the docs describe behavior a reader cannot get.
  fix: Merge coder/registry#1204 and publish the module before or with this PR. Merging after coder/registry#1204 is published resolves it.
  verified: true

Generated by Coder Agents on behalf of @nickvigilante, using the proposed doc-check skill from #31193 on Solstice-1 Local. Reply in a thread if a finding is wrong.

module "claude-code" {
source = "registry.coder.com/coder/claude-code/coder"
version = "~> 5.2"
version = "~> 5.5.3"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking: (Fact Checker) This example pins the module to ~> 5.5.3, but the Coder Registry has not published that version: the latest tag is release/coder/claude-code/v5.5.2, and the 5.5.3 bump only exists in the open, unmerged coder/registry#1204. If this PR merges first, terraform init cannot resolve the module for a reader who copies this block. Fix: merge and publish coder/registry#1204 before or with this PR. Merging after coder/registry#1204 is published resolves it.

}
```

The module configures the helper in `~/.claude/settings.json` automatically when you set `enable_ai_gateway = true`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking: (Fact Checker) This sentence says the module configures the helper in ~/.claude/settings.json automatically, but that behavior is not in any published module version: the setup_gateway_api_key_helper function that writes the helper was added only in the open, unmerged coder/registry#1204, and registry main still pins 5.5.2. If this PR merges first, the docs describe a behavior the reader cannot get. Fix: merge and publish coder/registry#1204 before or with this PR. Merging after coder/registry#1204 is published resolves it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR body already says that this depends on the registry PR. So this comment does not add any value and add noise.

@matifali

matifali commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Closing this until I come back to it again as part of the easier AI Gateway Configuration through clients.

@matifali matifali closed this Nov 4, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants