Skip to content

API reference

Chat completions

The endpoint that runs a model.

This is the endpoint that runs a model. The body follows the OpenAI chat completions schema.

Create a completion

POSThttps://odysseyapi.tech/v1/chat/completions
curl https://odysseyapi.tech/v1/chat/completions \  -H "Authorization: Bearer $ODYSSEY_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "openai/gpt-5",    "messages": [      { "role": "system", "content": "You extract structured data. Reply with JSON only." },      { "role": "user", "content": "Halvard Freight AS, invoice HF-20931, total EUR 4812.50." }    ],    "response_format": { "type": "json_object" },    "max_tokens": 512,    "temperature": 0.2  }'

Request body

ParameterDescription
modelRequiredA model id from the catalog, such as openai/gpt-5.
messagesRequiredThe conversation so far, oldest first.
max_tokensUpper bound on generated tokens. Capped at the model's max_output.
temperature0 to 2. Lower is more deterministic. Defaults to 1.
top_pNucleus sampling cutoff, 0 to 1. Defaults to 1.
streamReturn server-sent events instead of one response body.
stopUp to four sequences that end generation.
response_formatSet { "type": "json_object" } to constrain output to valid JSON.
toolsFunction definitions the model may call.
tool_choice"auto", "none", or a specific function to force.
seedRequests reproducible sampling where the model supports it.

Messages

Each message has a role of system, user, assistant or tool, and a content string. A system message sets behaviour for the whole conversation and is best kept first.

For vision models, content may be an array of parts, each either { "type": "text", "text": "..." } or { "type": "image_url", "image_url": { "url": "..." } }. Images can be public URLs or data URIs.

Tools

Tool definitions are passed through unchanged to models that support them. The response then contains tool_calls and a finish_reason of tool_calls; run the function yourself and send the result back as a message with role tool.

{  "model": "anthropic/claude-sonnet-5",  "messages": [{ "role": "user", "content": "What is the status of order 5512?" }],  "tools": [    {      "type": "function",      "function": {        "name": "get_order",        "description": "Look up an order by id.",        "parameters": {          "type": "object",          "properties": { "order_id": { "type": "string" } },          "required": ["order_id"]        }      }    }  ],  "tool_choice": "auto"}

Response

{  "id": "chatcmpl-2c9f41a7bd0e6835ca7f1d92",  "object": "chat.completion",  "created": 1789134913,  "model": "openai/gpt-5",  "choices": [    {      "index": 0,      "message": {        "role": "assistant",        "content": "{\"vendor\":\"Halvard Freight AS\",\"invoice_number\":\"HF-20931\"}"      },      "finish_reason": "stop"    }  ],  "usage": { "prompt_tokens": 64, "completion_tokens": 41, "total_tokens": 105 }}

usage is the token count you are billed for. The x-request-id response header identifies the request in Activity, where its status, timing and cost are recorded.

finish_reason is stop when the model finished, length when it hit max_tokens, and tool_calls when it wants a function result.