CLAUDE CODE API PROVIDER

Connect Claude Code to a prepaid Claude API provider.

WorldGate is an independent Claude Code API provider for developers who want to run supported Claude models against prepaid credit. Configure three environment variables, keep the WorldGate key in your shell, and send Claude Code traffic through the Anthropic-compatible Messages endpoint without an Anthropic consumer subscription.

Create an account
01

Install Claude Code and create a WorldGate key

Install the official Claude Code package, create a separate WorldGate API key for your coding environment, and add prepaid credit. A dedicated key makes Claude Code usage attributable and lets you revoke the coding credential without disrupting another application.

02

Set the WorldGate base URL without /v1

Export ANTHROPIC_BASE_URL as https://worldgateapi.com. Do not append /v1 because Claude Code adds the Messages API path itself. Export your WorldGate credential through ANTHROPIC_API_KEY and set ANTHROPIC_MODEL to a supported identifier such as claude-opus-5.

03

Prevent the unexpected login screen

Run unset ANTHROPIC_AUTH_TOKEN before starting Claude Code. A stale auth token can take precedence over the API-key flow. If Claude Code still asks you to log in, verify that ANTHROPIC_API_KEY is present in the same terminal session and restart the command from that shell.

04

Resolve output-token validation errors

WorldGate accepts positive output limits up to 16,384 tokens. If a client sends zero, a negative value, or a larger max_tokens value, reduce the configured output limit to the accepted range. This is an output ceiling, not the model context-window size.

05

Understand Claude Code API pricing

Claude Code does not use a flat WorldGate subscription. Each request uses prepaid credit at the selected model's published token rate. Claude Opus 5 is currently listed at $0.20 per million input tokens and $1 per million output tokens; check the pricing page before funding because rates can change.

06

Choose a Claude model by workload

Use claude-opus-5 for complex coding and agent work when its quality justifies the cost. Test Sonnet or Haiku for faster or more repetitive tasks. Compare task quality, latency, retries, and total token cost before moving a repository workflow to production.

07

Protect keys and control agent spend

Keep the WorldGate key out of source control, browser code, screenshots, and shared shell history. Use a project-specific key, set a RunGuard hard cap when you need a strict ceiling, enable balance alerts, and review request-level usage after long or autonomous agent sessions.

CLAUDE CODE SETUP

Configure Claude Code in one terminal.

The WorldGate base URL intentionally has no /v1. Export the variables in the same shell that launches Claude Code.

npm install -g @anthropic-ai/claude-code

unset ANTHROPIC_AUTH_TOKEN
export WORLDGATE_API_KEY="wg_live_your_key_here"
export ANTHROPIC_BASE_URL="https://worldgateapi.com"
export ANTHROPIC_API_KEY="$WORLDGATE_API_KEY"
export ANTHROPIC_MODEL="claude-opus-5"

claude --model claude-opus-5

METHODOLOGY & SOURCES

Verify the setup.

Setup details reviewed on July 31, 2026. The linked Anthropic documentation describes Claude Code and the Messages API; WorldGate-specific endpoint, model, billing, and limit details are documented by WorldGate.

COMMON QUESTIONS

What developers ask

Can Claude Code use WorldGate without an Anthropic login?

Yes. Set ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY in the same shell before starting Claude Code. WorldGate authenticates the request with a WorldGate key; it does not provide an Anthropic account or consumer subscription.

What base URL should Claude Code use?

Use https://worldgateapi.com with no trailing /v1. Claude Code appends the Anthropic Messages path itself.

Which Claude Code model should I select?

Use a model identifier that is currently listed by WorldGate, such as claude-opus-5. Compare current Opus, Sonnet, Haiku, and Fable rates on the pricing page before choosing.

Why does Claude Code ask me to log in?

The API key may be missing from the active shell or ANTHROPIC_AUTH_TOKEN may still be set. Unset the auth token, export ANTHROPIC_API_KEY again in the same terminal, and restart Claude Code.

Why do I get an output tokens error?

Set max_tokens to an integer between 1 and 16,384. The error concerns requested output length, not your prompt or the full context window.

How is Claude Code usage charged?

Requests deduct the published input, output, and applicable cached-token cost from WorldGate prepaid credit. There is no standard monthly WorldGate subscription for API usage.

Is WorldGate affiliated with Anthropic?

No. WorldGate is an independent API gateway and is not affiliated with or endorsed by Anthropic.

Lower model cost. Clearer usage.

Start with one WorldGate API key.

Start building