Home›Developer Center›Anthropic (Claude) API

Anthropic (Claude) API

API DocumentationOpenAI ChatGPT APIAnthropic (Claude) APIGoogle Gemini APIGoogle Search APIGoogle News APIOpenRouter APIAPI Pricing
CLI & Agent Guidescc-switch macOScc-switch Windowscc-switch LinuxOpenCode macOSOpenCode WindowsOpenCode LinuxOpenClaw macOSOpenClaw WindowsOpenClaw LinuxHermes Agent macOSHermes Agent WindowsHermes Agent LinuxClaude Code CLI macOSClaude Code CLI WindowsClaude Code CLI LinuxCodex CLI macOSCodex CLI WindowsCodex CLI Linux
MYAI168 API & MCPMYAI168 MCP CLIMYAI168 MCP Web & App
No matching questions on this page.Search the whole site
Claude

Anthropic (Claude) API Relay

POST https://www.myai168.com/en/api/anthropic/v1/messages

Claude Messages API (Claude 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).

curl https://www.myai168.com/en/api/anthropic/v1/messages \
  -H "x-api-key: YOUR_DEV_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-opus-4-8","max_tokens":1024,"messages":[{"role":"user","content":"Hello"}]}'
import requests

r = requests.post(
    "https://www.myai168.com/en/api/anthropic/v1/messages",
    headers={
        "x-api-key": "YOUR_DEV_KEY",
        "anthropic-version": "2023-06-01",
    },
    json={"model": "claude-opus-4-8", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello"}]},
)
print(r.json())
Supported endpoints and features (support matrix)

Support Matrix

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} — 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 (billed at official cache rates) and thinking.
  • POST /v1/messages/count_tokens — supported, free.
  • Web search tool (versioned web_search_* types) — supported and billed per search.
  • Other server tools (code execution, computer use, remote MCP 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 disabled for security.
  • Non-streaming responses include 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.
  • Failed calls, and calls where the vendor returns no usage info, are never charged.
Request parameters, response format and error codes

Request parameters (POST https://www.myai168.com/en/api/anthropic/v1/messages)

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).

ParameterTypeRequiredDescription
modelstringrequiredModel id (e.g. claude-opus-4-8). Must be in the GET /v1/models list, otherwise 400 with "No pricing info! Please use other models!".
max_tokensintegerrequiredMaximum reply tokens (required by the official spec).
messagesarrayrequiredConversation messages, each {"role": "user" | "assistant", "content": "..."}; content may also be a list of content blocks (including base64 images).
systemstring or arrayoptionalSystem 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.
streambooleanoptionaltrue streams the response as SSE.
thinkingobjectoptionalExtended thinking settings (forwarded per official spec).
toolsarrayoptionalClient-side tool definitions are forwarded as-is; the only accepted server-side tool is web search (web_search_*), others return 400.
temperature / top_p / stop_sequences etc.—optionalOther official parameters are forwarded as-is.

Response format

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).

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.

Streaming example

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","max_tokens":1024,"stream":true,"messages":[{"role":"user","content":"Hello"}]}'

Error codes

HTTP statusMeaning
401Missing or invalid API key (repeated failures from the same IP are temporarily blocked).
402Insufficient credits (please top up).
400Invalid request body, model not in the supported list ("No pricing info! Please use other models!"), or an unsupported server-side tool was requested.
502Upstream vendor error — never charged.

No points are ever charged on errors (including when the vendor returns no usage info).

‹ Previous page: OpenAI ChatGPT APINext page: Google Gemini API ›
↑
Question link copied.

Other FAQ pages

API Documentation

  • OpenAI ChatGPT API
  • Google Gemini API
  • Google Search API
  • Google News API
  • OpenRouter API
  • API Pricing

CLI & Agent Guides

  • cc-switch macOS
  • cc-switch Windows
  • cc-switch Linux
  • OpenCode macOS
  • OpenCode Windows
  • OpenCode Linux
  • OpenClaw macOS
  • OpenClaw Windows
  • OpenClaw Linux
  • Hermes Agent macOS
  • Hermes Agent Windows
  • Hermes Agent Linux
  • Claude Code CLI macOS
  • Claude Code CLI Windows
  • Claude Code CLI Linux
  • Codex CLI macOS
  • Codex CLI Windows
  • Codex CLI Linux

MYAI168 API & MCP

  • MYAI168 MCP CLI
  • MYAI168 MCP Web & App