API reference

Anthropic proxy

POST /v1/messages — speaks the Anthropic Messages protocol. Same request/response shape as api.anthropic.com, so the official Anthropic SDK works unchanged.

Basic example

from anthropic import Anthropic

client = Anthropic(
    base_url="https://api.mintoken.in",
    api_key="mt_live_xxxxx",                      # mintoken key
    default_headers={
        "X-Provider-Key": "sk-ant-xxxxx",         # your Anthropic key
    },
)

message = client.messages.create(
    model="claude-3-5-sonnet-latest",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Explain connection pooling."},
    ],
)

print(message.content[0].text)
Base URL vs. path
For Python and TypeScript Anthropic SDKs, set base_url to https://api.mintoken.in (no /v1) — the SDK appends /v1/messages itself. For cURL, hit the full path https://api.mintoken.in/v1/messages.

System prompts

The Anthropic API puts system prompts in a top-level system field (not as a message with role: system). Mintoken prepends its compression rules to whatever you send:

message = client.messages.create(
    model="claude-3-5-sonnet-latest",
    max_tokens=1024,
    system="You are a senior database engineer.",
    messages=[{"role": "user", "content": "Explain connection pooling."}],
)

You can also send systemas an array of content blocks (Anthropic's newer format) — mintoken prepends a text block, preserving the rest.

Supported features

  • Tool usetools, tool_choice, tool_use/tool_result content blocks all pass through.
  • Vision image content blocks with base64 or URL data.
  • Streaming — pass stream: true; SSE events (message_start, content_block_delta, etc.) are forwarded verbatim.
  • Extended thinking — available for reasoning-enabled models, passed through transparently.
  • Prompt caching cache_control fields are preserved.

Common models

  • claude-3-5-sonnet-latest — default pick; balanced cost and quality
  • claude-3-5-haiku-latest — fastest and cheapest
  • claude-opus-4 / claude-sonnet-4 — Claude 4 family, check your account access

Implementation notes

  • The anthropic-version header is optional — mintoken defaults to 2023-06-01upstream if you don't set it.
  • Upstream response bodies (including usage.input_tokens and usage.output_tokens) are passed to you unchanged.
  • If your request hits a 5xx from Anthropic, mintoken returns the same status code so your retries hit the expected branches.