Skip to main content

Request and response bodies (OpenAI compatibility)

This page documents the exact request and response shapes for our OpenAI-compatible endpoints so you can verify compatibility with your client.


Chat completions​

Endpoint: POST /v1/chat/completions
OpenAI reference: Create chat completion

Request body (accepted)​

We accept the same fields as the OpenAI API:

FieldTypeDescription
modelstringRequired. FunAI model ID (e.g. gpt-4o-mini, gemini-2-5-flash).
messagesarrayRequired. Array of message objects.
messages[].rolestringsystem, user, assistant, or tool.
messages[].contentstring or arrayText, or array of content parts for multimodal (see below).
temperaturenumber0–2. Default 1.0.
max_tokensintegerMax tokens to generate.
top_pnumberNucleus sampling. Default 1.0.
frequency_penaltynumber-2 to 2. Default 0.
presence_penaltynumber-2 to 2. Default 0.
stopstring or arrayStop sequences.
nintegerNumber of completions. Default 1.
streambooleanIf true, server-sent events. Default false.
response_formatobjecte.g. { "type": "json_object" } for structured output.
chat_idstringOptional (platform). Conversation ID for context.

Multimodal (vision): messages[].content can be an array of parts, e.g.:

{
"role": "user",
"content": [
{ "type": "text", "text": "What is in this image?" },
{ "type": "image_url", "image_url": { "url": "https://..." } }
]
}

This structure is compatible with the OpenAI vision format.

Response body (returned)​

Same shape as OpenAI:

FieldTypeDescription
idstringRequest ID.
objectstring"chat.completion".
createdintegerUnix timestamp.
modelstringModel ID used.
choicesarrayArray of choice objects.
choices[].indexintegerIndex.
choices[].messageobjectrole, content.
choices[].finish_reasonstringe.g. "stop", "length".
usageobjectprompt_tokens, completion_tokens, total_tokens.

When stream: true, we return Server-Sent Events with the same chunk shape as OpenAI (data: {"choices": [{"delta": {...}}], ...}).


Images generations​

Endpoint: POST /v1/images/generations
OpenAI reference: Create image

Request body (accepted)​

FieldTypeDescription
modelstringFunAI image model ID (e.g. gpt-image-1).
promptstringRequired. Description of the image.
nintegerNumber of images. Default 1.
sizestringe.g. "1024x1024", "1792x1024".
response_formatstring"url" or "b64_json". Default "url".
qualitystringe.g. "standard", "hd".
stylestringOptional.

Response body (returned)​

FieldTypeDescription
createdintegerUnix timestamp.
dataarrayList of image objects.
data[].urlstringImage URL (when response_format is "url").
data[].b64_jsonstringBase64 image (when response_format is "b64_json").
data[].revised_promptstringOptional.

Same structure as the OpenAI Images response.​

Compatibility summary​

AreaStatusNotes
Chat request (messages, model, params)CompatibleWe accept string or array content for vision.
Chat response (id, object, choices, usage)CompatibleSame shape as OpenAI.
Images request (prompt, n, size, response_format)CompatibleSame field names and types.
Images response (created, data[])CompatibleSame shape.
Streaming (SSE)CompatibleSame chunk format as OpenAI.
ExtrasSupportedchat_id, FunAI model IDs.

These endpoints are kept aligned with the OpenAI API v1 specification, so existing OpenAI SDKs and tooling work against them with only a base_url and API key change.