TokenLab

文字

評估決策

使用原生決策模型評估命名機率、選擇和評分問題。

POST
/v1/systemone

將 state 和命名 questions 發送至決策模型。請使用 GET /v1/models?category=decision 查詢當前可用性,並使用 GET /v1/models/{model} 查詢其發布的合約。

Jev 有兩個版本:穩定版 jev-1.14(請求別名為 jev-latest 和 jev-preview)以及較早期的 jev-1.13。範例中使用的是 jev-1.13;請參閱 決策 (Decisions) 以了解如何選擇適合的版本。

state 以及每個問題的 instructions 均接受字串、JSON 物件或 JSON 陣列。此端點會回傳同步的 JSON。

問題類型準則結果
noul包含 true 和 false 指引的可選物件noul,一個 0 到 1 之間的機率值
choice包含 1–255 個選項名稱並映射至指引或 null 的物件choice,可選包含 probabilities 和 confidence
score包含 2–10 個描述的有序陣列從 0 到最後一個索引的 score;可以是小數,並可選包含 legend、probabilities 和 confidence

回應會在 answers 下保留您的問題名稱。usage.input_tokens 和 usage.output_tokens 會在可用時報告觀測到的使用量。定價來自模型的當前費率;免費輸出並不代表輸出 token 為零。

聊天訊息、工具、串流和 Batch 不屬於此端點合約的一部分。

curl https://api.tokenlab.sh/v1/systemone \
  -H "Authorization: Bearer $TOKENLAB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "jev-1.13",
    "state": "I was charged twice. Please refund the duplicate payment.",
    "questions": {
      "refund_requested": {"type": "noul", "instructions": "Is a refund requested?"},
      "department": {
        "type": "choice", "instructions": "Which team should handle this?",
        "criteria": {"refunds": "Charges and refunds", "technical": "Software bugs"}
      },
      "urgency": {
        "type": "score", "instructions": "Rate urgency",
        "criteria": ["Routine enquiry", "Money affected", "Safety emergency"]
      }
    }
  }'

此 HTTP 請求也適用於標準的 fetch 或 requests 客戶端。決策回應是結構化資料,而非生成的文字解釋。

回應範例。數值僅供說明:

{
  "model": "jev-1.13",
  "answers": {
    "refund_requested": { "type": "noul", "noul": 0.97 },
    "department": {
      "type": "choice",
      "choice": "refunds",
      "probabilities": { "refunds": 0.93, "technical": 0.07 },
      "confidence": 0.93
    },
    "urgency": { "type": "score", "score": 1.2, "confidence": 0.7 }
  },
  "usage": { "input_tokens": 412, "output_tokens": 38 }
}

錯誤

若請求包含未知欄位或無效問題,將會回傳 400 invalid_request。若模型非決策模型,則會回傳 400 unsupported_endpoint。請參照 處理 API 錯誤 來處理其他狀態碼。

curl -X POST "https://example.com/v1/systemone" \  -H "Content-Type: application/json" \  -d '{    "model": "string",    "state": "string",    "questions": {      "property1": {        "type": "noul",        "instructions": "string"      },      "property2": {        "type": "noul",        "instructions": "string"      }    }  }'
{  "id": "string",  "model": "string",  "answers": {    "property1": {      "type": "noul",      "noul": 0    },    "property2": {      "type": "noul",      "noul": 0    }  },  "usage": {    "input_tokens": 0,    "output_tokens": 0  }}

授權

BearerAuth
AuthorizationBearer <token>

API Key 驗證。請在 Dashboard > API > API Keys 建立或管理 API 金鑰。

位置: header

請求標頭

X-TokenLab-Delivery-Policy?string

單次請求傳遞策略。會覆寫 API key 與 Workspace 的預設值。系統會自動優先嘗試 TokenLab Verified,並可能在輸出、請求接受或建立持久性資源前切換至 Official 模式一次。

可選值

  • "auto"
  • "verified"
  • "official"

請求主體

application/json

回應

application/json

application/json

application/json

application/json

application/json

application/json

application/json