Skip to main content

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 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
}'

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:

ParameterGuidance
max_tokensSet 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.
temperatureUse 0 for classification and extraction. Increase it only when the task benefits from variation.
seedCombine with temperature: 0 to reduce sampling variation between requests.
stopStandard stop sequences are honored.
messagesKeep 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.code when you need more detail. Some infrastructure-level 5xx responses 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-Timing with server-side latency durations. Error responses may omit usage and Server-Timing. 429 responses include Retry-After, and responses echo a caller-supplied trace ID.