Claude API

Call Claude with the official Messages API

Anthropic's official SDKs, Claude Code and other clients only need one new base URL. Request fields, streaming events and error shapes match the official API, and one API key calls both Claude and GPT models.

Call the Messages APIbash
curl https://api.unioapi.com/v1/messages \
  -H "x-api-key: $UNIO_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 1024,
    "messages": [{ "role": "user", "content": "Hello, Claude" }]
  }'

The base URL is https://api.unioapi.com; paths and headers match the official API.

1M
Context window on the latest Claude models
128K
Maximum output tokens per request
Messages
Anthropic's official API, executed as sent
Fast
Optional faster tier on Opus 5.5

Why call Claude through UnioAPI

Official API, no code changes

Requests go to POST /v1/messages with the anthropic-version header, and anthropic-beta headers take effect as sent. The official Python and TypeScript SDKs only need base_url set to https://api.unioapi.com.

The full 1M context

Claude Opus 5.5, Sonnet 5.5, Haiku 5.5 and Fable 5.1 all have 1M context and 128K output. Apart from Haiku 5.5, long inputs have no separate long-context price.

Prompt caching

Add cache_control to a content block to cache a stable prefix, with 5-minute or 1-hour lifetimes. Cache reads are billed at a fraction of the base input price, which adds up quickly in long chats and coding agents.

Adaptive thinking and effort

Steer thinking depth with output_config.effort, applied as sent. Thinking tokens count as output and are reported faithfully in usage.

Fast on Opus 5.5

Add speed: "fast" to a request for faster processing, billed at Fast prices; usage.speed in the response shows the tier the request actually ran on.

Every call is traceable

Console request logs list the model, tokens, latency and charge of each call, filterable by API key and endpoint, so usage and billing line up.

Four steps to the Claude API

  1. Step 1

    Create an API key

    Redeem credit in the console and create an API key; each key can have its own spend cap and expiry.

    Read the docs
  2. Step 2

    Change the base URL

    Set the official SDK's base_url to https://api.unioapi.com (no /v1) and use the model IDs shown on the model pages.

    Read the docs
  3. Step 3

    Send a Messages request

    Fields, streaming events and error shapes match the official API; every parameter is covered in the Messages reference.

    Read the docs
  4. Step 4

    Turn on prompt caching

    Add cache_control to stable prefixes such as system prompts and tool definitions to pay less for repeated input.

    Read the docs

Billed by actual token usage

Each call is settled from the usage in its response: input, output, cache reads and each cache-write lifetime are priced separately, and Fast has its own set of prices. The model pages list current prices for every model.

Claude API FAQ

Two things: set base_url to https://api.unioapi.com and use your UnioAPI key. Request bodies, streaming and error handling stay the same.

Further reading

Related topics

Start calling Claude with one key

Create an API key, point the base URL at https://api.unioapi.com and send your first request in minutes.