Skip to main content
POST
Create chat completion

リクエストボディ

string
必須
使用するモデルID(例:gpt-4o、claude-3.5-sonnet、gemini-2.0-flash)。
array
必須
会話を構成するメッセージのリスト。
boolean
デフォルト:false
trueの場合、Server-Sent Events(SSE)のストリームを返します。
number
デフォルト:1
0から2の間のサンプリング温度。低い値はより決定論的になります。
integer
生成するトークンの最大数。
number
デフォルト:1
Nucleusサンプリングパラメータ。
string | string[]
生成を停止するストップシーケンス。
number
デフォルト:0
トークン頻度に対するペナルティ(-2.0から2.0)。
number
デフォルト:0
トークン存在に対するペナルティ(-2.0から2.0)。
array
モデルが呼び出す可能性のあるツールのリスト(Function Calling)。
string | object
どのツールを呼び出すかを制御します。auto、none、または特定のツール。
object
特定の出力形式を強制します(例:{"type": "json_object"})。
integer
再現性のための決定論的サンプリングシード。

OpenModex拡張

object
このリクエストのインテリジェントルーティングを設定します。
object
プロンプトキャッシュを設定します。

レスポンス

使用例

承認

Authorization
string
header
必須

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

ボディ

application/json

Request body for creating a chat completion.

model
string
必須

ID of the model to use.

messages
object[]
必須

A list of messages comprising the conversation so far.

stream
boolean
デフォルト: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.

必須範囲: 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.

必須範囲: -2 <= x <= 2
presence_penalty
number

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

必須範囲: -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.

レスポンス

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'.

利用可能なオプション:
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.