Skip to main content

Quick Start

The Oxen.ai chat completions API is fully OpenAI-compatible. You can use the OpenAI SDK, curl, or any HTTP client that speaks the OpenAI chat format. Base URL: https://hub.oxen.ai/api/ai Endpoint: POST /ai/chat/completions Browse all available models.

Authentication

Every request requires a Bearer token in the Authorization header. You can find your API key in your account settings.
API key

Response Format

The API returns an OpenAI-compatible JSON response:

Parameters

Messages

Each message in the messages array has a role and content:

Streaming

Set "stream": true to receive responses as server-sent events (SSE). Each event is a chat.completion.chunk object with a delta instead of a message.
Each SSE line is prefixed with data: and contains a JSON chunk:
The stream ends with:

Vision

Models that support vision (such as gemini-3-1-pro-preview or claude-sonnet-4-6) accept images in the messages array. For full details and examples including base64 encoding and video understanding, see Vision Language Models.

Documents (PDFs)

Attach a document with a file content part. Place the document before the text part for the best results. Pass the file inline as a base64 data URL in file.file_data:
You can also reference a document by URL (handy for files generated in a workspace) by passing it in file.file_url. Pass exactly one of file_data (a base64 data URL) or file_url; the URL must be publicly accessible (and unexpired, if presigned).
Only application/pdf is supported, and a document must be 24 MB or smaller; other inputs return a 400. Referencing files by OpenAI file_id is not supported. Inline the file with file_data or pass file_url.

Audio

Attach audio with an audio_url content part to a model that supports audio input (such as gemini-3-1-pro-preview). Place the audio part before the text part for the best results.
To send a local file, base64-encode it into a data: URL and pass it as the audio_url:
Python (OpenAI SDK)
The URL must be publicly accessible (and unexpired, if presigned). Audio must be 20 MB or smaller; larger files return a 400. Supported formats vary by provider: OpenAI audio models (e.g. gpt-audio) accept only wav and mp3, while Gemini models (e.g. gemini-3-1-pro-preview) additionally accept m4a, aac, ogg, and flac.

Tool use

Tool calling (function calling) follows the same OpenAI Chat Completions tool format. You send a tools array describing each function’s JSON Schema; the model may reply with tool_calls instead of plain text. You execute those functions in your app, then send the results back in new tool messages so the model can finish the answer.

Raw curl: first request (tools only)

The model may respond with tool_calls instead of user-facing content:
Example assistant payload (abbreviated):
Run your function locally, then call the API again with the full transcript: original messages, the assistant message including tool_calls, and one tool message per call. Replace IDs and tool_calls with values from the first response. Repeat until finish_reason is "stop" (or "length") and there are no new tool_calls.

Follow-up request: curl and OpenAI Python SDK

The follow-up HTTP body matches what the OpenAI SDK builds when you append assistant and tool messages in a loop.

Errors

The API returns errors as JSON with an error object and a standard HTTP status code.