Skip to content

Conectar Claude Code

Claude Code utiliza Anthropic Messages API. Define ANTHROPIC_BASE_URL con la raíz de NordRouter, sin /v1, y proporciona la clave y el modelo mediante variables de entorno o settings.json.

  • Se recomienda ~/.claude/settings.json para compartir la configuración entre terminal y VS Code.
  • No añadas /v1: Claude Code incorpora /v1/messages por sí mismo.
  • Ante un inicio de sesión, 401 o /v1/v1, revisa por orden la opción de login, la clave y la Base URL.

Ejemplos completos

A continuación se conservan todos los ejemplos ejecutables de la guía original. Ejecuta únicamente los bloques que correspondan a tu herramienta y sistema operativo.

json
{
    "env": {
        "ANTHROPIC_API_KEY": "sk-nr-YOUR-KEY",
        "ANTHROPIC_BASE_URL": "https://nordrouter.com",
        "ANTHROPIC_MODEL": "anthropic/claude-opus-5",
        "ANTHROPIC_DEFAULT_OPUS_MODEL": "anthropic/claude-opus-5",
        "ANTHROPIC_DEFAULT_SONNET_MODEL": "anthropic/claude-sonnet-4.6",
        "ANTHROPIC_DEFAULT_HAIKU_MODEL": "anthropic/claude-haiku-4.5",
        "ANTHROPIC_SMALL_FAST_MODEL": "anthropic/claude-haiku-4.5",
        "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
    },
    "permissions": {
        "allow": [],
        "deny": []
    }
}
bash
export ANTHROPIC_BASE_URL=https://nordrouter.com
export ANTHROPIC_API_KEY=sk-nr-YOUR-KEY
export ANTHROPIC_MODEL=anthropic/claude-opus-5
claude
powershell
$env:ANTHROPIC_BASE_URL = "https://nordrouter.com"
$env:ANTHROPIC_API_KEY = "sk-nr-YOUR-KEY"
$env:ANTHROPIC_MODEL = "anthropic/claude-opus-5"
claude

Documentación oficial y enlaces

VariableMeaning
ANTHROPIC_API_KEYYour sk-nr-… key
ANTHROPIC_BASE_URLhttps://nordrouter.comno trailing /v1
ANTHROPIC_MODELMain model. You can also set anthropic/claude-sonnet-5 or anthropic/claude-fable-5
ANTHROPIC_DEFAULT_*_MODELSo the /model opus|sonnet|haiku command picks the correct IDs from our catalog
ANTHROPIC_SMALL_FAST_MODELFast background model for Claude Code's utility tasks
ErrorCauseFix
Missing Bearer API keyThe key wasn't picked up: empty ANTHROPIC_API_KEY or an "apiKeyHelper": "echo ''" line in the configSet the key; delete the apiKeyHelper line
Auth conflict: Both a token … and an API key are set + endless retriesA stale ANTHROPIC_AUTH_TOKEN (from a previous login) overrides your key — the server receives the wrong credential and returns 401Unset it: $env:ANTHROPIC_AUTH_TOKEN = $null (Windows) / unset ANTHROPIC_AUTH_TOKEN (macOS/Linux); make sure it's not in settings.json
Invalid URL (POST /v1/v1/messages)/v1 appended to ANTHROPIC_BASE_URLRemove /v1: it must be exactly https://nordrouter.com
No pricing available for model claude-opus-5Claude Code requests a model by its "bare" IDSet ANTHROPIC_MODEL and ANTHROPIC_DEFAULT_*_MODEL as in the config above
Invalid or malformed JSON in settings.jsonBroken JSON: missing braces/commas or "smart" quotes pasted from a chatReplace the file contents entirely with the config above
Invalid API keyTypo in the key, or the key was deletedCheck the key in the dashboard

Guías relacionadas

Comprueba primero la conexión con una solicitud de texto mínima. Después añade streaming, herramientas, imágenes u otras funciones avanzadas. Nunca incluyas la clave API en código público ni en un frontend del navegador.

Solución de problemas