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:
| Field | Type | Description |
|---|---|---|
model | string | Required. FunAI model ID (e.g. gpt-4o-mini, gemini-2-5-flash). |
messages | array | Required. Array of message objects. |
messages[].role | string | system, user, assistant, or tool. |
messages[].content | string or array | Text, or array of content parts for multimodal (see below). |
temperature | number | 0–2. Default 1.0. |
max_tokens | integer | Max tokens to generate. |
top_p | number | Nucleus sampling. Default 1.0. |
frequency_penalty | number | -2 to 2. Default 0. |
presence_penalty | number | -2 to 2. Default 0. |
stop | string or array | Stop sequences. |
n | integer | Number of completions. Default 1. |
stream | boolean | If true, server-sent events. Default false. |
response_format | object | e.g. { "type": "json_object" } for structured output. |
chat_id | string | Optional (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:
| Field | Type | Description |
|---|---|---|
id | string | Request ID. |
object | string | "chat.completion". |
created | integer | Unix timestamp. |
model | string | Model ID used. |
choices | array | Array of choice objects. |
choices[].index | integer | Index. |
choices[].message | object | role, content. |
choices[].finish_reason | string | e.g. "stop", "length". |
usage | object | prompt_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)
| Field | Type | Description |
|---|---|---|
model | string | FunAI image model ID (e.g. gpt-image-1). |
prompt | string | Required. Description of the image. |
n | integer | Number of images. Default 1. |
size | string | e.g. "1024x1024", "1792x1024". |
response_format | string | "url" or "b64_json". Default "url". |
quality | string | e.g. "standard", "hd". |
style | string | Optional. |
Response body (returned)
| Field | Type | Description |
|---|---|---|
created | integer | Unix timestamp. |
data | array | List of image objects. |
data[].url | string | Image URL (when response_format is "url"). |
data[].b64_json | string | Base64 image (when response_format is "b64_json"). |
data[].revised_prompt | string | Optional. |
Same structure as the OpenAI Images response.
Compatibility summary
| Area | Status | Notes |
|---|---|---|
Chat request (messages, model, params) | Compatible | We accept string or array content for vision. |
Chat response (id, object, choices, usage) | Compatible | Same shape as OpenAI. |
Images request (prompt, n, size, response_format) | Compatible | Same field names and types. |
Images response (created, data[]) | Compatible | Same shape. |
| Streaming (SSE) | Compatible | Same chunk format as OpenAI. |
| Extras | Supported | chat_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.