Skip to main content
POST
Create chat completion
This endpoint is compatible with the OpenAI Chat Completions protocol for creating chat completion requests.

Features

  • Supports both streaming (SSE) and non-streaming response modes
  • Supports multimodal input (text, images, etc.)
  • Supports function calling and tool calling
  • Supports structured output (JSON Schema)
  • Supports reasoning effort configuration
  • Supports web search options

Use cases

Suitable for scenarios requiring interaction with OpenAI-compatible models, including:
  • Single-turn or multi-turn conversations
  • Function calling and tool orchestration
  • Structured JSON output
  • Real-time streaming responses

Authentication

Include the Authorization header in the format Bearer YOUR_API_KEY.
Never expose API keys in client-side code. Use a server-side proxy to forward requests.

Quick example

Headers

Authorization
string
required
Example:

"Bearer YOUR_API_KEY"

Content-Type
string
Example:

"application/json"

Body

application/json
model
string
required

Model ID, e.g. gpt-4o, deepseek-chat, etc.

messages
object[]
required

List of messages

stream_options
object

Streaming response options (only used when stream=true)

top_p
number

Nucleus sampling, between 0 and 1

max_tokens
integer

Maximum number of tokens to generate (deprecated, use max_completion_tokens instead)

max_completion_tokens
integer

Maximum number of tokens to generate (including visible output tokens and reasoning tokens)

frequency_penalty
number

Frequency penalty, -2.0 to 2.0

presence_penalty
number

Presence penalty, -2.0 to 2.0

logit_bias
object

Map to modify the likelihood of specified tokens appearing

top_logprobs
integer

Maximum number of most likely tokens to return at each token position (0-20)

response_format
object

Response format, supports "text", "json_object", "json_schema"

prompt_cache_key
string

Stable identifier for cache optimization

prompt_cache_retention
string

Cache retention policy: "in_memory" or "24h"

safety_identifier
string

Safety identifier for detecting violating users

tool_choice
object

Controls which tool the model calls, can be a string ("none"/"auto"/"required") or an object

parallel_tool_calls
boolean

Whether to enable parallel tool calls

service_tier
string

Service tier: "auto", "default", "flex", "scale", "priority"

reasoning_effort
string

Reasoning effort level: "none", "minimal", "low", "medium", "high", "xhigh"

web_search_options
object

Web search options

function_call
object

Deprecated: function call control

stream
boolean

Whether to enable streaming output

temperature
number

Sampling temperature, between 0 and 2, higher values produce more random output

stop
object

Stop sequences

n
integer

Number of chat completion choices to generate for each input message

logprobs
boolean

Whether to return log probabilities of output tokens

seed
integer<int64>

Seed value for deterministic sampling

user
string

User identifier (deprecated, use prompt_cache_key instead)

tools
object[]

List of tools the model can call

modalities
string[]

Output type list: ["text"] or ["text", "audio"]

audio
object

Audio output parameters

metadata
object

Metadata, up to 16 key-value pairs

prediction
object

Predicted output content

verbosity
string

Response verbosity: "low", "medium", "high"

functions
object[]

Deprecated: list of function definitions

Response

200 - application/json

OpenAI Chat Completions API response object

system_fingerprint
string

System fingerprint, representing backend configuration

service_tier
string

Actual service tier used

id
string

Unique identifier for the chat completion

object
string

Object type, always "chat.completion"

created
integer<int64>

Creation time (Unix timestamp)

model
string

Model ID used

choices
object[]

List of chat completion choices

usage
object

Usage statistics