← All applications · Connect apps section on /docs
Claude Code
Also known as: Claude CLI · claude
Claude Code: configure the API key, model and provider in your terminal.
Published instructions · Checked version: 2.1.220 · Checked on:
The real application was run against a local mock API to check connection settings, authentication and streaming responses. Production, all features, plugins and operating systems have not been verified.
Chat, ping, invoke and content-generation examples may send real billable requests. Check the model, balance, rate and minimum before running them. GET /v1/models checks authentication and the catalogue only. Set up environment variables safely
Base URL to paste
OpenAI SDKs generally use a URL ending in /v1; Anthropic SDKs use the root URL. Avoid adding /v1 twice. Protocol compatibility does not guarantee every provider feature.
https://thapi.cloudPrerequisites
- The `claude` command (Claude Code) is installed
- API key sk-thapi-…
- If previously signed in to Anthropic, run `/logout` in Claude Code first
Recommended model: claude-fable-5
Quick way — command / config
npm install -g API CLI@latest
api-cli configure claude -m claude-fable-5
api-cli doctorWhere to place file / fill Settings
Create/edit the JSON file as shown in the settings.json tab. Back up before editing manually. Prefer `api-cli configure claude` (creates a timestamped backup).
Check the base URL and model without printing the API key: `node -e 'const fs=require("node:fs"),os=require("node:os"); const s=JSON.parse(fs.readFileSync(os.homedir()+"/.claude/settings.json","utf8")); console.log({baseURL:s.env?.ANTHROPIC_BASE_URL,model:s.env?.ANTHROPIC_MODEL})'`.PowerShell: `notepad $env:USERPROFILE\.claude\settings.json`. Use ANTHROPIC_AUTH_TOKEN (not ANTHROPIC_API_KEY).
Applies to one project only. Add it to .gitignore if it contains a key.
Verify connection
- `claude` opens; send “ping”.
- `echo $ANTHROPIC_BASE_URL` (Unix) phải là https://thapi.cloud
- Dashboard → Usage shows a new request.
Troubleshooting
| Symptom | Reason | How to handle |
|---|---|---|
| Keeps asking for an Anthropic login | An old OAuth session is still active. | Run `/logout` in Claude Code, set ANTHROPIC_AUTH_TOKEN again, and open a new terminal. |
| 404 | BASE_URL contains an extra /v1. | Phải là https://thapi.cloud (không /v1). |
| 401 | ANTHROPIC_API_KEY was used by mistake, or the key is incorrect. | Use ANTHROPIC_AUTH_TOKEN=sk-thapi-… |
Notes
- A separate key for the Claude Code machine is recommended.
- API CLI merges env more safely than manually editing the entire file.