OpenAI 對話格式
OpenAI-compatible Chat Completions for standard multi-turn chat, structured output, and tool calling. Model names use the provider/model-name format, for example openai/gpt-4o. Image-capable models can also return generated images through this endpoint.
chat/completions 操作,上方 playground 已預先填入通用對話結構。以下說明如何從相容 OpenAI 的用戶端,透過這個端點請求由 Gemini 驅動的圖像生成。
model 中指定圖像生成模型(例如 gemini-2.0-flash-preview-image-generation),依需求設定 stream,並透過 messages 提供 prompt。你也可以選擇加入 contents,搭配 messages 提供額外的 Gemini 風格多模態上下文。供應商特定說明
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
model | string | 是 | 圖像生成模型識別碼,例如 gemini-2.0-flash-preview-image-generation。 |
messages[].content | string | 是 | 描述目標圖像的 prompt 文字。 |
contents | array | 否 | 額外多模態上下文的 Gemini 風格內容陣列,並非標準 OpenAI 對話結構的一部分。 |
範例:請求圖像
回應欄位
回應遵循標準 chat completions 結構。生成圖像會直接嵌入在 assistant 訊息內容中:回應範例
授權
Your DGrid API key. All endpoints use Authorization: Bearer <DGRID_API_KEY>.
主體
Target model ID in provider/model-name format.
"openai/gpt-4o"
Conversation message list.
Sampling temperature.
Nucleus sampling value.
Number of choices to generate.
Enable SSE streaming.
Maximum token count.
Max completion-only tokens.
Presence penalty.
Frequency penalty.
Token bias configuration.
Stop sequence string or array.
Tool definitions.
Tool selection behavior. Defaults to auto.
Response schema or JSON mode config.
Deterministic seed.
End-user identifier.

