Endpoint
Request Parameters
Message Format
Each message has arole and content:
Vision (multimodal)
Use a content array to include images or video:Audio understanding
Send audio to a model that supports audio input with anaudio_url content
part:
400. Place the audio part before the
text part for the best results.
Supported formats vary by provider. OpenAI audio models (e.g.
gpt-audio)
accept only wav and mp3; an unsupported format returns a 400. Gemini models
(e.g. gemini-3-1-pro-preview) additionally accept m4a, aac, ogg, and
flac.Files and documents (PDFs)
Attach a document to a message with afile content part. Pass the file inline
as a base64 data URL
in file.file_data:
file_data (a base64 data URL) or file_url. The
URL must be publicly accessible (and unexpired, if presigned). A document must be
24 MB or smaller; larger files return a 400. Place the document before the text
part for the best results.
Supported file types:
application/pdf. Requesting an unsupported file type
returns a 400 error. Referencing files by OpenAI file_id is not supported.
Inline the file with file_data or pass file_url.Prompt caching
When several requests start with the same prompt prefix, Oxen can serve that prefix from its prompt cache instead of processing it again. Cache hits make long prompts faster. You don’t need extra parameters: send the same OpenAI-format request and caching happens upstream.
To get cache hits:
- Put stable content first. The system prompt, tool definitions, and any large documents or few-shot examples belong at the start of the request. Content that changes per request, such as the user’s question, goes last.
- Keep the prefix byte-identical. Any change to the prefix, even a timestamp in the system prompt or reordered tools, invalidates the cache from that point on.
- Use a plain string system message for Claude. The cache breakpoint is
added to the first system message when its
contentis a string. - Send requests close together. Cache entries expire after a few minutes of inactivity, depending on the provider.
Reading cache usage
When the provider reports cache activity,usage includes
prompt_tokens_details.cached_tokens: the number of prompt tokens served from
the cache. Cached tokens are already counted in prompt_tokens, so don’t add
them on top. Streaming responses report the same field in the final usage
chunk.
cost is the amount charged for the request, in currency.
If a response has no prompt_tokens_details, the provider didn’t report any
cache activity for that request.
Example
Send two requests that share a long system prompt and compare cache usage:Python
Examples
Basic text generation
Response
usage may also include prompt_tokens_details.cached_tokens. See
Prompt caching.
Analyze a PDF
Understand audio
data: URL:
Python
Streaming
delta instead of a full message:
Tool calling
finish_reason is "tool_calls":