https://cloud-api.near.ai/v1/messages for its Anthropic models. Point Claude Code at NEAR AI Cloud and it runs on your NEAR AI Cloud API key and credits instead of an Anthropic account.
The Messages endpoint serves Anthropic models only, such as
anthropic/claude-sonnet-5-5. Claude models on NEAR AI Cloud are in the Incognito privacy tier; see Available Models. To use open models such as GLM or Qwen in a coding agent, use Codex CLI, OpenCode, or another OpenAI-compatible tool.Prerequisites
- Claude Code installed (checked with
2.1.325). - A NEAR AI Cloud account with credits. Usage is billed per token from your NEAR AI Cloud credits; a Claude subscription is not used.
- A NEAR AI Cloud API key. In the NEAR AI Cloud Dashboard, open API Keys and create a key.
Configure
Claude Code needs two settings:
Use the base URL without
/v1. Claude Code appends /v1/messages itself, so https://cloud-api.near.ai/v1 would produce /v1/v1/messages.
Try it in one terminal
Make it permanent
Add the same values to theenv block of your user settings file, ~/.claude/settings.json:
~/.claude/settings.json
env entries to it rather than replacing it.
Run /status inside Claude Code to confirm. It shows the Anthropic base URL and that an auth token is in use.
If you already sign in with a Claude account
You do not need to sign out. WhenANTHROPIC_AUTH_TOKEN is set, Claude Code sends that key instead of your Claude login, and the login stays saved on your machine. Claude Code may show a startup warning that both are present; that is expected.
To switch back to your Claude subscription, unset the two variables or remove them from settings.json, then restart Claude Code.
Setting only
ANTHROPIC_BASE_URL is not enough. Without ANTHROPIC_AUTH_TOKEN, Claude Code keeps using your Claude login, which NEAR AI Cloud rejects with 401.ANTHROPIC_API_KEY also works with NEAR AI Cloud. In interactive mode, Claude Code asks once whether to use a key set that way. ANTHROPIC_AUTH_TOKEN avoids the prompt.
Choose a model
Claude Code’s default model IDs, such asclaude-opus-5-5, work as they are. NEAR AI Cloud resolves a Claude model ID without a prefix to the matching anthropic/ model.
To pick a different model, use /model inside Claude Code, or set ANTHROPIC_MODEL:
Quick test
If Claude Code fails, test the key and model directly against the Messages endpoint first:Troubleshooting
Related guides
Sources Checked
Sources checked on 2026-11-16, against Claude Code2.1.325. A Claude Code session that writes a file and runs a shell command was run against NEAR AI Cloud with the default model, and a short prompt with ANTHROPIC_MODEL=claude-sonnet-5-5.
- Connect Claude Code to an LLM gateway:
ANTHROPIC_BASE_URL,ANTHROPIC_AUTH_TOKEN, settingsenvblock - Authentication: credential precedence,
/status - Environment variables:
ANTHROPIC_MODEL,CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS - NEAR AI Cloud
GET /v1/modelsandPOST /v1/messages