Czat (chat completions)
POST /v1/chat/completions jest zgodny z API Chat Completions od OpenAI. Każde SDK OpenAI i każde narzędzie zgodne z OpenAI zadziała, gdy ustawisz base URL na https://jantaris.com/v1 i podasz klucz Jantarisa. Ten sam endpoint obsługuje wszystkie modele czatu z katalogu, nie tylko te od OpenAI.
Modele
| Id modelu | Producent |
|---|---|
claude-opus-5.5 | Anthropic |
claude-sonnet-5 | Anthropic |
claude-fable-5.1 | Anthropic |
gpt-6-sol | OpenAI |
gpt-6-luna | OpenAI |
gpt-6-astra | OpenAI |
gemini-3.8-flash | |
deepseek-v4.1-flash | DeepSeek |
glm-5.3 | Zhipu |
kimi-k3 | Moonshot |
qwen3.8-max | Alibaba |
grok-4.7 | xAI |
Ceny za 1M tokenów wejścia i wyjścia znajdziesz w katalogu modeli i w odpowiedzi GET /v1/models?category=chat (Modele). Na przykład Claude Sonnet 5 kosztuje 17,62 zł / 88,12 zł za 1 mln tokenów.
Zapytanie
POST https://jantaris.com/v1/chat/completions
Authorization: Bearer sk-jt-...
Content-Type: application/json| Pole | Typ | Wymagane | Opis |
|---|---|---|---|
model | string | tak | Id modelu z tabeli wyżej |
messages | array | tak | Rozmowa w formacie OpenAI: {role, content}, role system, user, assistant, tool |
stream | boolean | nie | true zwraca Server-Sent Events. Domyślnie false |
max_tokens | integer | nie | Górny limit wygenerowanych tokenów |
temperature | number | nie | Temperatura próbkowania |
tools | array | nie | Definicje funkcji w formacie OpenAI |
tool_choice | string lub object | nie | auto, none, required albo konkretna funkcja |
Podstawowe wywołanie
curl https://jantaris.com/v1/chat/completions \
-H "Authorization: Bearer $JANTARIS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6-sol",
"messages": [
{"role": "system", "content": "Odpowiadasz jednym zdaniem."},
{"role": "user", "content": "Co to jest webhook?"}
]
}'import os
from openai import OpenAI
client = OpenAI(base_url="https://jantaris.com/v1", api_key=os.environ["JANTARIS_API_KEY"])
resp = client.chat.completions.create(
model="gpt-6-sol",
messages=[
{"role": "system", "content": "Odpowiadasz jednym zdaniem."},
{"role": "user", "content": "Co to jest webhook?"},
],
)
print(resp.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://jantaris.com/v1", apiKey: process.env.JANTARIS_API_KEY });
const resp = await client.chat.completions.create({
model: "gpt-6-sol",
messages: [
{ role: "system", content: "Odpowiadasz jednym zdaniem." },
{ role: "user", content: "Co to jest webhook?" },
],
});
console.log(resp.choices[0].message.content);Bez SDK, samym requests:
import os, requests
r = requests.post(
"https://jantaris.com/v1/chat/completions",
headers={"Authorization": f"Bearer {os.environ['JANTARIS_API_KEY']}"},
json={"model": "gemini-3.8-flash", "messages": [{"role": "user", "content": "Cześć"}]},
timeout=120,
)
r.raise_for_status()
print(r.json()["choices"][0]["message"]["content"])Odpowiedź
{
"id": "chatcmpl-...",
"object": "chat.completion",
"created": 1790500000,
"model": "gpt-6-sol",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "Webhook to zapytanie HTTP, które serwis wysyła na twój adres, gdy coś się wydarzy." },
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 24, "completion_tokens": 18, "total_tokens": 42 }
}Płacisz według usage: tokeny wejścia po cenie wejścia modelu, tokeny wyjścia po cenie wyjścia.
Streaming
Ustaw stream: true, żeby dostawać tokeny na bieżąco. Odpowiedź ma typ text/event-stream, linie data: w formacie chunków OpenAI i kończy się data: [DONE].
curl -N https://jantaris.com/v1/chat/completions \
-H "Authorization: Bearer $JANTARIS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "claude-sonnet-5", "stream": true, "messages": [{"role": "user", "content": "Policz do pięciu."}]}'data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"1"}}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":", 2"}}]}
data: [DONE]stream = client.chat.completions.create(
model="claude-sonnet-5",
messages=[{"role": "user", "content": "Policz do pięciu."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)const stream = await client.chat.completions.create({
model: "claude-sonnet-5",
messages: [{ role: "user", content: "Policz do pięciu." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}Wywołania narzędzi
Narzędzia mają format function calling z OpenAI. Model zwraca tool_calls, ty uruchamiasz funkcję i odsyłasz wynik jako wiadomość z rolą tool.
import json
tools = [{
"type": "function",
"function": {
"name": "get_order_status",
"description": "Zwraca status wysyłki zamówienia",
"parameters": {
"type": "object",
"properties": {"order_id": {"type": "string"}},
"required": ["order_id"],
},
},
}]
messages = [{"role": "user", "content": "Gdzie jest zamówienie A-1042?"}]
first = client.chat.completions.create(model="gpt-6-luna", messages=messages, tools=tools)
msg = first.choices[0].message
if msg.tool_calls:
messages.append(msg)
for call in msg.tool_calls:
args = json.loads(call.function.arguments)
result = {"order_id": args["order_id"], "status": "wysłane"} # tu twój kod
messages.append({"role": "tool", "tool_call_id": call.id, "content": json.dumps(result)})
final = client.chat.completions.create(model="gpt-6-luna", messages=messages, tools=tools)
print(final.choices[0].message.content)const tools = [{
type: "function",
function: {
name: "get_order_status",
description: "Zwraca status wysyłki zamówienia",
parameters: { type: "object", properties: { order_id: { type: "string" } }, required: ["order_id"] },
},
}];
const messages = [{ role: "user", content: "Gdzie jest zamówienie A-1042?" }];
const first = await client.chat.completions.create({ model: "gpt-6-luna", messages, tools });
const msg = first.choices[0].message;
if (msg.tool_calls) {
messages.push(msg);
for (const call of msg.tool_calls) {
const args = JSON.parse(call.function.arguments);
const result = { order_id: args.order_id, status: "wysłane" }; // tu twój kod
messages.push({ role: "tool", tool_call_id: call.id, content: JSON.stringify(result) });
}
const final = await client.chat.completions.create({ model: "gpt-6-luna", messages, tools });
console.log(final.choices[0].message.content);
}Błędy
Ten endpoint zwraca błędy w formacie OpenAI, więc SDK OpenAI rzuca swoje zwykłe wyjątki (AuthenticationError, RateLimitError itd.). Domyślny limit to 600 zapytań na minutę na klucz. Szczegóły: Błędy.
Zobacz też
- SDK Anthropic i Claude Code: Anthropic Messages
- Cursor, Cline, Continue: Claude Code i narzędzia IDE









