Base URL: https://www.myai168.com/en/api/anthropic/v1 (each endpoint URL = base URL + endpoint path; for the authentication, streaming, billing headers and error codes shared by all relays, see API Quick Start).
This follows the official Anthropic Messages API spec: requests and responses use the official format — just replace the URL with the base URL above and the key with your developer key from this site. Send the key in the x-api-key header (Authorization: Bearer is also accepted) together with the anthropic-version: 2023-06-01 header. With the official SDKs, set base_url to https://www.myai168.com/en/api/anthropic (without /v1); see "Using the official SDKs (Python / Node.js)" on this page.
| Endpoint (appended to the base URL) | Purpose |
|---|---|
POST /messages | Conversation (Messages API): text, image and PDF input, thinking, tool use, web search, prompt caching and streaming. |
POST /messages/count_tokens | Count the input tokens of a request (free). |
GET /models, GET /models/{model_id} | List the models this relay accepts (free). |
POST https://www.myai168.com/en/api/anthropic/v1/messagesClaude Messages API (Claude Fable / Opus / Sonnet / Haiku), supports streaming, prompt caching and thinking. The only supported server-side tool is web search (Code Execution and the Files API are not supported — see the support matrix below). model, max_tokens and messages are required.
curl https://www.myai168.com/en/api/anthropic/v1/messages \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model":"claude-opus-5-5","max_tokens":1024,"messages":[{"role":"user","content":"Hello"}]}'
Response (excerpt): the reply text is in the content blocks whose type is text. Newer models think first by default, so the first block is often a thinking block — never assume content[0] is the text.
{
"id": "msg_...",
"type": "message",
"role": "assistant",
"model": "claude-opus-5-5",
"content": [
{"type": "thinking", "thinking": "", "signature": "..."},
{"type": "text", "text": "Hello! How can I help you today?"}
],
"stop_reason": "end_turn",
"usage": {"input_tokens": 8, "output_tokens": 42}
}
Python (extracting the text, checking the stop reason and reading the points charged):
import requests
r = requests.post(
"https://www.myai168.com/en/api/anthropic/v1/messages",
headers={
"x-api-key": "YOUR_API_KEY",
"anthropic-version": "2023-06-01",
},
json={"model": "claude-opus-5-5", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello"}]},
timeout=600,
)
r.raise_for_status()
data = r.json()
# content may hold thinking / tool_use blocks too -- keep only the text blocks
print("".join(b["text"] for b in data["content"] if b["type"] == "text"))
print("stop_reason:", data["stop_reason"])
print("cost:", r.headers.get("X-Cost-Points"), "remaining:", r.headers.get("X-Credits-Remaining"))
POST https://www.myai168.com/en/api/anthropic/v1/messages/count_tokensCounts the input tokens of a request without calling the model and without charging; the body is the same as /messages minus max_tokens, and the response is {"input_tokens": N}. Handy for estimating how much input a long document will use before sending it.
curl https://www.myai168.com/en/api/anthropic/v1/messages/count_tokens \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model":"claude-opus-5-5","messages":[{"role":"user","content":"Hello"}]}'
GET https://www.myai168.com/en/api/anthropic/v1/models / GET https://www.myai168.com/en/api/anthropic/v1/models/{model_id}List the models this relay accepts / retrieve one model (query endpoints, free). Each id is exactly what to put in the model field and must match exactly — dated variants are not accepted (write claude-haiku-4-5, not claude-haiku-4-5-20251001).
curl https://www.myai168.com/en/api/anthropic/v1/models \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01"
curl https://www.myai168.com/en/api/anthropic/v1/models/claude-opus-5-5 \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01"
The example models can be replaced with any other model in the GET /v1/models list; feature availability depends on the model. Every request needs the x-api-key and anthropic-version headers.
The system prompt goes in the top-level system field (it is not a role inside messages); for multi-turn conversations put the earlier turns in messages in order, alternating user and assistant, ending with the new question. The API keeps no conversation state, so send the full history every time.
curl https://www.myai168.com/en/api/anthropic/v1/messages \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5-5",
"max_tokens": 4096,
"system": "You are a concise assistant. Always answer in Traditional Chinese.",
"messages": [
{"role": "user", "content": "Recommend three books on time management."},
{"role": "assistant", "content": "1. Getting Things Done 2. Deep Work 3. Atomic Habits"},
{"role": "user", "content": "Which one is best for beginners?"}
]
}'
Make the message content an array of blocks; placing image blocks before the text block works best. Use base64 for a local image:
import base64
import requests
with open("photo.jpg", "rb") as f:
b64 = base64.b64encode(f.read()).decode()
r = requests.post(
"https://www.myai168.com/en/api/anthropic/v1/messages",
headers={"x-api-key": "YOUR_API_KEY", "anthropic-version": "2023-06-01"},
json={
"model": "claude-sonnet-5-5",
"max_tokens": 4096,
"messages": [{
"role": "user",
"content": [
{"type": "image", "source": {"type": "base64", "media_type": "image/jpeg", "data": b64}},
{"type": "text", "text": "What is in this image?"},
],
}],
},
timeout=600,
)
print("".join(b["text"] for b in r.json()["content"] if b["type"] == "text"))
An image can also be a public URL; PDF files use a document block:
{"type": "image", "source": {"type": "url", "url": "https://example.com/photo.jpg"}}
{"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": "BASE64_PDF_DATA"}}
output_config.effort controls how much thinking and output the model spends: low, medium, high, xhigh or max. When omitted, most models use high and claude-opus-5-5 uses medium; claude-haiku-4-5 does not support this field. Higher effort is more thorough but slower and uses more output tokens.
curl https://www.myai168.com/en/api/anthropic/v1/messages \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-5-5",
"max_tokens": 16000,
"output_config": {"effort": "high"},
"messages": [{"role": "user", "content": "Prove that the square root of 2 is irrational."}]
}'
max_tokens is a hard cap on thinking plus reply text combined; if it is too small the budget runs out during thinking (stop_reason is max_tokens with no text). At high effort and above, set it to 16,000 or more and use streaming.claude-opus-5-5 returns 400 for thinking: {"type": "disabled"} or {"type": "enabled", ...}, so omit the thinking field and steer with effort only. To turn off up-front thinking on claude-sonnet-5-5, send thinking: {"type": "between_tools"} instead (effort high or below only).thinking block is empty); add the field below when you want a thinking summary. Thinking tokens count toward output usage whether or not they are displayed."thinking": {"type": "adaptive", "display": "summarized"}
In multi-turn conversations and tool loops, send the content blocks of the previous response (including thinking blocks and their signature) back in messages unchanged — do not edit or drop them.
Add the web search tool to tools and Claude searches the web when needed and cites its sources; searches are billed per use, and max_uses caps the number of searches per request.
curl https://www.myai168.com/en/api/anthropic/v1/messages \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5-5",
"max_tokens": 4096,
"tools": [{"type": "web_search_20250305", "name": "web_search", "max_uses": 5}],
"messages": [{"role": "user", "content": "Summarize the top technology news today, with sources."}]
}'
The response content gains server_tool_use (the query) and web_search_tool_result (the results) blocks, and text blocks carry citations with the source URL and title; the number of searches is in usage.server_tool_use.web_search_requests. If stop_reason is pause_turn, the search turn is not finished: append this response's content unchanged as an assistant message and send the request again to continue. Available tool versions are web_search_20250305 (basic search) and the newer web_search_20260209 and web_search_20260318.
Declare your own tools in tools with name, description and input_schema. When the model wants a tool, stop_reason is tool_use and content contains tool_use blocks (id, name, input); your code runs the tool and returns the result in a tool_result block:
import requests
url = "https://www.myai168.com/en/api/anthropic/v1/messages"
headers = {"x-api-key": "YOUR_API_KEY", "anthropic-version": "2023-06-01"}
tools = [{
"name": "get_weather",
"description": "Get the current weather for a city.",
"input_schema": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
}]
messages = [{"role": "user", "content": "What is the weather in Taipei?"}]
# 1) The model asks to use the tool (stop_reason == "tool_use")
first = requests.post(url, headers=headers, timeout=600, json={
"model": "claude-sonnet-5-5", "max_tokens": 4096, "tools": tools, "messages": messages,
}).json()
messages.append({"role": "assistant", "content": first["content"]}) # send the blocks back unchanged
# 2) Run the tool yourself and return a tool_result block for every tool_use block
results = []
for block in first["content"]:
if block["type"] == "tool_use":
answer = '{"city": "%s", "temp_c": 28}' % block["input"]["city"] # your own code goes here
results.append({"type": "tool_result", "tool_use_id": block["id"], "content": answer})
messages.append({"role": "user", "content": results})
# 3) Get the final answer
final = requests.post(url, headers=headers, timeout=600, json={
"model": "claude-sonnet-5-5", "max_tokens": 4096, "tools": tools, "messages": messages,
}).json()
print("".join(b["text"] for b in final["content"] if b["type"] == "text"))
Note: claude-fable-5-2, claude-fable-5-1, claude-opus-5-5 and claude-sonnet-5-5 reject forced tool use in tool_choice ({"type": "any"} and {"type": "tool", ...} return 400); use the default auto. Only tools that your own code runs, plus web search, are supported; other tools executed on Anthropic servers (code execution, computer use, remote MCP and so on) return HTTP 400.
When you reuse the same large content (a long document, a long system prompt, tool definitions), add cache_control to that block; later requests whose prefix is identical hit the cache, which is faster and uses less input:
curl https://www.myai168.com/en/api/anthropic/v1/messages \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5-5",
"max_tokens": 4096,
"system": [
{"type": "text", "text": "LONG_REFERENCE_DOCUMENT_TEXT", "cache_control": {"type": "ephemeral"}}
],
"messages": [{"role": "user", "content": "Summarize the key points of the document."}]
}'
Check usage.cache_creation_input_tokens (written to the cache) and usage.cache_read_input_tokens (cache hits) in the response. The cache lives for 5 minutes by default and is refreshed on every hit; content shorter than the model's minimum cacheable length is not cached.
Add "stream": true to receive an SSE event stream; use -N with curl. Text increments are in delta.text of content_block_delta events, and the stop reason and output usage are in message_delta; after the stream ends, SSE comment lines report the points charged and the remaining balance.
curl -N https://www.myai168.com/en/api/anthropic/v1/messages \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model":"claude-sonnet-5-5","max_tokens":1024,"stream":true,"messages":[{"role":"user","content":"Hello"}]}'
event: message_start
data: {"type":"message_start","message":{"id":"msg_...","role":"assistant","content":[],"usage":{"input_tokens":8,"output_tokens":1}}}
event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}
event: content_block_stop
data: {"type":"content_block_stop","index":0}
event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":12}}
event: message_stop
data: {"type":"message_stop"}
: cost=12
: credits-remaining=34567
If the stream is cut off midway or the upstream reports an error (event: error), the call is not charged.
Some Anthropic SDK features behave differently through this relay. Check this matrix before integrating to avoid surprises.
GET /v1/models and GET /v1/models/{model_id} — supported (compatible with SDK models.list / models.retrieve). Returns exactly the models this relay accepts; models not in the list are rejected with "No pricing info! Please use other models!".POST /v1/messages — supported, including streaming, prompt caching and thinking, as well as image / PDF input, effort and client-side tool use.POST /v1/messages/count_tokens — supported, free.web_search_* types) — supported and billed per search./v1/files (Files API) and /v1/messages/batches (Message Batches API) endpoints — not provided by this relay; requests return HTTP 404. Do not guess available endpoints from the SDK surface.mcp_servers) and the Files API — not supported, HTTP 400. Use client-side tool use instead. Reason: all relay users share one upstream workspace, so exposing the Files API / code execution containers would create a cross-user file-access risk; they are withheld for security.temperature must be omitted or 1; do not send top_p / top_k) with a 400; among the models this relay accepts, only claude-haiku-4-5 still takes them. For the thinking and tool_choice restrictions of the newest models see "Common feature examples". A 400 returned by Anthropic is passed through unchanged.anthropic-beta header — forwarded to the upstream as-is, so features in official public beta can be used; beta features that need server-side tools or files remain unsupported.X-Cost-Points (points charged) and X-Credits-Remaining (balance after the call) headers. Streaming responses append the same information after the event stream ends as SSE comment lines : cost=N / : credits-remaining=M. You can also query your balance any time with GET https://www.myai168.com/en/api/user/get_credits.The request body is JSON, identical to the official Anthropic Messages API spec. Authenticate with an x-api-key: YOUR_API_KEY or Authorization: Bearer YOUR_API_KEY header (never place keys in URL query strings).
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | required | Model id (e.g. claude-opus-5-5). Must be in the GET /v1/models list, otherwise 400 with "No pricing info! Please use other models!". |
max_tokens | integer | required | Maximum reply tokens (required by the official spec); on models that think, the limit covers thinking and reply text together. |
messages | array | required | Conversation messages, each {"role": "user" | "assistant", "content": "..."}; content may also be a list of content blocks (including base64 images). |
system | string or array | optional | System prompt — the official API accepts a string, or an array of text content blocks (TextBlockParam); the array form lets you attach cache_control to individual blocks for prompt caching. |
stream | boolean | optional | true streams the response as SSE. |
output_config | object | optional | {"effort": "low" | "medium" | "high" | "xhigh" | "max"}: reasoning effort (not supported by claude-haiku-4-5). |
thinking | object | optional | Extended thinking settings (forwarded per official spec). On the newest models omit it or send {"type": "adaptive"}; add "display": "summarized" for a thinking summary. |
tools / tool_choice | array | optional | Client-side tool definitions are forwarded as-is; the only accepted server-side tool is web search (web_search_*), others return 400. |
stop_sequences / metadata etc. | — | optional | Other official parameters are forwarded as-is. temperature / top_p / top_k are only accepted by claude-haiku-4-5 (see the support matrix). |
Non-streaming: the official message object — take the text from the blocks in the content array whose type is text (with thinking enabled the first block is a thinking block, and tool calls add tool_use blocks, so never assume content[0] is text); usage is in usage.input_tokens / usage.output_tokens; response headers include X-Cost-Points (points charged) and X-Credits-Remaining (balance after the call).
Always check stop_reason to confirm the reply is complete:
stop_reason | Meaning |
|---|---|
end_turn | Normal end of the reply. |
max_tokens | Cut off at the max_tokens limit — raise the limit or lower the effort. |
tool_use | The model wants to call your tool; run it and return a tool_result. |
pause_turn | A server-side tool (web search) has not finished; send the response back unchanged to continue. |
stop_sequence | One of your stop_sequences was hit. |
refusal | The model declined to answer for safety reasons. |
Streaming: SSE event stream (message_start / content_block_delta / message_delta / message_stop) with text deltas in content_block_delta's delta.text; after the event stream ends, SSE comment lines : cost=N / : credits-remaining=M carry the points charged and remaining balance. See section 7 of "Common feature examples" for a full event sample.
curl -N https://www.myai168.com/en/api/anthropic/v1/messages \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model":"claude-sonnet-5-5","max_tokens":1024,"stream":true,"messages":[{"role":"user","content":"Hello"}]}'
| HTTP status | Meaning |
|---|---|
400 | Invalid request body, model not in the supported list ("No pricing info! Please use other models!"), or an unsupported server-side tool was requested. A 400 returned by Anthropic for a parameter the model rejects is also passed through unchanged. |
401 | Missing or invalid API key (repeated failures from the same IP are temporarily blocked), or this API key has reached its credit limit (API key credit limit reached!). |
402 | Insufficient credits (please top up). |
404 | The endpoint does not exist, or this relay does not provide it (see the support matrix). |
429 / 529 / 5xx | Rate limiting (rate_limit_error) or overload (overloaded_error) reported by Anthropic — the status code and error body are passed through unchanged; retry later with increasing delays. |
502 | Upstream vendor error — never charged. |
Error responses are JSON with the message in error.message, for example:
{"error": {"type": "no_pricing_info", "message": "No pricing info! Please use other models!"}}
Errors reported by Anthropic and passed through use the official format (the message is likewise in error.message):
{"type": "error", "error": {"type": "invalid_request_error", "message": "max_tokens: Field required"}}
No points are ever charged on errors. The relay waits up to about 10 minutes for the model: set your client timeout to around 600 seconds for non-streaming calls, and prefer streaming when max_tokens is large or the effort is high.
This relay works with the official Anthropic SDKs: set base_url (baseURL in Node.js) to https://www.myai168.com/en/api/anthropic (do not append /v1 — the SDK adds /v1/messages itself) and api_key to your developer key. Install the package first: pip install anthropic (requires Python 3.10 or later; Node.js: npm install @anthropic-ai/sdk).
import anthropic
client = anthropic.Anthropic(
base_url="https://www.myai168.com/en/api/anthropic",
api_key="YOUR_API_KEY",
)
message = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
# content may include thinking and other blocks -- keep only the text blocks
print("".join(b.text for b in message.content if b.type == "text"))
# Streaming
with client.messages.stream(
model="claude-opus-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
Effort, system prompt, token counting and the model list (reusing the client above):
# Effort, system prompt and a larger output budget
message = client.messages.create(
model="claude-opus-5-5",
max_tokens=16000,
system="You are a concise assistant.",
output_config={"effort": "high"},
messages=[{"role": "user", "content": "Prove that the square root of 2 is irrational."}],
)
# Count tokens (free) and list the accepted models (free)
count = client.messages.count_tokens(
model="claude-opus-5-5",
messages=[{"role": "user", "content": "Hello"}],
)
print(count.input_tokens)
for m in client.models.list():
print(m.id)
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://www.myai168.com/en/api/anthropic",
apiKey: "YOUR_API_KEY",
});
const message = await client.messages.create({
model: "claude-opus-5-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello" }],
});
console.log(message.content.filter((b) => b.type === "text").map((b) => b.text).join(""));
const stream = client.messages.stream({
model: "claude-opus-5-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello" }],
});
stream.on("text", (text) => process.stdout.write(text));
await stream.finalMessage();
You can also configure the client with environment variables: ANTHROPIC_BASE_URL (as above, without /v1) and ANTHROPIC_API_KEY (developer key). The official Anthropic SDKs skip the billing comment lines this site appends at the end of the stream.
Notes: for non-streaming requests with a very large max_tokens, the SDK refuses because the call may run too long and asks you to stream instead — use the streaming form above. SDK methods such as client.beta.files and client.messages.batches map to endpoints this relay does not provide (404). To connect Claude Code, see the Claude Code CLI guides in the Developer Center.