OpenAI format
Create chat completions compatible with the OpenAI Chat Completions protocol, supporting streaming and non-streaming responses
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 theAuthorization header in the format Bearer YOUR_API_KEY.
Quick example
Headers
"Bearer YOUR_API_KEY"
"application/json"
Body
Model ID, e.g. gpt-4o, deepseek-chat, etc.
List of messages
Streaming response options (only used when stream=true)
Nucleus sampling, between 0 and 1
Maximum number of tokens to generate (deprecated, use max_completion_tokens instead)
Maximum number of tokens to generate (including visible output tokens and reasoning tokens)
Frequency penalty, -2.0 to 2.0
Presence penalty, -2.0 to 2.0
Map to modify the likelihood of specified tokens appearing
Maximum number of most likely tokens to return at each token position (0-20)
Response format, supports "text", "json_object", "json_schema"
Stable identifier for cache optimization
Cache retention policy: "in_memory" or "24h"
Safety identifier for detecting violating users
Controls which tool the model calls, can be a string ("none"/"auto"/"required") or an object
Whether to enable parallel tool calls
Service tier: "auto", "default", "flex", "scale", "priority"
Reasoning effort level: "none", "minimal", "low", "medium", "high", "xhigh"
Web search options
Deprecated: function call control
Whether to enable streaming output
Sampling temperature, between 0 and 2, higher values produce more random output
Stop sequences
Number of chat completion choices to generate for each input message
Whether to return log probabilities of output tokens
Seed value for deterministic sampling
User identifier (deprecated, use prompt_cache_key instead)
List of tools the model can call
Output type list: ["text"] or ["text", "audio"]
Audio output parameters
Metadata, up to 16 key-value pairs
Predicted output content
Response verbosity: "low", "medium", "high"
Deprecated: list of function definitions
Response
OpenAI Chat Completions API response object
System fingerprint, representing backend configuration
Actual service tier used
Unique identifier for the chat completion
Object type, always "chat.completion"
Creation time (Unix timestamp)
Model ID used
List of chat completion choices
Usage statistics