POST /v1/decide

API 参考

Bearer laya_ 密钥。state 可以是字符串或 JSON。Choice / Score / Noul,另有批量、免费门禁和应用模板。预付费只扣输入 token,结构化输出不计费。

鉴权

Authorization: Bearer laya_…
Content-Type: application/json

https://laya-model.com

在 账户页创建密钥。模型别名 english 与 multilingual。

POST /v1/decide

别名 POST /v1/systemone,请求体相同。已登录的浏览器会话也会按余额计费;匿名默认可跑 1 次。

curl https://laya-model.com/v1/decide \
  -H "Authorization: Bearer laya_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "state": {
      "ticket": "I was charged twice and nobody has replied for 3 days.",
      "channel": "email"
    },
    "questions": {
      "route": {
        "type": "choice",
        "instructions": "Where should this go?",
        "criteria": { "billing": "money", "bug": "broken", "account": "login" }
      },
      "urgency": {
        "type": "score",
        "instructions": "How urgent is this?",
        "criteria": ["routine", "today", "urgent"]
      },
      "escalate": { "type": "noul", "instructions": "Escalate to a human now?" }
    }
  }'

请求体

  • state 字符串、对象或数组。
  • questions id 到 noul、choice 或 score 的映射。
  • 只扣 usage.input_tokens。结构化输出不计费。新 Google 账户每月先有 10k_monthly(10,000 输入 token)。

批量

POST /v1/batch/decide:最多 20 个 state,共用 questions。每个 state 单独计费。同一把 laya_ 密钥。

curl https://laya-model.com/v1/batch/decide \
  -H "Authorization: Bearer laya_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"states":["Passage A","Passage B"],"questions":{"relevant":{"type":"noul","instructions":"Does this answer the question?"}}}'

门禁

POST /v1/gate 只在本地套政策,返回 allow、review 或 block。不调用上游,不扣 token,也不需要密钥。

curl https://laya-model.com/v1/gate \
  -H "Content-Type: application/json" \
  -d '{"answers":{"toxicity":{"type":"noul","noul":0.12}},"policy":{"min_confidence":0.55}}'

错误

  • 401 缺少或无效的 laya_ 密钥,或匿名额度已用完。
  • 402 余额不足。
  • 429 超过 RPM,或每小时 / 每天输入 token 上限。
  • 503 服务器未配置 IMPOSSIBL_API_KEY。

应用模板

API 文档 · Laya AI