Skip to content

Latest commit

 

History

History
106 lines (82 loc) · 2.96 KB

File metadata and controls

106 lines (82 loc) · 2.96 KB

Use Claude Code with CometAPI

Canonical docs: https://apidoc.cometapi.com/integrations/claude-code

Use this guide to configure Claude Code with CometAPI through Anthropic-compatible credentials, base URL settings, and Claude model IDs. Use this guide to connect Claude Code to CometAPI.

Official references:

Note Model availability changes over time. For current Claude model IDs, check the CometAPI Models page.

Prerequisites

  • A CometAPI key from your dashboard (starts with sk-)
  • Git installed
  • Supported OS: macOS, Linux, or Windows

Install Claude Code

Run the official installer

macOS / Linux

curl -fsSL https://claude.ai/install.sh | bash

Homebrew

brew install --cask claude-code

Windows

PowerShell:

irm https://claude.ai/install.ps1 | iex

CMD:

curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

Info: Windows requires Git for Windows installed first.

Verify installation

claude --version

Configure CometAPI endpoint

Create or edit the settings file:

  • macOS / Linux: ~/.claude/settings.json
  • Windows: %USERPROFILE%\.claude\settings.json
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "sk-your-cometapi-key",
    "ANTHROPIC_BASE_URL": "https://api.cometapi.com"
  }
}

Replace sk-your-cometapi-key with your actual CometAPI key, then start Claude Code:

cd your-project
claude

Troubleshooting

settings.json does not take effect

  1. Restart your terminal completely by closing all windows and reopening it.
  2. If it still does not work, create ~/.claude.json and add:
{
  "hasCompletedOnboarding": true
}
  1. As a fallback, export environment variables directly:
# Add to ~/.zshrc (macOS) or ~/.bashrc (Linux)
export ANTHROPIC_AUTH_TOKEN="sk-your-cometapi-key"
export ANTHROPIC_BASE_URL="https://api.cometapi.com"

Invalid API Key or Please run /login

Check that ~/.claude/settings.json exists and the JSON format is valid with no trailing commas and correct quotes. Validate at jsonlint.com.

Cached official credentials are used

Claude Code prioritizes cached official credentials. Run /logout inside Claude Code, close it, then restart.

If it still fails, remove the cached auth file:

rm -rf ~/.config/claude-code/auth.json

Status shows offline

Claude Code checks connectivity via Google. offline means Google is unreachable. This does not affect CometAPI usage.

Fetch or web browsing fails

Claude Code's Fetch feature calls Anthropic's native service first, which requires direct internet access. A system-wide proxy may be needed.