Anthropic Messages
POST /v1/messages jest zgodny z API Messages od Anthropic. Używasz go, gdy twój kod stoi już na SDK Anthropic albo gdy narzędzie mówi formatem Anthropic, jak Claude Code. Obsługuje tylko modele Claude. Do pozostałych modeli czatu służy /v1/chat/completions.
Modele
| Id modelu | Cena |
|---|---|
claude-opus-5.5 | 29,37 zł / 146,87 zł za 1 mln tokenów |
claude-sonnet-5 | 17,62 zł / 88,12 zł za 1 mln tokenów |
claude-fable-5.1 | 58,75 zł / 293,74 zł za 1 mln tokenów |
Id modelu spoza rodziny Claude na tym endpoincie kończy się błędem.
Zapytanie
POST https://jantaris.com/v1/messages
x-api-key: sk-jt-...
anthropic-version: 2023-06-01
Content-Type: application/jsonNagłówek anthropic-version: 2023-06-01 jest wymagany. Oficjalne SDK dodają go same. Klucz możesz podać w x-api-key albo w Authorization: Bearer (Uwierzytelnianie).
| Pole | Typ | Wymagane | Opis |
|---|---|---|---|
model | string | tak | Id modelu Claude |
max_tokens | integer | tak | Górny limit wygenerowanych tokenów |
messages | array | tak | Naprzemienne tury user i assistant w formacie Anthropic |
system | string lub array | nie | Prompt systemowy |
stream | boolean | nie | true zwraca Server-Sent Events w formacie Anthropic |
temperature | number | nie | Temperatura próbkowania |
tools | array | nie | Definicje narzędzi w formacie Anthropic |
Podstawowe wywołanie
curl https://jantaris.com/v1/messages \
-H "x-api-key: $JANTARIS_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-5.5",
"max_tokens": 1024,
"system": "Jesteś zwięzłym recenzentem kodu.",
"messages": [{"role": "user", "content": "Oceń: def add(a, b): return a - b"}]
}'# pip install anthropic
import os
from anthropic import Anthropic
client = Anthropic(base_url="https://jantaris.com", api_key=os.environ["JANTARIS_API_KEY"])
msg = client.messages.create(
model="claude-opus-5.5",
max_tokens=1024,
system="Jesteś zwięzłym recenzentem kodu.",
messages=[{"role": "user", "content": "Oceń: def add(a, b): return a - b"}],
)
print(msg.content[0].text)
print(msg.usage)// npm install @anthropic-ai/sdk
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ baseURL: "https://jantaris.com", apiKey: process.env.JANTARIS_API_KEY });
const msg = await client.messages.create({
model: "claude-opus-5.5",
max_tokens: 1024,
system: "Jesteś zwięzłym recenzentem kodu.",
messages: [{ role: "user", content: "Oceń: def add(a, b): return a - b" }],
});
console.log(msg.content[0].text);Zwróć uwagę na base URL w SDK Anthropic: https://jantaris.com, bez /v1. SDK samo dokleja /v1/messages.
Odpowiedź
{
"id": "msg_...",
"type": "message",
"role": "assistant",
"model": "claude-opus-5.5",
"content": [{ "type": "text", "text": "Funkcja odejmuje zamiast dodawać..." }],
"stop_reason": "end_turn",
"usage": { "input_tokens": 31, "output_tokens": 57 }
}Streaming
Przy stream: true odpowiedź to strumień zdarzeń Anthropic (message_start, content_block_delta, message_stop i inne).
curl -N https://jantaris.com/v1/messages \
-H "x-api-key: $JANTARIS_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model": "claude-sonnet-5", "max_tokens": 512, "stream": true, "messages": [{"role": "user", "content": "Wyjaśnij SSE w dwóch zdaniach."}]}'with client.messages.stream(
model="claude-sonnet-5",
max_tokens=512,
messages=[{"role": "user", "content": "Wyjaśnij SSE w dwóch zdaniach."}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)const stream = client.messages.stream({
model: "claude-sonnet-5",
max_tokens: 512,
messages: [{ role: "user", content: "Wyjaśnij SSE w dwóch zdaniach." }],
});
stream.on("text", (text) => process.stdout.write(text));
await stream.finalMessage();Narzędzia
Narzędzia mają format Anthropic: name, description, input_schema. Model odpowiada blokiem tool_use, ty odsyłasz blok tool_result.
tools = [{
"name": "get_order_status",
"description": "Zwraca status wysyłki zamówienia",
"input_schema": {
"type": "object",
"properties": {"order_id": {"type": "string"}},
"required": ["order_id"],
},
}]
messages = [{"role": "user", "content": "Gdzie jest zamówienie A-1042?"}]
first = client.messages.create(model="claude-sonnet-5", max_tokens=1024, tools=tools, messages=messages)
if first.stop_reason == "tool_use":
call = next(b for b in first.content if b.type == "tool_use")
result = {"order_id": call.input["order_id"], "status": "wysłane"} # tu twój kod
messages += [
{"role": "assistant", "content": first.content},
{"role": "user", "content": [{"type": "tool_result", "tool_use_id": call.id, "content": str(result)}]},
]
final = client.messages.create(model="claude-sonnet-5", max_tokens=1024, tools=tools, messages=messages)
print(final.content[0].text)Błędy
Błędy na tym endpoincie mają format Anthropic, więc SDK Anthropic rzuca swoje zwykłe wyjątki:
{ "type": "error", "error": { "type": "authentication_error", "message": "Invalid API key." } }Kody HTTP są takie same jak w reszcie API. Domyślny limit to 600 zapytań na minutę na klucz. Szczegóły: Błędy.
Który endpoint wybrać
| Używasz | Endpoint |
|---|---|
| SDK Anthropic, Claude Code | /v1/messages |
| SDK OpenAI, Cursor, Cline, Continue, n8n, Make | /v1/chat/completions |
| Claude z poziomu SDK OpenAI | /v1/chat/completions z model: "claude-..." |









