POST /v1/chat/completions is OpenAI-compatible. One request = one fast turn.
model— see Models. Unknown ids return 404model_not_found.messages—systemanddevelopermessages are hoisted and concatenated as agent context. Prior turns render as a transcript; the finalusermessage is the query. Text and{type:"file"}parts are supported;image_url/input_audioparts return 400.- Sampling parameters (
temperature,top_p, …) are accepted and ignored — the agent controls its own generation. tools/tool_choicereturn 400 in v1 (client-defined function calling is planned for v1.1).response_formatwithjson_schemais enforced natively; see below.nmust be 1.
Structured output
response_format supports text, json_object, and strict json_schema. RavChat appends a JSON-only instruction (and, for schemas, the exact schema) so ordinary prompts conform without client-side coaching.
Schema-invalid output is not silently retried (a retry would be a second charged turn) — the turn is charged and returns an error.
Statelessness, sessions, and auto-create
Chat completions is stateless by default: each request starts a fresh agent conversation in your key’s project. RavChat auto-creates whatever is missing:- No project bound/named → your key’s stable API project is created and reused (never a new project per request).
- No session named → a new session is created for the request.
x_ravchat), so the very first call needs zero setup.
Opt-in continuity — pass explicit hints to continue a live session with only your last message (requires sessions:write):
x_ravchat.created.session tells you.
Response
A standardchat.completion object — single choice, message.content, finish_reason (stop | length), usage — plus:
usage.cost— RavChat credits charged for the turn (billing-authoritative). Non-streaming responses also carry it in thex-ravchat-creditsheader.x_ravchat— the context block.
The x_ravchat block
files[] lists files the agent was observed producing during the turn (shown files and generated media — see Files for the exact promise). Download any of them via GET /v1/files/{id}/content.
The same ids are always available as response headers — x-ravchat-project-id, x-ravchat-session-id, x-ravchat-thread-id, x-ravchat-created-session, and more — which survive proxies that strip unknown body fields (e.g. LiteLLM).