Configure Claude Code custom API settings
Set ANTHROPIC_BASE_URL to https://clodex.xyz and ANTHROPIC_API_KEY to a dedicated CLODEX key. Do not append /v1: Claude Code adds the Messages API path. Store variables in a protected secret manager or local environment file excluded from Git.
Use a separate key for each machine or team environment when possible. Narrow keys make revocation safer and allow usage logs to identify which installation produced a request.
export ANTHROPIC_BASE_URL="https://clodex.xyz"
export ANTHROPIC_API_KEY="clodex_YOUR_KEY"
claude
CLAUDE.md and API gateway instructions are different layers
The API endpoint controls transport, authentication and model access. CLAUDE.md contains project-level instructions that Claude Code discovers from the opened workspace. A gateway cannot see a local file unless the client includes its content in the request context.
Keep reusable engineering rules in CLAUDE.md and secrets outside it. Run the memory command in Claude Code to confirm which instruction files are loaded. If every user needs the same server-side instruction, that is a separate gateway policy and should be documented explicitly.
Claude Code API errors and slow responses
Do not launch several blind retries for a long agent task. Exponential backoff and a clear retry budget reduce duplicated work. For code-changing tasks, inspect the repository state before replaying a request because a partial turn may already have modified files.
- 401 or authentication errors: verify the key and base URL without printing the secret.
- 429 errors: reduce parallel agents and inspect key or channel concurrency.
- 5xx errors: preserve the request ID and classify whether the gateway or upstream failed.
- Stream ended before message_stop: treat the turn as incomplete and retry only when safe.
- Wrong model: compare the selected slug with the authenticated model catalog and usage log.
Operational checklist for teams
Document the approved model, base URL, key owner and escalation path. Keep development and production credentials separate. Monitor request latency, errors and spend by key so one busy agent cannot consume the entire shared budget without an alert.
Before an organization rollout, test repository search, file edits, tool calls, long-context turns and cancellation. Claude Code is an interactive agent, so a basic text completion test does not cover its full protocol behavior.
Frequently asked questions
What value should ANTHROPIC_BASE_URL use?
Set it to https://clodex.xyz without /v1.
Does the endpoint automatically provide CLAUDE.md?
No. Claude Code reads CLAUDE.md from the local workspace; server-side instructions are a separate gateway feature.
Why did a streamed task stop before completion?
The upstream or transport closed before message_stop. Preserve the request ID and treat the response as incomplete.