Making requests
Celeris exposes an OpenAI-compatible HTTP API. You can use the official OpenAI SDKs or other clients that support a custom base URL.
Base URL https://inference.celeris.ai/celeris-1/v1
Auth Authorization: Bearer ck_...
Content application/json
Framework clients take the same base URL, key, and model name:
| Client | Settings |
|---|---|
LangChain ChatOpenAI | base_url, api_key, model |
Vercel AI SDK createOpenAICompatible | baseURL, apiKey, name; select the model with provider.chatModel(model) |
LiteLLM completion | api_base, api_key; prefix the model name with openai/ |
Chat completions
POST /chat/completions is the primary endpoint.
- cURL
- Python
- TypeScript
curl https://inference.celeris.ai/celeris-1/v1/chat/completions \
-H "Authorization: Bearer $CELERIS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "celeris-1",
"messages": [
{"role": "system", "content": "Extract the requested fields. Reply with JSON only."},
{"role": "user", "content": "Order #4411: 2x flat white, oat milk, pickup 8:15am. Fields: items, milk, pickup_time"}
],
"max_tokens": 256
}'
import os
from openai import OpenAI
client = OpenAI(
base_url="https://inference.celeris.ai/celeris-1/v1",
api_key=os.environ["CELERIS_API_KEY"],
)
response = client.chat.completions.create(
model="celeris-1",
messages=[
{"role": "system", "content": "Extract the requested fields. Reply with JSON only."},
{
"role": "user",
"content": "Order #4411: 2x flat white, oat milk, pickup 8:15am. Fields: items, milk, pickup_time",
},
],
max_tokens=256,
)
print(response.choices[0].message.content)
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://inference.celeris.ai/celeris-1/v1',
apiKey: process.env.CELERIS_API_KEY,
});
const response = await client.chat.completions.create({
model: 'celeris-1',
messages: [
{role: 'system', content: 'Extract the requested fields. Reply with JSON only.'},
{
role: 'user',
content: 'Order #4411: 2x flat white, oat milk, pickup 8:15am. Fields: items, milk, pickup_time',
},
],
max_tokens: 256,
});
console.log(response.choices[0].message.content);
Parameters that matter most here
| Parameter | Guidance |
|---|---|
max_tokens / max_completion_tokens | Output-token budget. Defaults to 2048 when neither field is supplied. Start short structured calls at 256 with thinking off; use at least 2048 with thinking on and adjust for your workload. See Models for limits and output budgets for exceptions. |
stop | Stop generation at a supplied stop sequence. |
messages | The conversation, with a role and content for each message. See Image input for messages containing images. |
chat_template_kwargs | Controls reasoning, including whether the model thinks before answering. |
See the API reference for all supported fields.
Output budgets
In some cases, additional output may be generated to complete a response, so
reported completion usage can exceed the requested budget. Use the returned
usage for token accounting.
Prompt caching
Read cached input-token counts from usage.prompt_tokens_details.cached_tokens
on chat completions or usage.input_tokens_details.cached_tokens on Responses.
See Token usage for accounting.
Sending images
See Image input for the request format, supported formats, and size limits.
Responses API
POST /v1/responses implements the OpenAI Responses API. Send your prompt as
input on each request: a string, or an array of messages whose content is a
string or an array of input parts:
- cURL
- Python
curl https://inference.celeris.ai/celeris-1/v1/responses \
-H "Authorization: Bearer $CELERIS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "celeris-1",
"input": "Rewrite as a search query: cheap flights sydney to tokyo june",
"max_output_tokens": 256
}'
import os
from openai import OpenAI
client = OpenAI(
base_url="https://inference.celeris.ai/celeris-1/v1",
api_key=os.environ["CELERIS_API_KEY"],
)
response = client.responses.create(
model="celeris-1",
input="Rewrite as a search query: cheap flights sydney to tokyo june",
max_output_tokens=256,
)
print(response.output_text)
Set max_output_tokens explicitly. If omitted, the output budget is the
remaining context window. Set stream: true for a stream of Responses events,
which ends with response.completed on success.
Sending images on the Responses API
Follow the Responses image-input procedure. Its content-part format differs from chat completions.
Tool calling
Pass OpenAI-style tools and the model calls one when appropriate. tool_choice
sets the calling policy:
auto(default): the model decides whether to call a tool.none: the model never calls a tool.required: the model is directed to call one of the provided tools.{"type": "function", "function": {"name": "..."}}: the model is directed to call that specific function.
On celeris-1, required and named tool choices need a non-streaming request.
Check for tool_calls in the response and validate the parsed arguments
against your schema before running a tool.
curl https://inference.celeris.ai/celeris-1/v1/chat/completions \
-H "Authorization: Bearer $CELERIS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "celeris-1",
"messages": [{"role": "user", "content": "What is the weather in Melbourne?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}],
"max_tokens": 256
}'
When the model calls a tool, the reply has finish_reason: "tool_calls" and the
call under choices[0].message.tool_calls:
{
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [{
"id": "call_abc123",
"type": "function",
"function": {"name": "get_weather", "arguments": "{\"city\": \"Melbourne\"}"}
}]
},
"finish_reason": "tool_calls"
}]
}
Run the tool yourself, then send the result back as a tool message that
references the call's id to get the final answer:
curl https://inference.celeris.ai/celeris-1/v1/chat/completions \
-H "Authorization: Bearer $CELERIS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "celeris-1",
"messages": [
{"role": "user", "content": "What is the weather in Melbourne?"},
{"role": "assistant", "content": null, "tool_calls": [{"id": "call_abc123", "type": "function", "function": {"name": "get_weather", "arguments": "{\"city\": \"Melbourne\"}"}}]},
{"role": "tool", "tool_call_id": "call_abc123", "content": "18°C, partly cloudy"}
],
"max_tokens": 256
}'
Reasoning
Celeris-1 reasons only when asked. Set enable_thinking: true inside
chat_template_kwargs. Celeris-1 Magnus reasons by default. Send
enable_thinking: false to get a direct answer.
Celeris-1 has one reasoning mode, so omit reasoning_effort for that model.
Celeris-1 Magnus accepts reasoning_effort at the top level or inside
chat_template_kwargs while thinking is on: low, medium, or xhigh.
It defaults to low. If both are supplied, the top-level value is used.
curl https://inference.celeris.ai/celeris-1/v1/chat/completions \
-H "Authorization: Bearer $CELERIS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "celeris-1",
"messages": [{"role": "user", "content": "If a train travels 60 km in 45 minutes, what is its average speed in km/h?"}],
"chat_template_kwargs": {"enable_thinking": true},
"max_tokens": 2048
}'
When reasoning is separated, it appears in message.reasoning and the answer
in message.content:
{
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"reasoning": "60 km in 45 min. 45 min = 0.75 h. 60 / 0.75 = 80.",
"content": "80 km/h."
},
"finish_reason": "stop"
}]
}
On chat-completion streams, separated reasoning arrives as delta.reasoning
and the answer as delta.content. Set include_reasoning: false to omit
separated reasoning from the response.
The OpenAI SDKs pass non-standard fields through extra_body:
response = client.chat.completions.create(
model="celeris-1",
messages=[{"role": "user", "content": "If a train travels 60 km in 45 minutes, what is its average speed in km/h?"}],
max_tokens=2048,
extra_body={"chat_template_kwargs": {"enable_thinking": True}},
)
reasoning = getattr(response.choices[0].message, "reasoning", None) or ""
if reasoning:
print(reasoning)
print(response.choices[0].message.content)
Reasoning tokens count toward max_tokens / max_output_tokens. A small
budget can stop generation before an answer is emitted. If chat completions
returns empty content with finish_reason: "length", retry with a larger budget.
For empty content with finish_reason: "stop", retry as-is or turn thinking off.
See Known issues for unseparated reasoning and replies after tool results.
Reasoning on the Responses API
Use the same chat_template_kwargs: {"enable_thinking": true} on /v1/responses.
Separated reasoning appears in an output item of type: "reasoning"; the
answer appears in an item of type: "message":
{
"output": [
{"type": "reasoning", "content": [{"type": "reasoning_text", "text": "60 km in 45 min = 0.75 h. 60 / 0.75 = 80."}]},
{"type": "message", "role": "assistant", "content": [{"type": "output_text", "text": "80 km/h.", "annotations": []}]}
]
}
JSON mode
Use response_format to get JSON ready to parse:
{"type": "json_object"}requests a JSON object.{"type": "json_schema", "json_schema": {"name": "...", "schema": {...}}}requests JSON that validates against your schema. The schema must have an object root.
curl https://inference.celeris.ai/celeris-1/v1/chat/completions \
-H "Authorization: Bearer $CELERIS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "celeris-1",
"messages": [{"role": "user", "content": "Give me a person and the city they live in, for Paris."}],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "person_city",
"schema": {
"type": "object",
"properties": {"name": {"type": "string"}, "city": {"type": "string"}},
"required": ["name", "city"],
"additionalProperties": false
}
}
},
"max_tokens": 256
}'
Read the JSON from message.content. Check finish_reason before parsing:
length means the output may be incomplete; retry with a larger budget.
On celeris-1, JSON mode works only on non-streaming /chat/completions
requests. If you ask for JSON in the prompt instead, handle
possible Markdown fences
before parsing. When a response calls a tool, the JSON format does not apply
to the tool call.
See Errors for invalid schemas or output that cannot satisfy the schema, and Pricing for billing. Reported output usage can exceed the requested output budget.
Streaming
Leave stream unset for one complete JSON response, or set stream: true for
OpenAI-compatible server-sent events. Chat-completion streams end with [DONE].
Set stream_options: {"include_usage": true} so the final chunk carries the
request's token usage.
- Python
- TypeScript
stream = client.chat.completions.create(
model="celeris-1",
messages=[{"role": "user", "content": "List three uses for a brick."}],
max_tokens=256,
stream=True,
stream_options={"include_usage": True},
)
for chunk in stream:
if chunk.choices: # the final include_usage chunk carries no choices
print(chunk.choices[0].delta.content or "", end="")
if chunk.usage:
print(f"\n{chunk.usage.total_tokens} tokens")
const stream = await client.chat.completions.create({
model: 'celeris-1',
messages: [{role: 'user', content: 'List three uses for a brick.'}],
max_tokens: 256,
stream: true,
stream_options: {include_usage: true},
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
if (chunk.usage) console.log(`\n${chunk.usage.total_tokens} tokens`);
}
Calling from the browser
The API supports browser requests. A single-page application can call Celeris directly:
const response = await fetch(
'https://inference.celeris.ai/celeris-1/v1/chat/completions',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${key}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'celeris-1',
messages: [{role: 'user', content: 'Rewrite as a search query: cheap flights sydney to tokyo june'}],
max_tokens: 256,
}),
},
);
if (!response.ok) throw new Error(`Celeris request failed: ${response.status}`);
const result = await response.json();
console.log(result.choices[0].message.content);
Authentication uses a bearer header rather than a cookie. Do not embed a Celeris key in public client-side code. See Authentication.