Anthropic SDK
Use the Anthropic SDK against this gateway — the whole Claude line plus cross-vendor models (Python / TypeScript / curl)
When to use this: a project already on the Anthropic SDK can switch base URL and keep its code unchanged. You can also use the Anthropic SDK to call non-Claude models (GPT, Gemini, GLM, Grok, DeepSeek and others).
Before you start#
- Create an API key in the jiuye.zsopc.com console (
sk-gpushare-prefix; you can re-reveal it on its detail page at any time) - Sign-up includes $0.30 of trial credit, enough for every example on this page. After that, top up at dflop.top/dashboard/billing (Stripe, $1 minimum, same account and shared balance as jiuye.zsopc.com)
- All keys share one account balance — when it runs out every key returns 402 at once, and creating a new key doesn't help. See Authentication and the Quickstart
Endpoint#
| Value | |
|---|---|
| Base URL | https://jiuye.zsopc.com (⚠️ without /v1 — the SDK appends /v1/messages itself) |
| Endpoint | /v1/messages (compatible with the Anthropic Messages API) |
| Auth | x-api-key: sk-gpushare-xxx (set automatically by the SDK; with raw curl, Authorization: Bearer sk-gpushare-xxx also works) |
| Protocol | Anthropic Messages (HTTP / SSE streaming) |
Install#
pip install anthropic # Python
npm install @anthropic-ai/sdk # TypeScript
Python#
Basic call#
from anthropic import Anthropic
client = Anthropic(
base_url="https://jiuye.zsopc.com",
api_key="sk-gpushare-xxx",
)
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[
{"role": "user", "content": "Hello, Claude"},
],
)
print(message.content[0].text)
Streaming#
with client.messages.stream(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Stream a haiku"}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
Calling other vendors (the interesting part)#
The Anthropic SDK can call any model that supports the Anthropic Messages protocol — not just Claude:
# GPT via the Anthropic SDK
message = client.messages.create(
model="gpt-5.5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
# Gemini
message = client.messages.create(
model="gemini-3-flash",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
# GLM
message = client.messages.create(
model="glm-5.1",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
# Grok
message = client.messages.create(
model="grok-4-fast-reasoning",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
# DeepSeek
message = client.messages.create(
model="deepseek-v3.2",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
Tool use#
Identical to Anthropic's own API:
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
tools=[{
"name": "get_weather",
"description": "Get the current weather",
"input_schema": {
"type": "object",
"properties": {
"city": {"type": "string"},
},
"required": ["city"],
},
}],
messages=[{"role": "user", "content": "Weather in Tokyo?"}],
)
for block in message.content:
if block.type == "tool_use":
print(block.name, block.input)
System prompt#
message = client.messages.create(
model="claude-opus-4-8",
max_tokens=1024,
system="You are a terse expert. Answer in one sentence.",
messages=[{"role": "user", "content": "Why is the sky blue?"}],
)
print(message.content[0].text)
TypeScript#
Basic call#
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: process.env.PLATFORM_API_KEY,
baseURL: "https://jiuye.zsopc.com",
});
const message = await client.messages.create({
model: "claude-sonnet-4-6",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello" }],
});
console.log(message.content[0].type === "text" ? message.content[0].text : "");
Streaming#
const stream = client.messages.stream({
model: "claude-sonnet-4-6",
max_tokens: 1024,
messages: [{ role: "user", content: "Stream a haiku" }],
});
stream.on("text", (text) => process.stdout.write(text));
await stream.finalMessage();
Calling other vendors#
// GPT via the Anthropic SDK
await client.messages.create({
model: "gpt-5.5",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello" }],
});
// GLM
await client.messages.create({
model: "glm-4.7",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello" }],
});
curl#
Non-streaming#
curl https://jiuye.zsopc.com/v1/messages \
-H "x-api-key: $PLATFORM_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello, Claude"}
]
}'
Streaming#
curl https://jiuye.zsopc.com/v1/messages \
-H "x-api-key: $PLATFORM_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"stream": true,
"messages": [
{"role": "user", "content": "Stream a haiku"}
]
}' \
--no-buffer
Things to know#
max_tokensis required — the Anthropic Messages protocol demands it (unlike OpenAI)- The
anthropic-versionheader is set by the SDK; add2023-06-01yourself when using raw curl - Errors always come back Anthropic-style:
{"type": "error", "error": {"type": "...", "message": "..."}}— the body has onlytypeandmessage, nocodefield. Full truth table: Error codes - Out of balance returns HTTP 402 with
{"type": "error", "error": {"type": "billing_error", "message": "..."}}. On a 402, prompt the user to top up and don't retry — the balance is account-level, and a new key won't change anything - Model allowlist: if the key was created with
allowed_models, calling a model outside it returns HTTP 400 (type: "invalid_request_error") - Timeouts and long outputs: the upstream request has a total ceiling of about 180 seconds (streaming is bound by the same limit — you just get the first token sooner). For long outputs with a large
max_tokens, usemessages.stream/stream: true; a timeout surfaces as HTTP 504 (type: "api_error"). Set your SDK timeout to ≥ 200 seconds - Model × protocol coverage: when a model exists but has no channel on this protocol you get HTTP 503 — switch to the OpenAI Chat endpoint or pick another model. Authoritative coverage: compatibility matrix
- Image / video / embeddings don't go through
/v1/messages— they have their own endpoints, see Image / video / music APIs
Models available on this endpoint#
Models supporting the Anthropic Messages endpoint (as of July 2026):
| Vendor | Models | Notes |
|---|---|---|
| Anthropic | claude-opus-4-8, claude-opus-4-7, claude-opus-4-6, claude-sonnet-4-6, claude-haiku-4-5-20251001 | X1, native protocol pass-through |
| Anthropic | claude-opus-4-5-thinking, claude-opus-4-6-thinking | best-effort channel: the upstream injects roughly 400 tokens of system prompt per turn, and stability is below a direct connection |
gemini-2.5-flash-lite, gemini-2.5-flash-thinking, gemini-3-flash, gemini-3.1-pro-low | verified working on this endpoint (same best-effort channel) | |
| OpenAI | gpt-5.4, gpt-5.5 | |
| Zhipu | glm-4.7, glm-5-turbo, glm-5.1 | the direct channel declares the Anthropic protocol |
The table lists the common combinations; the authoritative coverage is the compatibility matrix and
GET /v1/models(see the API reference). Unsupported "model × protocol" combinations return HTTP 503 — switch endpoint or model.