Migrating from Anthropic to Turing Platform
To migrate code using the Anthropic Python/TypeScript SDK to the Turing Platform, you need to change three things: base_url, the authentication header type (x-api-key → Authorization: Bearer), and the model name.
Core diff
Python
from anthropic import Anthropic
client = Anthropic(
- api_key=os.environ["ANTHROPIC_API_KEY"],
+ auth_token=os.environ["TURING_API_KEY"],
+ base_url="https://live-turing.cn.llm.tcljd.com/api/v1",
)
message = client.messages.create(
- model="claude-sonnet-5",
+ model="turing/claude-sonnet-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
api_key → auth_tokenThe Anthropic SDK authenticates using the x-api-key header by default. The Turing Platform uses the standard Authorization: Bearer header — in the SDK, this corresponds to the auth_token parameter (not api_key).
TypeScript / Node.js
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
- apiKey: process.env.ANTHROPIC_API_KEY,
+ authToken: process.env.TURING_API_KEY,
+ baseURL: "https://live-turing.cn.llm.tcljd.com/api/v1",
});
cURL
-curl https://api.anthropic.com/v1/messages \
+curl https://live-turing.cn.llm.tcljd.com/api/v1/messages \
- -H "x-api-key: $ANTHROPIC_API_KEY" \
- -H "anthropic-version: 2023-06-01" \
+ -H "Authorization: Bearer $TURING_API_KEY" \
-H "Content-Type: application/json" \
-d '{
- "model": "claude-sonnet-5",
+ "model": "turing/claude-sonnet-5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello"}]
}'
anthropic-version headerThe Turing Platform automatically selects the appropriate API version internally. You may keep this header (it is harmless) or remove it.
Model name mapping
Claude model names on the Turing Platform are prefixed with turing/claude-*. When migrating, prefer recent model versions such as turing/claude-sonnet-5 or turing/claude-opus-4.8.
For the full list of available models, context windows, pricing, and retirement status, refer to Model List → Turing Claude.
Feature comparison
| Feature | Anthropic Native | Turing Platform |
|---|---|---|
| Messages API | ✅ | ✅ Fully compatible; see Messages API |
| Streaming SSE | ✅ | ✅ |
Function calling (tools + tool_result) | ✅ | ✅ |
| Extended Thinking | ✅ {"type": "enabled"/"adaptive"} | ✅ |
Prompt Caching (cache_control) | ✅ | ✅, with 5m / 1h TTL |
| Vision (image input) | ✅ | ✅ |
Web Search Tool (web_search_20250305) | ✅ | ✅ |
| Computer Use | ✅ | ⚠ Routed via upstream Vertex AI; supported in some scenarios |
| Files API | ✅ | ⚠ Planned |
| Batch API | ✅ | ⚠ Not publicly available |
| Count Tokens | ✅ | ✅ /api/count-message-tokens |
Turing Platform addition: turing_options
Add a turing_options field at the top level of the request to access platform capabilities:
message = client.messages.create(
model="turing/claude-sonnet-5",
max_tokens=1024,
messages=[...],
extra_body={
"turing_options": {
"timeout": 30,
"max_retries": 2,
"fallbacks": ["turing/gpt-5.4-mini"]
}
}
)
See Timeout, Retry, and Fallback.
Common gotchas
- Using
api_keyby mistake: The SDK will automatically use thex-api-keyheader, causing the Turing Platform to return 401; you must useauth_token. - Model name date suffixes: Date-suffixed names like
claude-sonnet-4-5-20241022are not used on the Turing Platform — dates are dropped:turing/claude-sonnet-4.5. anthropic-versionheader: No need to set this explicitly.- Response fields
id,type,role, etc.: Identical to Anthropic's responses; no changes to parsing logic are required. - Thinking configuration for newer Claude models:
claude-opus-4.7/claude-opus-4.8/claude-sonnet-5do not supporttype: "enabled"+budget_tokens; usetype: "adaptive"+output_config.effortinstead. Sonnet 5 has reasoning enabled by default but can bedisabled; Opus 4.7/4.8 has it disabled by default and must be explicitly enabled. See Reasoning for details.
Optional: Switch to the Chat Completions protocol
The Anthropic Messages protocol is Claude's native protocol and is not portable across providers. If you want to use the same code to switch freely between Claude, GPT, Gemini, and Qwen, switch to the OpenAI Chat Completions protocol:
-from anthropic import Anthropic
-client = Anthropic(
- auth_token="...",
- base_url="https://live-turing.cn.llm.tcljd.com/api/v1",
-)
+from openai import OpenAI
+client = OpenAI(
+ api_key="...",
+ base_url="https://live-turing.cn.llm.tcljd.com/api/v1",
+)
-message = client.messages.create(
- model="turing/claude-sonnet-5",
- max_tokens=1024,
- messages=[{"role": "user", "content": "Hello"}],
-)
+response = client.chat.completions.create(
+ model="turing/claude-sonnet-5", # Change only this line to switch models
+ messages=[{"role": "user", "content": "Hello"}],
+)
If you need Claude-native features — such as fine-grained cache_control caching, server_tool_use / web_search_tool_result block structures, or direct return of thinking blocks — staying on the Messages protocol provides a better experience.
Platform capabilities available immediately after migration
- Fallback to non-Claude models: If
claude-sonnet-5fails, automatically switches togpt-5.4-mini. - Unified billing view for cross-provider prompt caching: Billing & Usage.
- Request tracing:
X-Turing-Trace-Idresponse header. - Unified rate limit view: Rate Limits.
See also
- Messages API — Claude native protocol
- Chat Completions — OpenAI-compatible protocol (supports Claude)
- Prompt Caching —
cache_controlin depth - Reasoning — Claude adaptive thinking migration guide
- Migrate from OpenAI