The most common setup question is not “Which model should I use?” It is usually one of these:
- How do I configure Claude Code in VS Code?
- Which Base URL should I enter in Cline?
- Which provider should I select in Cursor?
This guide gives you copy-paste templates for Claude Code CLI, the Claude Code VS Code extension, Cline, and Cursor using ClaudeAPI.com.
The key rule is simple:
Anthropic-compatible tools -> https://gw.claudeapi.com
OpenAI-compatible tools -> https://gw.claudeapi.com/v1
Anthropic-compatible tools -> https://gw.claudeapi.com
OpenAI-compatible tools -> https://gw.claudeapi.com/v1
Use the wrong one and you will usually get 401, 404, model errors, or connection timeouts.
Get your API key first
Log in to the ClaudeAPI dashboard and create or copy an API key.
You need:
- API key: the key shown in your ClaudeAPI account
- Anthropic-compatible Base URL:
https://gw.claudeapi.com - OpenAI-compatible Base URL:
https://gw.claudeapi.com/v1
Do not mix provider keys. A ClaudeAPI key, an Anthropic official key, and an OpenAI key are not interchangeable.
URL decision table
| Tool | Recommended mode | Base URL |
|---|---|---|
| Claude Code CLI | Anthropic-compatible | https://gw.claudeapi.com |
| Claude Code VS Code extension | Anthropic-compatible via Claude Code settings or CC Switch | https://gw.claudeapi.com |
| Cline | Anthropic provider for Claude-only workflows | https://gw.claudeapi.com |
| Cline | OpenAI Compatible for gateway-style multi-model workflows | https://gw.claudeapi.com/v1 |
| Cursor | OpenAI-compatible custom endpoint | https://gw.claudeapi.com/v1 |
If a field is named “Base URL” and the tool speaks Anthropic’s Messages API, do not add /v1. If the tool speaks OpenAI-compatible Chat Completions, include /v1.
Claude Code CLI
Claude Code can route requests through a gateway by using environment variables. The two important variables are:
ANTHROPIC_BASE_URL
ANTHROPIC_API_KEY
ANTHROPIC_BASE_URL
ANTHROPIC_API_KEY
macOS and Linux
Add these lines to ~/.zshrc, ~/.bashrc, or the shell profile you actually use:
export ANTHROPIC_BASE_URL="https://gw.claudeapi.com"
export ANTHROPIC_API_KEY="YOUR_CLAUDEAPI_KEY"
export ANTHROPIC_BASE_URL="https://gw.claudeapi.com"
export ANTHROPIC_API_KEY="YOUR_CLAUDEAPI_KEY"
Then reload the shell:
source ~/.zshrc
source ~/.zshrc
Use source ~/.bashrc if you edited .bashrc.
Test:
claude "Reply with one short sentence to confirm the configuration works."
claude "Reply with one short sentence to confirm the configuration works."
Check the active Base URL:
echo $ANTHROPIC_BASE_URL
echo $ANTHROPIC_BASE_URL
Windows CMD
For the current terminal session:
set ANTHROPIC_BASE_URL=https://gw.claudeapi.com
set ANTHROPIC_API_KEY=YOUR_CLAUDEAPI_KEY
set ANTHROPIC_BASE_URL=https://gw.claudeapi.com
set ANTHROPIC_API_KEY=YOUR_CLAUDEAPI_KEY
Check:
echo %ANTHROPIC_BASE_URL%
echo %ANTHROPIC_BASE_URL%
Windows PowerShell
For the current PowerShell session:
$env:ANTHROPIC_BASE_URL = "https://gw.claudeapi.com"
$env:ANTHROPIC_API_KEY = "YOUR_CLAUDEAPI_KEY"
$env:ANTHROPIC_BASE_URL = "https://gw.claudeapi.com"
$env:ANTHROPIC_API_KEY = "YOUR_CLAUDEAPI_KEY"
Check:
echo $env:ANTHROPIC_BASE_URL
echo $env:ANTHROPIC_BASE_URL
Windows permanent environment variables
For a persistent setup:
- Press
Win + R. - Run
sysdm.cpl. - Open Advanced → Environment Variables.
- Add user variables:
ANTHROPIC_BASE_URL=https://gw.claudeapi.comANTHROPIC_API_KEY= your ClaudeAPI key
- Restart every terminal and restart VS Code if you use the integrated terminal.
Claude Code also supports /status, which is useful for checking whether it is using an API key and whether a gateway Base URL is active.
Claude Code VS Code extension
If you use the Claude Code VS Code extension, you have two practical options.
Option A: configure Claude Code settings
Claude Code settings can define environment variables for Claude Code.
Global settings file:
| System | Path |
|---|---|
| macOS / Linux | ~/.claude/settings.json |
| Windows | C:\Users\<your-username>\.claude\settings.json |
Example:
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"env": {
"ANTHROPIC_BASE_URL": "https://gw.claudeapi.com",
"ANTHROPIC_API_KEY": "YOUR_CLAUDEAPI_KEY"
}
}
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"env": {
"ANTHROPIC_BASE_URL": "https://gw.claudeapi.com",
"ANTHROPIC_API_KEY": "YOUR_CLAUDEAPI_KEY"
}
}
Save the file and fully restart VS Code.
The $schema line is optional, but useful. It gives VS Code JSON validation and completion for Claude Code settings.
Option B: use CC Switch
If your team uses CC Switch, the cleaner approach is often to let CC Switch manage provider switching for Claude Code CLI and the Claude Code VS Code extension.
Look for this option:
CC Switch -> Settings -> General -> Apply to Claude Code plugin
CC Switch -> Settings -> General -> Apply to Claude Code plugin

After enabling it:
- Select the ClaudeAPI.com provider in CC Switch.
- Fully restart VS Code.
- Open the Claude Code extension.
- Send a short test message.
This option affects the Claude Code extension. It does not configure Continue, Cline, or Cursor.
Cline
Cline supports more than one provider mode. For ClaudeAPI, choose the mode based on what you need.
Option A: Anthropic provider mode
Use this when you want Claude-focused workflows and the most direct Anthropic-compatible behavior.
| Field | Value |
|---|---|
| API Provider | Anthropic |
| Custom Base URL | https://gw.claudeapi.com |
| API key | Your ClaudeAPI key |
| Model | claude-sonnet-4-6 or another enabled model |
General steps:
- Open Cline in VS Code.
- Click the settings gear.
- Select Anthropic as the provider.
- Enable custom Base URL if the UI requires a checkbox.
- Enter
https://gw.claudeapi.com. - Paste your ClaudeAPI key.
- Select or enter the model ID.
- Save and send a short test message.
Do not use https://gw.claudeapi.com/v1 in Anthropic provider mode.
Option B: OpenAI Compatible mode
Use this when you want Cline to talk to ClaudeAPI through the OpenAI-compatible Chat Completions surface, or when you need one gateway style alongside other OpenAI-compatible models.
| Field | Value |
|---|---|
| API Provider | OpenAI Compatible |
| Base URL | https://gw.claudeapi.com/v1 |
| API key | Your ClaudeAPI key |
| Model ID | claude-sonnet-4-6 or another enabled model |
This mode must include /v1.
Direct VS Code settings example
If your Cline version supports these settings keys, the Anthropic-style configuration may look like:
{
"cline.apiProvider": "anthropic",
"cline.apiKey": "YOUR_CLAUDEAPI_KEY",
"cline.anthropicBaseUrl": "https://gw.claudeapi.com",
"cline.apiModelId": "claude-sonnet-4-6"
}
{
"cline.apiProvider": "anthropic",
"cline.apiKey": "YOUR_CLAUDEAPI_KEY",
"cline.anthropicBaseUrl": "https://gw.claudeapi.com",
"cline.apiModelId": "claude-sonnet-4-6"
}
OpenAI-compatible mode may look like:
{
"cline.apiProvider": "openai-compatible",
"cline.openAiCompatible.baseUrl": "https://gw.claudeapi.com/v1",
"cline.openAiCompatible.apiKey": "YOUR_CLAUDEAPI_KEY",
"cline.openAiCompatible.modelId": "claude-sonnet-4-6"
}
{
"cline.apiProvider": "openai-compatible",
"cline.openAiCompatible.baseUrl": "https://gw.claudeapi.com/v1",
"cline.openAiCompatible.apiKey": "YOUR_CLAUDEAPI_KEY",
"cline.openAiCompatible.modelId": "claude-sonnet-4-6"
}
Configuration keys can change between extension versions. If the UI and settings.json disagree, prefer the current Cline UI.
Cursor
Cursor uses an OpenAI-compatible custom endpoint flow for this setup.
| Field | Value |
|---|---|
| OpenAI API Key | Your ClaudeAPI key |
| Override OpenAI Base URL | https://gw.claudeapi.com/v1 |
| Custom model | Exact ClaudeAPI model ID |
Steps:
- Open Cursor Settings.
- Go to Models.
- Add or enable the OpenAI API key field.
- Paste your ClaudeAPI key.
- Enable Override OpenAI Base URL.
- Enter
https://gw.claudeapi.com/v1. - Add a custom model ID.
- Select the model in Cursor Chat and test.
Example model IDs:
claude-sonnet-4-6
claude-haiku-4-5-20251001
claude-opus-4-8
claude-sonnet-4-6
claude-haiku-4-5-20251001
claude-opus-4-8
Check the ClaudeAPI console for the exact model IDs enabled on your account. Do not use UI display names or shortened names such as sonnet or haiku.
Important Cursor note: custom OpenAI Base URL behavior can affect other OpenAI-key workflows because it is an override. If other Cursor models fail after enabling a custom endpoint, turn off the override or isolate this setup in a separate Cursor profile/workspace.
Model selection
For IDE work, start with a balanced model and only upgrade when the task justifies it.
| Model | Good fit | Notes |
|---|---|---|
claude-haiku-4-5-20251001 |
Simple questions, comments, quick response tasks | Best for speed and low cost |
claude-sonnet-4-6 |
Daily coding, code review, documentation, refactors | Recommended default |
claude-opus-4-8 |
Complex architecture work, difficult refactors, long-context analysis | Use for high-value tasks |
Model availability and pricing can change. Check the ClaudeAPI dashboard before setting team-wide defaults.
Quick verification scripts
Use these tests when you are not sure whether the problem is the tool UI or the API connection.
Anthropic-compatible test
Use this for Claude Code and Cline Anthropic mode:
curl -X POST https://gw.claudeapi.com/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_CLAUDEAPI_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 50,
"messages": [{"role": "user", "content": "Reply with: configuration successful"}]
}'
curl -X POST https://gw.claudeapi.com/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_CLAUDEAPI_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 50,
"messages": [{"role": "user", "content": "Reply with: configuration successful"}]
}'
A successful response contains a content field.
Python test
import anthropic
client = anthropic.Anthropic(
api_key="YOUR_CLAUDEAPI_KEY",
base_url="https://gw.claudeapi.com"
)
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=100,
messages=[
{"role": "user", "content": "Reply with: configuration successful"}
]
)
print(message.content[0].text)
print(f"Input tokens: {message.usage.input_tokens}")
print(f"Output tokens: {message.usage.output_tokens}")
import anthropic
client = anthropic.Anthropic(
api_key="YOUR_CLAUDEAPI_KEY",
base_url="https://gw.claudeapi.com"
)
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=100,
messages=[
{"role": "user", "content": "Reply with: configuration successful"}
]
)
print(message.content[0].text)
print(f"Input tokens: {message.usage.input_tokens}")
print(f"Output tokens: {message.usage.output_tokens}")
OpenAI-compatible test
Use this for Cursor and Cline OpenAI Compatible mode:
curl -X POST https://gw.claudeapi.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_CLAUDEAPI_KEY" \
-d '{
"model": "claude-sonnet-4-6",
"messages": [{"role": "user", "content": "Reply with: configuration successful"}],
"max_tokens": 50
}'
curl -X POST https://gw.claudeapi.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_CLAUDEAPI_KEY" \
-d '{
"model": "claude-sonnet-4-6",
"messages": [{"role": "user", "content": "Reply with: configuration successful"}],
"max_tokens": 50
}'
A successful response contains a choices array.
Troubleshooting
401 Unauthorized
Common causes:
- API key copied incorrectly
- extra spaces before or after the key
- key from the wrong provider
- key disabled or out of quota
Fix:
- Copy the key again from ClaudeAPI.
- Confirm the same key works in the curl test.
- Restart the tool after changing environment variables.
404 Not Found
This is usually a Base URL mismatch.
Use:
Claude Code / Cline Anthropic mode:
https://gw.claudeapi.com
Cursor / Cline OpenAI Compatible mode:
https://gw.claudeapi.com/v1
Claude Code / Cline Anthropic mode:
https://gw.claudeapi.com
Cursor / Cline OpenAI Compatible mode:
https://gw.claudeapi.com/v1
Do not use:
ANTHROPIC_BASE_URL=https://gw.claudeapi.com/v1
ANTHROPIC_BASE_URL=https://gw.claudeapi.com/v1
That is wrong for Claude Code.
Cline agent features do not work as expected
If you are using Cline for file edits, terminal commands, and agent workflows, start with Anthropic provider mode. OpenAI-compatible mode can be useful for gateway routing, but provider-specific tool behavior may differ.
Claude Code extension still asks for login
The extension may not be seeing the environment variables.
Check:
~/.claude/settings.jsonor Windows equivalent exists- JSON syntax is valid
ANTHROPIC_BASE_URLishttps://gw.claudeapi.com- VS Code was fully restarted
- no conflicting login/session configuration is taking priority
Windows environment variables do not apply
Close all PowerShell/CMD windows and reopen them. If you use VS Code’s integrated terminal, fully restart VS Code.
CC Switch changed, but the VS Code plugin did not
Check:
- CC Switch selected provider is ClaudeAPI.com.
- “Apply to Claude Code plugin” is enabled.
- VS Code was fully restarted.
Configuration quick card
ClaudeAPI.com quick configuration
Claude Code CLI
ANTHROPIC_BASE_URL = https://gw.claudeapi.com
ANTHROPIC_API_KEY = YOUR_CLAUDEAPI_KEY
Claude Code VS Code extension
~/.claude/settings.json
or CC Switch -> Apply to Claude Code plugin
Base URL: https://gw.claudeapi.com
Cline Anthropic mode
Provider: Anthropic
Base URL: https://gw.claudeapi.com
Cline OpenAI Compatible mode
Provider: OpenAI Compatible
Base URL: https://gw.claudeapi.com/v1
Cursor
OpenAI API Key: YOUR_CLAUDEAPI_KEY
Override OpenAI Base URL: https://gw.claudeapi.com/v1
ClaudeAPI.com quick configuration
Claude Code CLI
ANTHROPIC_BASE_URL = https://gw.claudeapi.com
ANTHROPIC_API_KEY = YOUR_CLAUDEAPI_KEY
Claude Code VS Code extension
~/.claude/settings.json
or CC Switch -> Apply to Claude Code plugin
Base URL: https://gw.claudeapi.com
Cline Anthropic mode
Provider: Anthropic
Base URL: https://gw.claudeapi.com
Cline OpenAI Compatible mode
Provider: OpenAI Compatible
Base URL: https://gw.claudeapi.com/v1
Cursor
OpenAI API Key: YOUR_CLAUDEAPI_KEY
Override OpenAI Base URL: https://gw.claudeapi.com/v1
Related guides
- Claude API Base URL configuration guide
- Claude Code cc-switch tutorial
- Continue VS Code Claude API setup guide
- Claude API pricing and model selection guide
Sources
- Anthropic Claude Code Docs: Environment variables
- Anthropic Claude Code Docs: Connect Claude Code to an LLM gateway
- Cline Docs: Anthropic provider
- Cline Docs: OpenAI Compatible provider
- LLM Gateway Docs: Cursor integration
Disclosure
This article was translated and adapted from a Chinese ClaudeAPI draft with AI assistance, then reviewed against public documentation available on July 15, 2026. ClaudeAPI is an independent third-party API service and is not Anthropic, Cline, or Cursor.



