Skip to content

補全

補全 API 提供經典 OpenAI 相容文字補全流程,適用於 prompt 導向生成與舊版整合場景。

原生 OpenAI 格式

若您的工作流只需要單一 prompt 文字生成,而不需要多輪 chat schema,請使用 completions 端點。

POST
https://api.dgrid.ai
POST/v1/completions
Authorization
Authorization: Bearer <DGRID_API_KEY>
Request
application/json
Response
200 · application/json

請求體

欄位型別必填預設值說明
modelstring-目標模型 ID。
promptstring 或 array-提示文字或提示陣列。
suffixstring-用於插入場景的後綴文字。
max_tokensinteger16最大補全長度。
temperaturenumber1採樣溫度。
top_pnumber1Nucleus sampling。
ninteger1回傳的補全數量。
streambooleanfalse是否串流。
logprobsinteger-返回 log probability 數量。
echobooleanfalse是否回傳原始 prompt。
stopstring 或 array-停止序列。
presence_penaltynumber0存在懲罰。
frequency_penaltynumber0頻率懲罰。
best_ofinteger1伺服器端挑選最佳結果數。
logit_biasobject-Token 偏置映射。
userstring-終端使用者識別。

回應體

欄位型別說明
idstringCompletion 識別碼。
objectstring固定為 text_completion
createdinteger建立時間戳。
modelstring用於生成的模型。
choicesarray補全結果列表。
choices[].textstring生成文字。
choices[].indexintegerchoice 索引。
choices[].logprobsobject 或 null若有要求時返回 log probability。
choices[].finish_reasonstring結束原因。
usageobjectToken 使用統計。