Anthropic SDK
Use the Anthropic SDK with the Model Gate Messages API.
No current prepared translation is available. The English source is shown without machine translation.
Anthropic SDK through Model Gate
Python
from anthropic import Anthropic
client = Anthropic(
api_key="mg_live_...",
base_url="https://api.model-gate.com",
)
message = client.messages.create(
model="claude-sonnet-4.6",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
print(message.content[0].text)
Node.js
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: process.env.MODEL_GATE_API_KEY,
baseURL: "https://api.model-gate.com",
});
const message = await client.messages.create({
model: "ch-46s",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello" }],
});
console.log(message.content[0].text);
The Anthropic SDK base URL does not include /v1; the SDK appends the Messages path.