OpenAI Decisions API now available on AI Gateway
TL;DR · AI 摘要
OpenAI Decisions API now available on AI Gateway - Vercel OpenAI's Decisions API is now available on AI Gateway through...
核心要点
- 主题聚焦:OpenAI Decisions API now available on AI Gateway
- 来源:Vercel News,建议结合原文判断细节。
- AI 分析暂不可用,本条为保底评分与摘要。
OpenAI Decisions API 现已上线 AI Gateway - Vercel
通过兼容 OpenAI 的 /v1/decisions 端点,OpenAI 的 Decisions API 现已部署在 AI Gateway。您可以使用 GPT-6 Luna Decisions 或 AI Gateway 上的其他决策模型进行调用。
决策模型针对共享输入回答结构化问题,返回概率、选项和评分,而非生成文本。这种特性适用于路由、分诊、安全防护和评分表等场景。您可以在单次请求中针对相同输入提出谓词(是/否)、选项和评分问题。
openai/gpt-6-luna-decisions 是一个独立于 openai/gpt-6-luna 的模型 ID,后者仍作为文本生成的语言模型。发送到 decisions ID 的请求将通过 Decisions API 处理,并按照其计费标准进行计费。
您可以通过 OpenAI SDK、AI SDK、现有 HTTP API(/v1/evaluate)或 AI CLI 调用该接口。
复制链接到升级部分
decisions.create 需要 JavaScript 使用 OpenAI SDK 7.30.0 或更高版本,或 Python 使用 3.26.0 或更高版本。在 AI SDK 中,experimental_decide 需要 ai 7.0.128 或更高版本。
OpenAI SDK 和 AI SDK
将 OpenAI SDK 指向 AI Gateway,并像调用 OpenAI 一样调用 decisions.create。在 AI SDK 中,问题通过名称进行键值映射,是/否类型称为 boolean。questions 中的每个键都会成为 answers 中的键:
Typescript
Python
Bash
AI SDK
1
import
OpenAI
from
'openai'
;
2
3
const
openai
=
new
OpenAI
(
{
4
apiKey
:
process
.
env
.
AI_GATEWAY_API_KEY
,
5
baseURL
:
'https://ai-gateway.vercel.sh/v1'
,
6
}
)
;
7
8
const
decision
=
await
openai
.
decisions
.
create
(
{
9
model
:
'openai/gpt-6-luna-decisions'
,
10
input
:
'I was charged twice. Please refund me.'
,
11
questions
:
[
12
{
13
type
:
'choice'
,
14
name
:
'department'
,
15
instructions
:
'Which team should handle this?'
,
16
choices
:
[
17
{
value
:
'billing'
,
description
:
'Charges and refunds'
}
,
18
{
value
:
'technical'
,
description
:
'Bugs and outages'
}
,
19
]
,
20
}
,
21
]
,
22
}
)
;
23
24
console
.
log
(
decision
.
answers
)
;复制给代理
查看模型详情
↗
答案按问题顺序返回为数组,每个答案携带对应问题的名称。将模型设置为任何决策模型,包括 Jev、Liquid d1 和 Laya。
查看 OpenAI 兼容的 Decisions API 参考文档了解请求限制和错误格式,查看 AI SDK 的决策文档,或浏览 AI Gateway 上的所有决策模型。