1. 7API
  2. Docs
  3. Anthropic-compatible API

Anthropic-compatible API

7API implements the Anthropic Messages API. The Anthropic SDKs, Claude Code and other Anthropic-format clients work unchanged once you set the base URL and key. Non-Claude models (GLM, DeepSeek, Kimi, GPT, Grok, Gemini) are reachable on this format too.

text
Base URL:  https://7api.st          (no /v1 — the SDK adds /v1/messages)
Header:    x-api-key: sk-your-key   (Authorization: Bearer also works)

Messages

POST /v1/messages

bash
curl https://7api.st/v1/messages \
  -H "x-api-key: $SEVENAPI_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": "Explain a mutex in one paragraph."}]
  }'
python
from anthropic import Anthropic
client = Anthropic(base_url="https://7api.st", api_key="sk-your-key")
msg = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=2048,
    system="You are a senior reviewer.",
    messages=[{"role": "user", "content": "Review: def add(a,b): return a-b"}],
)
print(msg.content[0].text, msg.usage)

Supported features

FeatureNotes
system, messages, max_tokensmax_tokens defaults to 16,384 if omitted. The maximum is 131,072.
stream: trueStandard Anthropic SSE events. See Streaming.
tools, tool_choiceTool use on every model
thinkingAdaptive thinking on Claude models. {"type":"enabled","budget_tokens":N} is accepted on claude-opus-4-6 only.
output_config.effortClaude Code's effort control. See Reasoning effort.
cache_controlPassed through. See Prompt caching.
Imagesimage content blocks on vision models
anthropic-betaForwarded. context-1m-2025-08-07 is added automatically for [1m] model names.

POST /v1/messages/streaming is an alias that always streams.

Usage fields

json
"usage": {
  "input_tokens": 12,
  "cache_creation_input_tokens": 0,
  "cache_read_input_tokens": 48211,
  "output_tokens": 377
}

As at Anthropic, input_tokens excludes cached tokens. Billing is described in Prompt caching.

Count tokens

POST /v1/messages/count_tokens takes the same body as /v1/messages and returns {"input_tokens": N}. The count is a fast local estimate, and it's free. It still needs a positive balance, like other generation endpoints. Claude Code calls this endpoint before compacting a conversation.

Using non-Claude models

Send any catalog ID as model:

bash
curl https://7api.st/v1/messages \
  -H "x-api-key: $SEVENAPI_API_KEY" -H "Content-Type: application/json" \
  -d '{"model": "glm-5.3", "max_tokens": 512, "messages": [{"role": "user", "content": "hi"}]}'

Clients that only accept model names beginning with claude- can add that prefix to any model, for example claude-glm-5.3 or claude-gpt-6.1-sol. See Model IDs.

Errors

Generation errors on this endpoint use Anthropic's shape:

json
{ "type": "error", "error": { "type": "overloaded_error", "message": "…" } }

See Errors for every status code.