UnderSky 文档

Decisions API(Jev / System One)

POST /v1/decisions 与 OpenRouter 兼容别名 POST /api/alpha/decisions 参考 —— TypeSafe Jev System One,按上游成本原价结算。

对一段 state 提交类型化问题(noul / choice / score),由 TypeSafe Jev(经 OpenRouter)完成评估。UnderSky 使用你的 API Key 鉴权,并按上游成本做 pass-through 计费。

端点

POST https://api.undersky.ai/v1/decisions
POST https://api.undersky.ai/api/alpha/decisions

/api/alpha/decisions 与 OpenRouter Decisions 路径一致,便于把 https://openrouter.ai 换成 https://api.undersky.ai。处理逻辑、鉴权、RPM 桶与计费与 /v1/decisions 相同。

身份认证

使用 UnderSky API Key:

  • Authorization: Bearer sk-your-api-key

参数

请求体遵循 OpenRouter Decisions 原生格式。必填字段:

参数类型必填说明
modelstring是Jev 模型 ID(见下表)。可选 openrouter/ 目录前缀。
statestring | object | array是待评估内容。
questionsobject是问题 id → 类型化问题(noul / choice / score)的映射。

每个问题都需要 type 和 instructions。choice 还需要 criteria 对象,将选项 ID 映射到描述;score 则需要有序的 criteria 描述数组。

支持的模型

模型 ID名称
~typesafe/jev-latestJev Latest
typesafe/jev-1.13Jev 1.13
openrouter/~typesafe/jev-latestJev Latest (OpenRouter prefix)
openrouter/typesafe/jev-1.13Jev 1.13 (OpenRouter prefix)

可选的 openrouter/ 前缀在转发上游前会被剥离,因此目录 ID 与 OpenRouter 风格 ID 均可使用。

定价

Pass-through:按上游响应中的 usage(input_tokens、output_tokens、cost)折算为 UnderSky 积分。参阅定价。

限流

与 Chat RPM 档位共用同一配置(与 Chat Completions 相同)。/api/alpha/decisions 别名映射到同一 /v1/decisions 限流键。参阅速率限制。

请求(curl)

curl -X POST https://api.undersky.ai/v1/decisions \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "~typesafe/jev-latest",
    "state": {
      "ticket": "Customer paid twice for the same order",
      "amount_usd": 48
    },
    "questions": {
      "should_refund": {
        "type": "noul",
        "instructions": "Should we issue a full refund?"
      },
      "primary_reason": {
        "type": "choice",
        "instructions": "Primary reason category",
        "criteria": {
          "duplicate_charge": "The same order was charged more than once.",
          "defective": "The product was defective.",
          "late_delivery": "The delivery was late.",
          "other": "Another reason applies."
        }
      },
      "confidence": {
        "type": "score",
        "instructions": "Confidence that the refund is warranted (0-1)",
        "criteria": ["A full refund is not warranted.", "A full refund is warranted."]
      }
    }
  }'

OpenRouter 路径别名(请求体相同):

curl -X POST https://api.undersky.ai/api/alpha/decisions \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "typesafe/jev-1.13",
    "state": "Blank checkout page after payment redirect",
    "questions": {
      "is_incident": {
        "type": "noul",
        "instructions": "Is this a production incident?"
      }
    }
  }'

响应

成功时透传 OpenRouter 响应,通常包含 answers 与 usage(token 与成本)。具体字段以上游 Decisions 契约为准。

注意事项

  • API 侧需配置 Decisions 上游(OPENROUTER_API_KEY)。
  • 上游超时为 60 秒。
  • Chat / Responses / Messages 仍走各自端点;Decisions 仅用于类型化的 Jev 评估。