API
Chat Completions
Use the OpenAI-compatible Chat Completions API for text, vision, tools, and streaming.
Overview
Chat Completions is the primary endpoint for conversational model calls. It accepts a list of `messages` and returns an assistant response. When `stream` is `true`, output is delivered as Server-Sent Events.
Request
`POST https://uouo.cloud/v1/chat/completions`
Headers
| Header | Required | Description |
|---|---|---|
| Authorization | Yes | `Bearer $UOUODUO_API_KEY` |
| Content-Type | Yes | `application/json` |
Body parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| model | string | Yes | - | Model ID, for example `gpt-4o-mini`. |
| messages | array | Yes | - | Conversation messages. |
| temperature | number | No | 1 | Sampling temperature from 0 to 2. |
| top_p | number | No | 1 | Nucleus sampling value from 0 to 1. |
| stream | boolean | No | false | Return SSE chunks when true. |
| max_tokens | integer | No | - | Legacy maximum output token field. |
| max_completion_tokens | integer | No | - | Maximum generated tokens. |
| tools | array | No | - | Function/tool definitions. |
| tool_choice | string or object | No | `auto` | Controls tool selection. |
| response_format | object | No | - | JSON object or schema output constraints. |
| user | string | No | - | End-user identifier for audit and abuse prevention. |
Example
curl https://uouo.cloud/v1/chat/completions \
-H "Authorization: Bearer $UOUODUO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [
{ "role": "system", "content": "You are a concise production assistant." },
{ "role": "user", "content": "Summarize the release risk in three bullets." }
]
}'Streaming
Set `"stream": true` to receive `text/event-stream` chunks:
data: {"id":"chatcmpl_abc","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"First"},"finish_reason":null}]}
data: {"id":"chatcmpl_abc","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":" point"},"finish_reason":null}]}
data: [DONE]If `stream_options.include_usage` is enabled, the final chunk may include usage. Network interruptions can prevent the final usage chunk from arriving, so use console logs as the billing source of truth.
Response fields
| Field | Type | Description |
|---|---|---|
| id | string | Completion ID. |
| object | string | Usually `chat.completion`. |
| created | integer | Unix timestamp. |
| model | string | Model used by the route. |
| choices | array | Candidate responses. |
| usage | object | Prompt, completion, and total token counts. |
Errors
| HTTP | Code | Meaning | Suggested action |
|---|---|---|---|
| 400 | invalid_request_error | Invalid body or parameter range. | Validate the request schema. |
| 401 | unauthorized | Missing or invalid API key. | Create or rotate a key in `/app/keys`. |
| 403 | forbidden | Key or account cannot access the model. | Check model access and workspace policy. |
| 429 | rate_limit_exceeded | Rate limit, quota, or balance issue. | Review usage and retry with backoff. |
| 500 | internal_error | Gateway or upstream failure. | Record request ID and check status. |
Notes
- Vision input requires a model that supports image content parts.
- Tool call arguments should be validated by your server before execution.
- Provider support for `seed`, `reasoning_effort`, and structured output can vary.
- Control cost with `max_completion_tokens` and monitor `/app/usage`.