Quickstart

1. Get an account

We open your org and its first admin. Admins add teammates under Settings.

2. Get an API key

Console → API keys → Create key. The key is shown once. Or use the CLI:

npm install -g modelrail
modelrail login
modelrail keys create my-app

3. Send your first request

Anthropic protocol:

curl https://api.modelrail.cc/v1/messages \
  -H "x-api-key: $MODELRAIL_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{"model":"claude-opus-5-5","max_tokens":1024,"messages":[{"role":"user","content":"Hello"}]}'

OpenAI protocol (Chat Completions):

curl https://api.modelrail.cc/v1/chat/completions \
  -H "Authorization: Bearer $MODELRAIL_KEY" \
  -H "content-type: application/json" \
  -d '{"model":"claude-opus-5-5","messages":[{"role":"user","content":"Hello"}]}'

Billing

  • Priced in USD and settled offline under your contract. See Models for prices per million tokens.
  • Input, cached input and output are billed separately; cached input is typically 1/10 of the input price.
  • Total balance = quota + coupons. Coupons are used first, earliest expiry first, and lapse at expiry.
  • When the balance hits zero the gateway refuses new requests; you never go into debt. Activity is itemized and Credits shows monthly bills.

Integrations

OpenAI-format base URL ends with /v1; Anthropic-format does not:

OpenAI     https://api.modelrail.cc/v1
Anthropic  https://api.modelrail.cc

Claude Code

export ANTHROPIC_BASE_URL=https://api.modelrail.cc
export ANTHROPIC_AUTH_TOKEN=$MODELRAIL_KEY
claude

Codex / OpenAI SDK

export OPENAI_BASE_URL=https://api.modelrail.cc/v1
export OPENAI_API_KEY=$MODELRAIL_KEY

Python

import anthropic
client = anthropic.Anthropic(base_url="https://api.modelrail.cc", api_key=KEY)

from openai import OpenAI
client = OpenAI(base_url="https://api.modelrail.cc/v1", api_key=KEY)

CLI

modelrail models                   # models and prices
modelrail test claude-opus-5-5     # send a test request
modelrail balance                  # balance
modelrail usage --days 7           # usage by model
modelrail setup claude-code        # configure Claude Code

Errors

401Invalid, revoked or expired key; or account frozen
400 / 422 budget_exceededBalance exhausted or key spend limit reached
429Rate limited; retry later
5xxUpstream failure; contact us with the request_id

Detect exhausted balance via error.type = budget_exceeded, not the status code alone.