Вызывайте model Claude Anthropic через единый endpoint /chat/completions TokenHub. Полная совместимость с OpenAI-compatible форматом запросов и ответов — миграция SDK не требуется. Поддерживаются streaming, использование инструментов (function calling) и vision (ввод изображений). Оплата по token в зависимости от tier model.
th-xxxxxxxxxxxx...)https://tokenhub.store/api/v1Передайте API Key в заголовке Authorization:
Authorization: Bearer th-your-api-keyPOST/chat/completionsChat completion. Тот же schema, что и у OpenAI /v1/chat/completions, включая streaming, использование инструментов, vision и JSON mode.
Цены указаны за 1 миллион tokens (USD). Оплачиваются только успешные запросы. Принимаются как канонический ID, так и alias вида anthropic/*.
| Уровень | ID model | Вход | Выход | Примечания |
|---|---|---|---|---|
| Opus 4.7 | anthropic/claude-opus-4-7 | $5.00 | $25.00 | Новейшее, наивысшее качество reasoning и coding. |
| Opus 4.6 | anthropic/claude-opus-4-6 | $5.00 | $25.00 | Новейшее, наивысшее качество reasoning и coding. |
| Sonnet 4.6 | anthropic/claude-sonnet-4-6 | $3.00 | $15.00 | Флагманский баланс качества и стоимости (рекомендуется по умолчанию). |
| Haiku 4.5 | anthropic/claude-haiku-4-5 | $1.00 | $5.00 | Самый быстрый и дешевый 4-gen; отлично подходит для high-QPS и классификации. |
| Sonnet 4.5 | anthropic/claude-sonnet-4-5 | $3.00 | $15.00 | Предыдущее поколение, универсальная рабочая модель. |
| Opus 4.5 | anthropic/claude-opus-4-5 | $5.00 | $25.00 | Новейшее, наивысшее качество reasoning и coding. |
| Sonnet 4 | anthropic/claude-4-sonnet | $3.00 | $15.00 | Предыдущее поколение, универсальная рабочая модель. |
| Opus 4 | anthropic/claude-4-opus | $15.00 | $75.00 | Новейшее, наивысшее качество reasoning и coding. |
| 3.5 Sonnet | anthropic/claude-3-5-sonnet-latest | $3.00 | $15.00 | Стабильная, проверенная в production; широко совместимая. |
| 3.5 Haiku | anthropic/claude-3-5-haiku-latest | $0.80 | $4.00 | Стабильная, проверенная в production; широко совместимая. |
| Параметр | Тип | Обязательно | По умолчанию | Описание |
|---|---|---|---|---|
| model | string | Обязательно | — | ID model Claude. Пример: "anthropic/claude-sonnet-4-6". Поддерживаются как формы с префиксом anthropic/*, так и короткое имя без префикса. |
| messages | array | Обязательно | — | История чата. Каждый элемент имеет вид { role, content }. role ∈ system | user | assistant. content — строка или массив частей (для vision / результатов инструментов). |
| max_tokens | integer | Необязательно | 1024 | Максимум output tokens (Claude требует это поле). Обычно 1024–4096. |
| temperature | number | Необязательно | 1.0 | Sampling temperature, 0.0–1.0. Ниже = более детерминированно. |
| top_p | number | Необязательно | 1.0 | Nucleus sampling. Используйте temperature ИЛИ top_p, но не оба сразу. |
| stream | boolean | Необязательно | false | Если true, возвращает Server-Sent Events (SSE) deltas. |
| stop | string[] | Необязательно | — | До 4 stop sequences. |
| tools | array | Необязательно | — | Список определений tool/function для использования инструментов (function calling). |
| tool_choice | string|object | Необязательно | auto | Управление выбором tool: auto | none | required | { type:'function', function:{ name } }. |
| response_format | object | Необязательно | — | JSON mode: { "type": "json_object" } заставляет model возвращать валидный JSON. |
| user | string | Необязательно | — | Необязательный ID конечного пользователя для вашего учета. |
curl https://tokenhub.store/api/v1/chat/completions \
-H "Authorization: Bearer th-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4-6",
"messages": [
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Explain CAP theorem in 3 bullets."}
],
"max_tokens": 512,
"temperature": 0.3
}'from openai import OpenAI
client = OpenAI(
api_key="th-your-api-key",
base_url="https://tokenhub.store/api/v1",
)
resp = client.chat.completions.create(
model="anthropic/claude-sonnet-4-6",
max_tokens=512,
temperature=0.3,
messages=[
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Explain CAP theorem in 3 bullets."},
],
)
print(resp.choices[0].message.content)
print("usage:", resp.usage)import OpenAI from "openai";
const client = new OpenAI({
apiKey: "th-your-api-key",
baseURL: "https://tokenhub.store/api/v1",
});
const resp = await client.chat.completions.create({
model: "anthropic/claude-sonnet-4-6",
max_tokens: 512,
temperature: 0.3,
messages: [
{ role: "system", content: "You are a concise assistant." },
{ role: "user", content: "Explain CAP theorem in 3 bullets." },
],
});
console.log(resp.choices[0].message.content);
console.log("usage:", resp.usage);Зарегистрируйтесь в TokenHub и начните вызывать Claude через наш OpenAI-compatible API