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.cloud.celeris.ai/celeris-1/v1
Auth Authorization: Bearer dg_...
Content application/json
Chat completions
POST /chat/completions is the primary endpoint.
- cURL
- Python
- TypeScript
curl https://inference.cloud.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": 64,
"temperature": 0,
"seed": 7
}'
import os
from openai import OpenAI
client = OpenAI(
base_url="https://inference.cloud.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=64,
temperature=0,
seed=7,
)
print(response.choices[0].message.content)
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://inference.cloud.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: 64,
temperature: 0,
seed: 7,
});
console.log(response.choices[0].message.content);
Parameters that matter most here
The API accepts the chat-completion fields listed in the API reference. These parameters have the greatest effect on short, structured workloads:
| Parameter | Guidance |
|---|---|
max_tokens | Set a limit that fits the expected response. For example, a label may need 4 tokens and a small JSON object may need 64. Lower limits reduce worst-case latency and cost. |
temperature | Use 0 for classification and extraction. Increase it only when the task benefits from variation. |
seed | Combine with temperature: 0 to reduce sampling variation between requests. |
stop | Standard stop sequences are honored. |
messages | Keep prompts short and pointed. Prompt plus max_tokens must fit the 4,096-token context window. |
The full parameter reference lives in the API reference.
Streaming
Leave stream unset for one complete JSON response, or set stream: true for
OpenAI-compatible server-sent events. Streaming responses end with [DONE].
Set stream_options: {"include_usage": true} so the final chunk carries the
request's token usage.
For short responses, a single JSON response is usually simpler. Use streaming when an interactive client needs to display partial output. A client disconnect does not guarantee that processing stops; see Pricing.
Calling from the browser
The API supports browser requests. It responds to preflight OPTIONS
requests, returns Access-Control-Allow-Origin: *, and exposes the
Server-Timing header to browser scripts. A single-page application can call
Celeris directly:
const response = await fetch(
'https://inference.cloud.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: 32,
temperature: 0,
}),
},
);
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.
Response behavior
- API errors use OpenAI-compatible JSON. SDKs expose them as HTTP errors
with the status intact. Handle broad cases by status and use
error.codewhen you need more detail. Some infrastructure-level5xxresponses may not include JSON. See Errors. - Every successful response includes
usage(prompt, completion, and total tokens) — the same numbers the usage dashboard aggregates. - Every successful response includes
Server-Timingwith server-side latency durations. Error responses may omitusageandServer-Timing.429responses includeRetry-After, and responses echo a caller-supplied trace ID.