EN ZalogujZałóż konto
Startujemy w październiku 2026. Działają konta, katalog modeli, kalkulator i dokumentacja. Studio jest dostępne w podglądzie; generowanie czeka na uruchomienie.

Anthropic Messages

Wszystkie strony dokumentacji

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 modeluCena
claude-opus-5.529,37 zł / 146,87 zł za 1 mln tokenów
claude-sonnet-517,62 zł / 88,12 zł za 1 mln tokenów
claude-fable-5.158,75 zł / 293,74 zł za 1 mln tokenów

Id modelu spoza rodziny Claude na tym endpoincie kończy się błędem.

Zapytanie

http
POST https://jantaris.com/v1/messages
x-api-key: sk-jt-...
anthropic-version: 2023-06-01
Content-Type: application/json

Nagłó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).

PoleTypWymaganeOpis
modelstringtakId modelu Claude
max_tokensintegertakGórny limit wygenerowanych tokenów
messagesarraytakNaprzemienne tury user i assistant w formacie Anthropic
systemstring lub arrayniePrompt systemowy
streambooleannietrue zwraca Server-Sent Events w formacie Anthropic
temperaturenumbernieTemperatura próbkowania
toolsarraynieDefinicje narzędzi w formacie Anthropic

Podstawowe wywołanie

bash
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"}]
  }'
python
# 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)
javascript
// 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ź

json
{
  "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).

bash
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."}]}'
python
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)
javascript
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.

python
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:

json
{ "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żywaszEndpoint
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-..."