Decisions API
Decisions API는 모델이 텍스트를 생성하는 대신 콘텐츠에 대해 유형화된 판단을 내리도록 합니다. 판단할 콘텐츠와 질문 목록을 제공하면, 모델은 각 질문에 대해 구조화된 답변을 반환합니다. 예/아니요의 확률, 선택지 중 하나의 선택, 또는 등급 척도상의 점수이며, 각 선택지의 확률과 신뢰도가 함께 제공됩니다.
분류, 라우팅, 검수, 점수 매기기, 필터링 등 프로그램이 결과를 받아 바로 분기 처리해야 하는 경우에 적합합니다. 모델은 지정한 선택지와 등급 안에서만 답하며, 그 밖의 내용은 반환하지 않으므로 자유 형식 텍스트를 파싱할 필요가 없습니다.
판단 모델을 처음 사용하는 경우 먼저 Jev 사용 가이드를 읽어 보시기를 권장합니다. 빠른 시작, 질문 설계, 반환 결과 설명, 시나리오 예시를 다룹니다. 이 페이지는 필드 단위 레퍼런스입니다.
엔드포인트
세 경로 모두 동일한 모델과 동일한 과금 체계를 사용하며, 요청과 응답의 형식만 다릅니다. 사용하는 클라이언트에 맞는 경로를 선택하십시오.
인증 방식은 다른 API와 동일합니다: Authorization: Bearer <OFOXAI_API_KEY>. 스트리밍은 지원하지 않으며, 한 번의 요청으로 모든 답변이 동기적으로 반환됩니다.
사용 가능한 모델
이 API를 지원하는 전체 모델 목록은 모델 페이지 를 참고하십시오. 일반 대화 모델(예: openai/gpt-4o)로 호출하면 endpoint_not_supported가 반환됩니다.
통합 형식: /v1/decisions
요청 파라미터
입력 형식
input은 세 가지 형태를 지원합니다.
- 텍스트: 문자열 하나.
"input": "Customer message: I was charged twice, nobody has answered my two emails, and I need a refund today." - 구조화된 데이터: JSON 객체 하나로, 그대로 모델에 전달됩니다. 질문에서 백틱으로 필드 이름을 참조할 수 있습니다. 예:
`message`."input": { "ticket_id": 4812, "message": "I was charged twice.", "plan": "pro" } - 메시지 배열:
[{ "role", "content" }].content는 문자열 또는 콘텐츠 블록 목록이며, 콘텐츠 블록은input_text와input_image만 지원합니다. 이미지는 이미지를 읽을 수 있는 모델에서만 유효합니다. Jev는 이미지를 읽지 않으며, 이미지를 전달하면 400이 반환됩니다.
질문 객체
요청 예시
cURL
curl https://api.ofox.ai/v1/decisions \
-H "Authorization: Bearer $OFOX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "typesafe/jev-latest",
"input": "Customer message: I was charged twice, nobody has answered my two emails, and I need a refund today.",
"questions": [
{ "type": "predicate", "name": "is_frustrated", "instructions": "Is the customer frustrated?" },
{
"type": "choice",
"name": "category",
"instructions": "Which category does this ticket belong to?",
"choices": [
{ "value": "billing", "description": "Charges and refunds" },
{ "value": "bug", "description": "Product issue" },
{ "value": "other", "description": "Other" }
]
},
{
"type": "score",
"name": "urgency",
"instructions": "How quickly does a human need to respond?",
"levels": [
{ "label": "low", "description": "Within a week is fine" },
{ "label": "medium", "description": "Should respond soon" },
{ "label": "high", "description": "Must respond today" }
]
}
]
}'응답 형식
{
"model": "typesafe/jev-latest",
"answers": [
{ "type": "predicate", "name": "is_frustrated", "probability": 0.97 },
{
"type": "choice",
"name": "category",
"choice": "billing",
"confidence": 1,
"probabilities": [
{ "value": "billing", "probability": 1 },
{ "value": "bug", "probability": 0 },
{ "value": "other", "probability": 0 }
]
},
{
"type": "score",
"name": "urgency",
"score": 2,
"confidence": 1,
"legend": { "0": "low: Within a week is fine", "1": "medium: Should respond soon", "2": "high: Must respond today" },
"probabilities": [
{ "value": 0, "label": "low", "probability": 0 },
{ "value": 1, "label": "medium", "probability": 0 },
{ "value": 2, "label": "high", "probability": 1 }
]
}
],
"usage": { "prompt_tokens": 407, "completion_tokens": 72, "total_tokens": 479 }
}answers는 questions와 일대일로 대응하며 순서도 같습니다. 유형별 답변 필드는 다음과 같습니다.
TypeSafe 네이티브 형식: /typesafe/v1/systemone
TypeSafe 공식 API 와 요청·응답 형식이 같으므로 TypeSafe SDK를 그대로 사용하거나 기존 코드를 이전할 때 적합합니다. 통합 형식과의 차이는 다음과 같습니다.
curl https://api.ofox.ai/typesafe/v1/systemone \
-H "Authorization: Bearer $OFOX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "jev-latest",
"state": "Help! My payouts have been failing for 3 days.",
"questions": {
"is_urgent": { "type": "noul", "instructions": "Does this convey urgency?" },
"department": {
"type": "choice",
"instructions": "Which team should handle this?",
"criteria": {
"billing": "Payments, invoicing, refunds",
"technical": "Bugs, outages, integrations",
"sales": "Pricing, upgrades"
}
},
"frustration": {
"type": "score",
"instructions": "How frustrated is the customer?",
"criteria": ["Calm", "Frustrated", "Very angry"]
}
}
}'{
"model": "typesafe/jev-latest",
"answers": {
"is_urgent": { "type": "noul", "noul": 0.95 },
"department": {
"type": "choice",
"choice": "billing",
"confidence": 0.85,
"probabilities": { "billing": 0.9, "technical": 0.1, "sales": 0 }
},
"frustration": {
"type": "score",
"score": 1.03,
"confidence": 0.95,
"legend": { "0": "Calm", "1": "Frustrated", "2": "Very angry" },
"probabilities": { "0": 0, "1": 0.97, "2": 0.03 }
}
},
"usage": { "input_tokens": 399, "output_tokens": 73 }
}SDK 연동
OpenAI SDK
OpenAI 공식 SDK는 client.decisions.create()를 제공합니다. base_url을 https://api.ofox.ai/v1로 지정하고 요청 본문은 통합 형식을 사용하면 됩니다. 예시는 위의 Python 탭을 참고하십시오. Decisions API가 포함된 SDK 버전이 필요합니다(openai Python 3.31.0에서 동작 확인).
TypeSafe SDK
TypeSafe 공식 SDK에서는 base_url을 https://api.ofox.ai/typesafe로 지정하고 api_key를 OfoxAI API Key로 바꾸면 되며, 나머지 코드는 그대로 둡니다.
Python
# pip install typesafe-sdk
import os
from typesafe_sdk import TypeSafeClient, Noul, Choice, Score
with TypeSafeClient(base_url="https://api.ofox.ai/typesafe", api_key=os.environ["OFOX_API_KEY"]) as client:
r = client.system_one(
model="jev-latest",
state={"message": "I was charged twice, nobody has answered my two emails, and I need a refund today."},
questions={
"urgent": Noul(instructions="Is the customer asking for this to be handled today?"),
"dept": Choice(
instructions="Which team should handle this?",
criteria={"billing": "Charges, invoices, refunds", "technical": "Bugs, integrations", "sales": "Pricing, upgrades"},
),
"anger": Score(instructions="How upset is the customer?", criteria=["Calm", "Upset but polite", "Very angry"]),
},
)
print(r.nouls["urgent"].noul) # 0.98
print(r.choices["dept"].choice) # billing
print(r.scores["anger"].score) # 1.56확률과 신뢰도
- 확률은 「답이 무엇인가」에 답합니다.
probability,probabilities는 각 답변에 대한 모델의 보정된 확률입니다. - 신뢰도는 「이번 판단을 믿어도 되는가」에 답합니다.
confidence는 확률 분포에서 도출되며, 분포가 한쪽에 집중될수록 높아집니다. 두 선택지가 각각 0.5일 때도choice는 하나를 반환하지만confidence는 매우 낮습니다.
일반적으로는 코드에 임곗값을 두고, 신뢰도가 높으면 자동으로 처리하고 낮으면 사람에게 넘기거나 더 강력한 모델로 재검토합니다.
과금
토큰 단위로 과금되며, 단가는 모델 페이지 를 참고하십시오. typesafe/jev-latest는 입력 토큰에만 과금되며 출력은 과금되지 않습니다(completion_tokens / output_tokens는 그대로 반환됩니다).
한 요청 안의 모든 질문은 동일한 입력을 공유하므로, 여러 질문을 하나의 요청에 담는 것이 여러 번 나누어 호출하는 것보다 훨씬 저렴하고 빠릅니다.
제한
자주 발생하는 오류
기타 공통 오류는 오류 처리를 참고하십시오.