Skip to main content
POST

Authorizations

string
required
API key in Bearer Token formatGet the API key:Visit the API Key management page to get your API key

Body

string
required
Model nameOpenAI compatible models (recommended for tool calls):
  • gpt-4o-mini — lightweight and fast, suitable for high-frequency simple tasks
  • gpt-4o — general recommendation, balanced performance and cost
  • gpt-5.2 — high-performance version, full support for tool calls
  • For more models, please refer to GET /api/v1/models
Claude models (Anthropic protocol forwarding):
  • claude-haiku-4-5-20251001 — lightweight and fast
  • claude-sonnet-4-5-20250929 — general recommendation
  • claude-sonnet-4-6 — new Sonnet version
  • claude-opus-4-5-20251101 — flagship inference model
  • claude-opus-4-6 — new Opus version, most powerful
For complete model list, please refer to: GET /api/v1/models
array
required
Message listThe model generates the next reply based on the message history. Each message includes role and content.Plain text message:
Multi-turn conversation:
Multi-turn tool calls:
integer
Maximum output token countControls the maximum number of tokens the model can generate; the model may naturally stop before reaching the limit. Minimum value: 1. No limit by default (subject to model context window constraints).
integer
Maximum output token count (new name for max_tokens)Equivalent to max_tokens; provide either one, with max_tokens having higher priority.
boolean
Whether to enable streaming outputWhen set to true, responses are streamed in real-time via SSE (Server-Sent Events). Default is true. To disable streaming, explicitly pass "stream": false.When set to false, the full response is returned after generation completes.
number
Temperature, range 0–2
  • Low values (e.g., 0.2): more deterministic, conservative output
  • High values (e.g., 0.8): more random, creative output
Default is 1.0. Not recommended to use with top_p simultaneously.
number
Nucleus sampling parameter, range 0–1Samples from tokens with cumulative probability up to top_p. Default is 1.0. Not recommended to use with temperature simultaneously.
number
Frequency penalty, range -2.0–2.0Positive values penalize tokens appearing frequently in generated text, reducing repetition. Default is 0.
number
Presence penalty, range -2.0–2.0Positive values penalize tokens that have appeared before, encouraging the model to explore new topics. Default is 0.
integer
Random seedWhen set, the same seed plus identical request parameters will attempt to produce deterministic output for reproducibility.
string | array
Stop sequencesThe model will immediately stop generation upon encountering this string (or any string in the array). Up to 4 allowed.
array
Tool definitions listDefines function tools callable by the model, each with a name, description, and parameter JSON Schema.
string | object
Tool selection policy
  • "auto" — the model decides whether to call tools (default)
  • "required" — force the model to call a tool
  • "none" — prohibit calling any tools
  • {"type": "function", "function": {"name": "get_weather"}} — force call a specified tool
boolean
Whether to allow parallel tool callsWhen set to false, only one tool is called at a time. Default is true (allow parallel calls).
object
Response formatControls the model’s output format.JSON object mode:
JSON Schema mode:
string
Reasoning effortApplicable to models that support reasoning (such as gpt-5.2 and above), controls the depth of model reasoning.
  • "low" — fast reasoning, saves tokens
  • "medium" — balanced reasoning
  • "high" — deep reasoning, more accurate but consumes more tokens

Response

string
Completion unique identifierExample: "chatcmpl-9vKqnMf3Ax8ZpRdTw2LsYe7b"
string
Object type, fixed to "chat.completion" (non-streaming) or "chat.completion.chunk" (streaming)
integer
Creation time, Unix timestamp (seconds)
string
Model name passed in the request
string
Billing task ID (project extension field), used to track the credit consumption record for this call
array
Array of generated results (always only 1 item)
object
Token usage statistics (in non-streaming at the top-level of the response, in streaming in the final frame)

Usage Examples

Basic Conversation

System Prompt + Multi-turn Conversation

Streaming Response

Tool Invocation (Complete Multi-turn Flow)

Structured Output (JSON Schema)

Sampling Parameter Control

Streaming Response Event Format

Tool Call Streaming Events:

Notes

  1. Authorization method: Only supports the format Authorization: Bearer <api_key>. When using the OpenAI SDK, simply set the api_key.
  2. Streaming by default: The stream parameter defaults to true. For non-streaming responses, explicitly pass "stream": false.
  3. Insufficient balance: Returns HTTP 402 when the balance is insufficient. Please recharge and try again.
  4. stop and stop sequences: The stop parameter is currently ineffective. The underlying providers do not support this feature yet; passing the parameter will not cause errors but will not stop generation at specified sequences.
  5. Note on response_format: Current underlying providers have limited support for response_format—in json_object mode, the model may still output Markdown code blocks instead of pure JSON; in json_schema mode, the schema constraints may not be enforced. For structured output, it is recommended to clearly specify the required format in the prompt.
  6. Tool parameters: The parameters field must be a valid JSON Schema, and the required array determines which parameters are mandatory.
  7. Model selection recommendations:
    • Haiku — high-frequency simple Q&A, lowest cost
    • Sonnet — code generation, document processing, generally recommended
    • Opus — complex reasoning, long text analysis, strongest capabilities
    • -thinking series — for scenarios requiring deep thinking such as mathematical proofs and logical deductions