Skip to main content
POST

Authorization

string
required
Bearer Token authentication. Format: Authorization: Bearer <api-key>Get API Key:Visit the API Key management page to get your API Key
string
Alternative authentication method, choose either this or Authorization. Format: x-api-key: <api-key>

Request Body Parameters

string
required
The name of the model to use. Examples: gpt-4o, gpt-5.4, gpt-5.5, etc.The full list of models can be obtained via GET /api/v1/models.
array
required
List of input contentsAn array of inputs, each containing the fields role and content. Supports multi-turn conversations and multi-modal content (text + images).
string
System Prompt. Used to set the model’s behavior guidelines, role identity, or context.Equivalent to a message in the array with role: "system".
boolean
default:"true"
Whether to enable streaming output.
  • true (default): returns tokens incrementally as SSE event stream, suitable for real-time display
  • false: returns the full response at once after completion, suitable for batch processing
integer
Maximum number of tokens to generate in the reply. If exceeded, the response status will be "incomplete", and incomplete_details.reason will be "max_output_tokens".
number
Sampling temperature, range 0 to 2. Higher values result in more random output, lower values more deterministic. Not recommended to adjust temperature and top_p simultaneously.
number
Nucleus sampling probability, range 0 to 1. The model samples only from tokens whose cumulative probability reaches top_p.
array
List of tools available for the model to call. Currently, only type: "function" is supported; built-in tools like web_search, file_search, computer_use are not supported.
string | object
default:"auto"
Tool calling policy:
  • "auto": model decides automatically whether to call tools
  • "none": prohibit calling tools
  • "required": force calling at least one tool
  • { "type": "function", "name": "function_name" }: force call the specified tool
boolean
default:"true"
Whether the model is allowed to call multiple tools in parallel. Only effective if tools are provided.
object
Output format control.
object
Reasoning mode configuration (applicable to models supporting reasoning, such as gpt-5.2 and above).

Response Fields

string
Unique response identifier, format: resp_ + 24-character random string
string
Fixed as "response"
number
Response creation time, Unix timestamp (seconds, with millisecond precision)
string
Response status:
  • "completed": Completed successfully
  • "incomplete": Cut off early due to max_output_tokens
  • "in_progress": Streaming output in progress (only in streaming events)
  • "failed": Generation failed
string
Actual model name used
string
Platform extension field. Billing task ID for this call, used for reconciliation and consumption queries.Note:
  • Non-streaming: task_id is located directly at the top level of the response JSON
  • Streaming: task_id is nested inside the response object of response.created (first event) and response.completed (last event). It needs to be parsed from the raw SSE event. The OpenAI SDK streaming interface does not automatically expose this field
array
Array of output items, which may contain two types: text messages and tool calls.
string
Shortcut field, equivalent to output[0].content[0].text (in plain text scenarios). Empty string in tool call scenarios.
object
Token usage statistics.
object | null
Not null when status is "incomplete".

Streaming Response Events

When stream: true, the API returns an SSE event stream in text/event-stream format. Each event has the following format:
All event payloads include a sequence_number field (incrementing from 0) to ensure clients process events in order.
Obtaining task_id: To get the billing task ID in streaming mode, listen for the first response.created event and read event.response.task_id.

Event Sequence (Text Response)

Event Sequence (Tool Invocation)

Event Examples


Usage Examples

Basic Text Conversation

Image Understanding

Tool Invocation

Structured Output (JSON Schema)

Reasoning Mode

Multi-turn Conversation

previous_response_id is currently ineffective; you need to manually concatenate historical messages in input:

Notes

  1. Streaming by Default: The stream parameter defaults to true. To receive a non-streaming response, explicitly pass "stream": false.
  2. Insufficient Credits: An HTTP 402 is returned when the balance is insufficient. Please recharge and try again.
  3. Limited Support for text.format: The underlying provider currently has limited support for structured output—models may still output Markdown code blocks instead of pure JSON in json_object mode; Schema constraints may not be enforced in json_schema mode. For structured output, it is recommended to clearly describe the required format in instructions or input.
  4. Tool Parameters: The parameters field must be a valid JSON Schema, and the required array specifies which parameters are mandatory.

Error Code Description