Create a chat completion

Send a conversation and receive Olive's reply, together with the clinical reasoning that produced it.

POST/chat/completions

Send a conversation and receive Olive's reply, together with the clinical reasoning that produced it.

This is the endpoint every OpenAI SDK calls for client.chat.completions.create. The request and response bodies follow the OpenAI Chat Completions contract, with one addition: the assistant message carries a reasoning_content field alongside content, holding Olive's working-out as prose you can display, log, or discard.

Reasoning tokens are billed against max_tokens alongside the answer. If the budget runs out while Olive is still reasoning, the response comes back with finish_reason: "length" and an empty content. When you set max_tokens, leave room for both, or leave it unset, in which case Olive generates up to 16384 tokens. Set reasoning_effort to give Olive a smaller or larger thinking budget.

To ask about a document, upload it with POST /files and put its id in a file content part. Olive reads the file's text, and that text counts as input tokens, so the files and the conversation together must fit the 65536-token context window. Inline file bytes and image_url parts are refused with 400.

Set stream: true to receive the answer as server-sent events. Olive always attaches the final usage totals to the last chunk of a stream, so you never need a second request to record token counts.

Authorization

BearerAuth
AuthorizationBearer <token>

Your Avey API key, sent as Authorization: Bearer <key>. This is the header the OpenAI SDKs already send, so pass the key as the client's ordinary api_key and no further configuration is needed.

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

The body of a chat completion request. Unlisted OpenAI fields are not part of Avey's documented surface. See OpenAI compatibility.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl https://api.avey.ai/llm/chat/completions \  -H "Authorization: Bearer $AVEY_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "olive",    "messages": [      { "role": "user", "content": "What are the red flags for headache in primary care?" }    ]  }'
{  "id": "chatcmpl-9f2c1b7e4a5d4f0e8b1c3d2a6f7e5b90",  "object": "chat.completion",  "created": 1769904000,  "model": "olive",  "choices": [    {      "index": 0,      "finish_reason": "stop",      "message": {        "role": "assistant",        "content": "Sudden-onset \"thunderclap\" headache, new headache over age 50, and headache with fever and neck stiffness all warrant urgent assessment.",        "reasoning_content": "The question asks for red flags, so the useful frame is which features shift the pre-test probability toward a secondary cause rather than a primary headache disorder."      }    }  ],  "usage": {    "prompt_tokens": 38,    "completion_tokens": 274,    "total_tokens": 312  }}