321AI Model MarketplaceLive marketplace →

Quick answer: 321AI speaks the Anthropic Messages protocol at https://321ai.cc (the SDK appends /v1/messages itself — do not add /v1 to this base URL). Authenticate with your 321AI key the same way the Anthropic SDK does (x-api-key). Claude Code works by setting ANTHROPIC_BASE_URL=https://321ai.cc and ANTHROPIC_AUTH_TOKEN=<your key>.

Anthropic Messages API via 321AI

Audience: developers using the Anthropic SDK, Claude Code, or any client that speaks the Messages protocol.

Two protocols, two base URLs

SettingValueNote
Anthropic protocol (Messages)https://321ai.ccSDK appends /v1/messages — no /v1 in base
OpenAI protocol (chat/completions)https://321ai.cc/v1include /v1
Auth (Anthropic)x-api-key: your 321AI keyor Authorization: Bearer for Claude Code env vars

curl example (Messages protocol)

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

Python SDK example

from anthropic import Anthropic

client = Anthropic(api_key="YOUR_KEY", base_url="https://321ai.cc")
msg = client.messages.create(
    model="claude-sonnet-5", max_tokens=256,
    messages=[{"role": "user", "content": "Hello"}],
)
print(msg.content)

Steps

  1. Create an API key. Sign up at 321AI and copy a key from the console.
  2. Point the SDK at 321AI. anthropic-python: OpenAI-style base URL override — use base_url="https://321ai.cc". Node SDK: new Anthropic({ baseURL: "https://321ai.cc" }).
  3. Call /v1/messages. POST https://321ai.cc/v1/messages with x-api-key and anthropic-version headers, body {"model":"claude-sonnet-5","max_tokens":256,"messages":[...]}.
  4. Use Claude Code (optional). Set ANTHROPIC_BASE_URL=https://321ai.cc and ANTHROPIC_AUTH_TOKEN=<your key>; optionally pin ANTHROPIC_MODEL and a cheap ANTHROPIC_SMALL_FAST_MODEL.

Troubleshooting

SDK error: invalid base URL

For the Anthropic protocol the base is https://321ai.cc WITHOUT /v1 — the SDK appends /v1/messages itself. For the OpenAI protocol (chat/completions) the base is https://321ai.cc/v1 WITH /v1.

Which Claude models are available

See the live catalog at /pricing/claude — prices are the market minimum across vendors, updated daily.

Is the request/response format identical to Anthropic?

Yes — the Messages protocol (system, messages, tools, streaming SSE) is passed through; report any protocol gap via the in-console ticket.

Related: Claude Code 中文教程 · Claude price table · relay glossary

All model pricesFeatured · 321AI communityFeatured · Open-source toolsFeatured · Advertise with usFeatured