Skip to main content
POST
Create chat completion

Thân Yêu Cầu

string
bắt buộc
ID mô hình để sử dụng (ví dụ: gpt-4o, claude-3.5-sonnet, gemini-2.0-flash).
array
bắt buộc
Danh sách tin nhắn tạo thành cuộc hội thoại.
boolean
mặc định:false
Nếu true, trả về luồng Server-Sent Events (SSE).
number
mặc định:1
Nhiệt độ lấy mẫu từ 0 đến 2. Giá trị thấp hơn cho kết quả xác định hơn.
integer
Số lượng token tối đa để tạo.
number
mặc định:1
Tham số lấy mẫu nucleus.
string | string[]
Chuỗi dừng sẽ ngừng việc tạo.
number
mặc định:0
Hình phạt tần suất token (-2.0 đến 2.0).
number
mặc định:0
Hình phạt sự hiện diện token (-2.0 đến 2.0).
array
Danh sách công cụ mà mô hình có thể gọi (function calling).
string | object
Kiểm soát công cụ nào được gọi. auto, none hoặc một công cụ cụ thể.
object
Buộc định dạng đầu ra cụ thể (ví dụ: {"type": "json_object"}).
integer
Seed lấy mẫu xác định để tái tạo kết quả.

Phần Mở Rộng OpenModex

object
Cấu hình định tuyến thông minh cho yêu cầu này.
object
Cấu hình bộ nhớ đệm prompt.

Phản Hồi

Ví Dụ

Ủy quyền

Authorization
string
header
bắt buộc

API key authentication. Pass your OpenModex API key as a Bearer token in the Authorization header: Authorization: Bearer omx_sk_...

Nội dung

application/json

Request body for creating a chat completion.

model
string
bắt buộc

ID of the model to use.

messages
object[]
bắt buộc

A list of messages comprising the conversation so far.

stream
boolean
mặc định:false

If true, partial message deltas will be sent as server-sent events.

temperature
number

Sampling temperature between 0 and 2. Higher values make output more random.

Phạm vi bắt buộc: 0 <= x <= 2
top_p
number

Nucleus sampling parameter. Only consider tokens with top_p probability mass.

n
integer

How many completions to generate for each prompt.

max_tokens
integer

The maximum number of tokens to generate in the completion.

stop

Up to 4 sequences where the API will stop generating further tokens.

frequency_penalty
number

Penalizes new tokens based on their existing frequency in the text so far.

Phạm vi bắt buộc: -2 <= x <= 2
presence_penalty
number

Penalizes new tokens based on whether they appear in the text so far.

Phạm vi bắt buộc: -2 <= x <= 2
logit_bias
object

Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

tools
object[]

A list of tools the model may call.

tool_choice

Controls which tool is called by the model. Can be 'none', 'auto', 'required', or a specific tool object.

response_format
object

An object specifying the format the model must output (e.g., {"type": "json_object"}).

seed
integer

If specified, the system will attempt to sample deterministically.

user
string

A unique identifier representing your end-user, for abuse monitoring.

routing
object

Configuration for intelligent request routing.

cache
object

Configuration for response caching.

Phản hồi

Chat completion response. When stream=true, returns SSE stream of ChatCompletionChunk objects.

Response from a chat completion request.

id
string

A unique identifier for the completion.

object
enum<string>

The object type, always 'chat.completion'.

Tùy chọn có sẵn:
chat.completion
created
integer

Unix timestamp (in seconds) of when the completion was created.

model
string

The model used for the completion.

choices
object[]

A list of completion choices.

usage
object

Token usage statistics for a completion request.

system_fingerprint
string

A fingerprint representing the backend configuration.

openmodex
object

OpenModex-specific metadata included in completion responses.