Skip to main content

Chat Completions

Our Chat Completions API allows you to access the world's most advanced Large Language Models (LLMs) through a single, unified interface. Change the model value to switch between makers such as OpenAI, Google and xAI.

Endpoint: POST /v1/chat/completions
OpenAI-compatible: Yes (Compatible with OpenAI Python & Node.js SDKs)

Request​

Usage Examples​

Python (OpenAI SDK)​

from openai import OpenAI

client = OpenAI(
api_key="YOUR_FUNAI_API_KEY",
base_url="https://api.funai.art/v1"
)

response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is FunAI Studio?"}
]
)

print(response.choices[0].message.content)

Node.js (OpenAI SDK)​

import OpenAI from 'openai';

const openai = new OpenAI({
apiKey: 'YOUR_FUNAI_API_KEY',
baseURL: 'https://api.funai.art/v1'
});

async function main() {
const completion = await openai.chat.completions.create({
messages: [{ role: 'user', content: 'Hello!' }],
model: 'gpt-4o-mini',
});

console.log(completion.choices[0].message.content);
}

main();

Optional platform extension: "chat_id": "<uuid>" to attach the request to an existing conversation.

Response​

Same shape as OpenAI chat completion: id, object, created, model, choices, usage. See Request/response bodies.

Streaming​

Set "stream": true. Response is Server-Sent Events (SSE) with the same chunk format as OpenAI.

Vision (multimodal)​

Send content as an array of parts:

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

We accept this format and pass it through to the provider; it is compatible with OpenAI vision.