BazaarLinkBazaarLink
登入
文件API 參考SDK 參考Agent 應用AI Skills
決策

送出決策請求

使用輸出 decisions 的模型,依具名問題評估 state。此 alpha 端點回傳非串流 JSON。透過 GET /v1/models?output_modalities=decisions 查詢可用模型識別碼;Clef 請使用此端點。輸入 tokens 按所選模型的客戶單價計費,帳戶須有足夠餘額。請先將 API 金鑰設於 BAZAARLINK_API_KEY;範例會在 BAZAARLINK_AUTH_HEADER 組成完整的 Authorization 標頭。

POST/v1/alpha/decisions

驗證

Authorization必填
string · header

在 Authorization 標頭以 Bearer token 傳入 API 金鑰。

Body

model必填
string

取自 /v1/models?output_modalities=decisions 的可用模型識別碼。

Example: "cloudflare/clef-flash"
state必填
JSON string | object | array

要評估的證據,可使用字串、JSON 物件或陣列;結構化內容部分會保留。圖片解讀依所選模型支援的 state 格式而定;若圖片計入 tokens,將包含在 input_tokens 中計費。

images
string[]

選填的內嵌圖片,每次請求最多 4 張:PNG、JPEG 或 WebP,使用 data URI 或純 base64,每張最多 4 MiB、合計最多 8 MiB。不接受遠端網址。圖片會加入 state 供模型判讀,input_tokens 含圖片 tokens。圖片格式不支援或內容無效時回傳 400 invalid_images。

questions必填
record<string, Question>

具名問題;每個答案的鍵值均對應原本的問題識別碼。

type必填
string

noul 以數值表達是非決策;choice 選擇一個選項;score 回傳數值分數。

noulchoicescore
instructions必填
JSON string | object | array

說明此問題應如何判斷的指示。

criteria
record<string, JSON> | JSON[]

noul 可選填 true/false 判斷準則。choice 必須提供選項對應準則的物件,選項準則可為 null。score 必須提供至少一項準則的有序陣列。

stream
boolean

省略此欄位或設為 false;串流請求會收到 HTTP 400。

false

深度指南 →

POST /v1/alpha/decisions
export BAZAARLINK_AUTH_HEADER="Authorization: $(printf '%s %s' 'Bearer' "$BAZAARLINK_API_KEY")"

curl https://api.bazaarlink.ai/v1/alpha/decisions \
  -H "$BAZAARLINK_AUTH_HEADER" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "cloudflare/clef-flash",
    "state": "The support agent issued a full refund.",
    "questions": {
      "refunded": {
        "type": "noul",
        "instructions": "Was a refund issued?"
      }
    }
  }'
回應範例

成功。answers 回傳每題的型別化結果;confidence、probabilities 與 score 的 legend 欄位依模型而定。usage.input_tokens 包含全部計入的輸入 tokens,usage.output_tokens 表示輸出 tokens。usage.cost 為本次向客戶收取的美元金額。id 是 BazaarLink 的不透明請求識別碼,與 x-request-id、x-generation-id 相同。以此 id 呼叫 GET /v1/generation?id=ID 回讀已保存的客戶用量;用量紀錄寫入期間若收到 404,可短暫重試。

{
  "id": "85e6f35c71a31f19-SJC",
  "model": "cloudflare/clef-flash",
  "answers": {
    "refunded": {
      "type": "noul",
      "noul": 0.99
    }
  },
  "usage": {
    "input_tokens": 64,
    "output_tokens": 1,
    "cost": 0.000007
  }
}
客服
客服
您好!有什麼可以協助?
請留下訊息,我們會盡快回覆。
送出決策請求 — BazaarLink API