跳轉到主要內容

快速開始

Python
from anthropic import Anthropic

client = Anthropic(
    base_url="https://api.orcarouter.ai",
    api_key="sk-orca-...",
)

response = client.messages.create(
    model="anthropic/claude-sonnet-4.6",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.content[0].text)
Anthropic SDK 自己會在 base_url 后面追加 /v1/messages,所以應填 裸主機名(不帶 /v1)。請求最終會落到 https://api.orcarouter.ai/v1/messages —— OrcaRouter 的一等公民 Anthropic 接口表面。原生 SSE 事件(message_startcontent_block_deltamessage_stop……)會直接透傳,流式、 工具調用、prompt 緩存(cache_control)、視覺端到端可用。 SDK 使用標準的 x-api-key 頭發送 api_key——OrcaRouter 的鑒權中間件 在 Anthropic 形態的路徑上識別該形式,不需要做任何 header 改造。 完整接受的鑒權頭列表見 獲取 API 密鑰

另見