Chat Completions
POST
https://api.oneinfer.ai/v1/ula/chat/completionsGenerate a chat completion from a conversation history using any supported LLM. Supports both streaming and non-streaming responses via a unified interface compatible with OpenAI, Anthropic, DeepSeek, and more.
Request headers
AuthorizationstringrequiredBearer token for authentication. Format:
Bearer <YOUR_TOKEN>. Exchange your API key for a token via the Authentication endpoint.Content-TypestringrequiredSet to application/json for all chat completion requests.
Request parameters
Core parameters
messagesarrayrequiredArray of message objects forming the conversation. Each object has a role ('system', 'user', 'assistant') and a content string.
modelstringThe model to use, by its catalog name (e.g. "openai/gpt-4o-mini", "anthropic/claude-sonnet-4.6"). OneInfer picks the provider that serves it; the response's
provider field says which one did. Use the GET Models endpoint to list the available models.Generation controls
temperaturenumberSampling temperature from 0 to 2. Higher values produce more creative outputs. Default: 0.7.
max_tokensintegerMaximum number of tokens to generate in the response. Default: 1000.
top_pnumberNucleus sampling parameter. Only tokens whose cumulative probability is within top_p are considered. Default: 1.0.
stopstring[]One or more sequences at which to stop generation. Optional.
streambooleanIf true, the response is streamed as Server-Sent Events (SSE). Default: false.
Advanced
endpoint_idstringID of a dedicated serverless endpoint to route this request to. Optional — omit for standard routing.
service_tierstringExecution priority tier. Options: "default" or "flex". Default: "default".
Example request: chat completion with streaming enabled
{
"model": "openai/gpt-4o-mini",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Tell me about AI."
}
],
"temperature": 0.7,
"max_tokens": 1000,
"stream": false
}Response
Response fields
idstringUnique request identifier.
createdintegerUnix timestamp of when the completion was created.
textstringThe generated assistant message content.
finish_reasonstringWhy generation stopped. E.g. "stop", "length".
providerstringThe provider that handled the request.
modelstringThe model that generated the response.
usageobjectToken usage: prompt_tokens, completion_tokens, total_tokens.
latency_msnumberEnd-to-end latency in milliseconds.
is_context_length_fullbooleanTrue if the context window was fully utilised.
application/json
200 OK
{
"api_details": {
"api_status": "success",
"api_message": "Chat completion generated successfully."
},
"data": {
"id": "req_abc123",
"created": 1711468800,
"text": "AI (Artificial Intelligence) refers to systems that simulate human intelligence...",
"finish_reason": "stop",
"provider": "openai",
"model": "gpt-4o-mini",
"usage": {
"prompt_tokens": 24,
"completion_tokens": 156,
"total_tokens": 180
},
"latency_ms": 1250,
"is_context_length_full": false
},
"error": {}
}Streaming responsestream: true
When stream: true, the server returns a stream of Server-Sent Events (SSE). Each event contains a JSON chunk with the incremental delta. The stream ends with data: [DONE].
text/event-stream
data: {"id":"chunk_1","text":"AI","finish_reason":null}
data: {"id":"chunk_2","text":" (Artificial","finish_reason":null}
data: {"id":"chunk_3","text":" Intelligence)","finish_reason":null}
data: {"id":"chunk_4","text":" refers to systems...","finish_reason":null}
data: {"id":"chunk_final","text":"","finish_reason":"stop"}
data: [DONE]Error status codes
| Code | Status | Description |
|---|---|---|
200 | OK | Completion returned successfully. |
400 | Bad Request | Invalid JSON body, missing required fields (messages), unsupported model, or invalid field values. |
401 | Unauthorized | Missing or invalid Authorization header / Bearer token. |
403 | Forbidden | Insufficient credit balance to process the request. |
415 | Unsupported Media Type | Content-Type must be application/json or multipart/form-data. |
422 | Unprocessable Entity | Request body failed schema validation. |
500 | Internal Server Error | Unexpected error during chat completion generation. |