Skip to main content

Overview

Type: Coding ToolPrimary Path: Anthropic-nativeSupport Confidence: Strong native path
Claude Code is Anthropic’s official CLI tool for AI-assisted coding. You can configure it to use AI Sonar as the API provider.

Installation

Anthropic now recommends the native installer. npm installation still exists for compatibility, but Anthropic has deprecated it.
If you specifically need the npm package, use:
Do not use sudo npm install -g for Claude Code.

Configuration

Environment Variables

Set the following environment variables:
Add these to your shell profile (~/.bashrc, ~/.zshrc, etc.) for persistence.
For AI Sonar, keep ANTHROPIC_BASE_URL at https://api.aisonar.dev without a /v1 suffix. This matches the Anthropic-style endpoint shape and the unified gateway pattern documented by Claude Code.

Configuration File

Alternatively, create or edit ~/.claude/settings.json:

Usage

After configuration, use Claude Code normally:
Verify the installation if needed:

Available Models

AI Sonar supports all Claude models:

Model Selection

Specify a model with the --model flag:
Or set a default in your configuration:

Extended Thinking

For complex reasoning tasks, use models with extended thinking:

Troubleshooting

Verify the base URL is exactly https://api.aisonar.dev (no /v1 suffix for Anthropic-style requests).
Ensure your AI Sonar API key starts with sk- and has sufficient balance.
Claude Code’s gateway mode also supports ANTHROPIC_AUTH_TOKEN. Keep using ANTHROPIC_API_KEY for the standard AI Sonar setup unless you intentionally switched your gateway auth behavior.
Check the model name is correct. Use claude-sonnet-4-6 format.