升级重大升级进行中:全新视频制作台,更多模型即将上架,敬请期待
Inferway
登录注册
决策 API

决策模型 API 指南

POST /v1/systemone 及其别名 POST /v1/decisions 返回针对文本和图片问题的已类型化答案。请使用 Inferway 直连 API Key;不支持流式输出和聊天采样参数。

已上线 · 决策 API 已开放。

模型与计费

输入 token 按每百万 token 计费;输出 token 不计费。

模型输入 / 100 万 token(USD / CNY)输出
typesafe/jev-1.14$0.034 / ¥0.24免费

请求

state 接受文本、对象或数组。questions 将问题 ID 映射到四种题型:

  • noul:是/否概率;instructions 必填,可选 criteria,键为 true 和 false。
  • choice:从非空 criteria 对象中选择一项;instructions 可选。
  • score:在有序 criteria 等级上给出连续分数,最多十级;instructions 可选。
  • box:用非空 instructions 在图片中定位物体;不要传 criteria。仅 typesafe/jev-1.14 支持,且请求必须包含图片。
{
  "model": "typesafe/jev-1.14",
  "state": "Classify this ticket: the invoice was charged twice.",
  "questions": {
    "billing": {
      "type": "noul",
      "instructions": "Is this about billing?"
    },
    "category": {
      "type": "choice",
      "criteria": {
        "billing": "payment",
        "technical": "service"
      }
    },
    "urgency": {
      "type": "score",
      "criteria": [
        "low",
        "medium",
        "high"
      ]
    }
  }
}

图片与限额

图片放在 assets 中,以引用字符串为键,并在 state、指令或选择项文本中引用。每个 asset 都必须被引用。每个 asset 使用 format(png、jpg 或 jpeg)和标准 data_base64,不带 data URL 前缀。type 为 image 可选。解码后的单张图片上限 16 MiB,完整请求体上限 32 MiB。图片必须是静态图,每边长度在 280 到 1,568 像素之间;会检查尺寸和动画。

state 与 questions 合计上限 64K token,state 加最长单个问题上限 32K token。图片计入上下文。每个请求最多 64 个问题、255 个选择项。

响应

answers 将每个问题 ID 映射到对应类型的答案:noul 给出概率,choice 给出选中项和各项概率,score 给出数值等级和图例,box 给出归一化的 top、bottom、left 和 right 坐标。id 是 Inferway 请求 ID,同时通过 Inference-Id 响应头返回;model 是公开模型 ID。usage.input_tokens 是用于计费的输入数量。usage.output_tokens 仅供展示,不计费。object 和 created 可能不存在。

{
  "id": "req_example",
  "model": "typesafe/jev-1.14",
  "answers": {
    "billing": {
      "type": "noul",
      "noul": 0.93,
      "probabilities": {
        "yes": 0.93,
        "no": 0.07
      }
    },
    "category": {
      "type": "choice",
      "choice": "billing",
      "probabilities": {
        "billing": 0.91,
        "technical": 0.09
      }
    },
    "urgency": {
      "type": "score",
      "score": 2,
      "legend": {
        "0": "low",
        "1": "medium",
        "2": "high"
      },
      "probabilities": {
        "0": 0.05,
        "1": 0.16,
        "2": 0.79
      }
    }
  },
  "usage": {
    "input_tokens": 454,
    "output_tokens": 0
  }
}

错误码

HTTP含义
400请求无效、题型不支持、图片无效,或内容政策拒绝。
401缺少 API Key 或 API Key 无效。
402可用余额不足;请求不会被执行。
403凭据或 Key 策略不允许该路由或模型。
404模型不可用或功能未开启。
429网关 Key 速率限制。
502模型服务传输或响应错误。
503模型暂时不可用。响应带 Retry-After(秒);请在该时间后重试。
504请求超时。

请求不会自动重试。重试是一次新的请求,可能产生单独费用。