OpenAI compatibility
The chat and image endpoints are OpenAI-compatible, so OpenAI SDKs and tools (LangChain and others) work with a base URL and key change.
Base URL
https://api.funai.art/v1
Point any OpenAI SDK or OpenAI-compatible tool at this base URL with your FunAI API
key. (The older base URL https://api.funai.art/generation/v1 still works for chat,
completions and images.)
What we support
| OpenAI API | Our endpoint | Notes |
|---|---|---|
| Chat Completions | POST /v1/chat/completions | Streaming, vision, response_format |
| Images | POST /v1/images/generations | |
| Completions (legacy) | POST /v1/completions | |
| Models | GET /v1/models, GET /v1/models/{id} | Public: no key needed |
| Videos | POST /v1/videos, GET /v1/videos/{id}, GET /v1/videos/{id}/content, DELETE /v1/videos/{id} | Async video jobs |
| Model lists by kind | GET /v1/images/models, GET /v1/videos/models | Public |
We accept the same parameter names and types as the OpenAI API and return the same top-level shape (e.g. id, object, created, model, choices, usage for chat).
Using the OpenAI SDK
Set base_url to https://api.funai.art/v1:
from openai import OpenAI
client = OpenAI(
base_url="https://api.funai.art/v1",
api_key="YOUR_FUNAI_API_KEY"
)
# Chat
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello"}],
stream=False
)
# Images
response = client.images.generate(
model="gpt-image-1",
prompt="A cat",
n=1,
size="1024x1024"
)
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.funai.art/v1',
apiKey: 'YOUR_FUNAI_API_KEY'
});
const completion = await client.chat.completions.create({
model: 'gpt-4o-mini',
messages: [{ role: 'user', content: 'Hello' }]
});
Extensions we accept
- Chat: Optional
chat_idin the request body for conversation context (we persist and reuse history). - Chat: Optional
response_formatfor structured outputs (e.g.{ "type": "json_object" }).
Cost on every response
Chat responses include the cost in usage: usage.cost (USD), usage.credits_charged,
usage.usd_equivalent and usage.billing_wallet ("api" or "platform": which
balance paid). Image and video responses carry the same fields at the top level. See
Pricing & balance.
Differences / notes
- Model names: Use FunAI model IDs (
GET /v1/modelslists them). A model ID may be served by different upstream providers (OpenAI, Gemini, etc.). - Images: We accept
prompt,n,size,response_format,quality,styleas in the OpenAI Images API. - Streaming: Chat supports
stream: true; responses use SSE in the same format as OpenAI. - Errors: OpenAI error shape,
{"error": {"message", "type", "code", "param", "request_id"}}. See Errors.
For exact request/response fields, see Request/response bodies.