Skip to Content
API リファレンスDecisions 判定

Decisions API

Decisions API は、テキストを生成するのではなく、コンテンツに対してモデルに型付きの判定を行わせるための API です。判定対象のコンテンツと一連の質問を渡すと、モデルは質問ごとに構造化された回答を返します。Yes/No の確率、選択肢からの単一選択、または段階スケールでのスコアのいずれかで、各選択肢の確率と信頼度が付きます。

分類、ルーティング、モデレーション、スコアリング、フィルタリングなど、「プログラムが結果をそのまま分岐に使う」場面に適しています。モデルは指定された選択肢と段階の中でしか回答せず、それ以外の内容は返しません。自由形式のテキストを解析する必要もありません。

判定モデルを初めて使用する場合は、まず Jev 利用ガイドを参照することを推奨します。クイックスタート、質問の設計、返却結果の説明、シナリオ例を掲載しています。このページはフィールド単位のリファレンスです。

エンドポイント

3 つのエンドポイントは同じモデル群と同じ課金体系を使用し、違いはリクエストとレスポンスの形式だけです。使用するクライアントに合わせて選択してください。

エンドポイント形式適した用途
POST https://api.ofox.ai/v1/decisionsOfoxAI 統一フォーマット(質問は配列)cURL、任意の HTTP クライアント、OpenAI SDK
POST https://api.ofox.ai/openai/v1/decisions同上OpenAI SDK の base_url を https://api.ofox.ai/openai/v1 に設定済みのプロジェクト
POST https://api.ofox.ai/typesafe/v1/systemoneTypeSafe 公式の System One フォーマット(質問はオブジェクト)TypeSafe 公式 SDK、または TypeSafe 公式ドキュメントに沿って書かれたコード

認証方法は他のエンドポイントと同じです:Authorization: Bearer <OFOXAI_API_KEY>。非ストリーミングのみに対応しており、1 回のリクエストですべての回答が同期的に返ります。

利用可能なモデル

モデル ID説明
typesafe/jev-latestTypeSafe Jev。判定専用モデルです。テキストまたは JSON 入力のみ、64K コンテキスト。jev-latest と省略できます
openai/gpt-6-luna3 つのエンドポイントすべてに対応。画像を読み取れます(メッセージ配列で input_image を渡します)

この API に対応するモデルの一覧はモデルページ をご覧ください。通常の対話モデル(openai/gpt-4o など)で呼び出すと endpoint_not_supported が返ります。

統一フォーマット:/v1/decisions

リクエストパラメータ

パラメータ型必須説明
modelstring✅モデル ID。例:typesafe/jev-latest
inputstring | object | array✅判定対象のコンテンツ。入力形式を参照
questionsarray✅質問のリスト。各要素は質問オブジェクトです。回答は同じ順序で返ります
safety_identifierstring—安定したエンドユーザー ID。OpenAI モデルでのみ有効

入力形式

input は次の 3 つの形式に対応しています。

  • テキスト:1 つの文字列。
    "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 が返ります。

質問オブジェクト

フィールド対象の種類説明
typeすべてpredicate(Yes/No)、choice(単一選択)、score(段階評価)
nameすべて任意ですが、指定を推奨します。回答にそのまま返されるため、対応付けに使えます。同一リクエスト内で重複できません
instructionsすべて質問そのもの。文字列、または質問と参照データを含む JSON オブジェクト
criteriapredicate任意。{ "true": "...", "false": "..." } の形式で、「Yes」と「No」がそれぞれ何を指すかを説明します
choiceschoice必須。選択肢の配列で、各要素は { "value": "billing", "description": "Charges, refunds" } です。description は省略可能です。最大 255 個
levelsscore必須。低い順に並べた段階の配列で、各要素は { "label": "low", "description": "..." } です。2–10 段階

リクエスト例

Terminal
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 と 1 対 1 で対応し、順序も同じです。種類ごとの回答フィールドは次のとおりです。

種類フィールド説明
predicateprobability回答が「Yes」である確率、0–1
choicechoice確率が最も高い選択肢
probabilities各選択肢の確率。合計は 1
confidence今回の判定に対するモデルの確からしさ、0–1。確率と信頼度を参照
scorescore確率で重み付けした段階の値。0 から始まり、2 つの段階の間の値になることがあります(例:1.43)
legend段階の番号と説明の対応表
probabilities各段階の確率
confidence同上

TypeSafe ネイティブフォーマット:/typesafe/v1/systemone

TypeSafe 公式 API  とリクエスト・レスポンスの形式が同じため、TypeSafe SDK をそのまま使う場合や既存コードを移行する場合に適しています。統一フォーマットとの違いは次のとおりです。

統一フォーマット /v1/decisionsTypeSafe ネイティブフォーマット
判定対象のコンテンツinputstate
質問配列。name で識別オブジェクト。キー名が質問 ID
Yes/No の質問type: "predicate"、回答フィールドは probabilitytype: "noul"、回答フィールドは noul
選択肢と段階choices / levels 配列いずれも criteria に記述:choice は {選択肢: 説明} オブジェクト、score は説明文字列の配列
使用量フィールドprompt_tokens / completion_tokensinput_tokens / output_tokens
Terminal
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 に置き換えるだけで、その他のコードは変更不要です。

typesafe_sdk.py
# 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 は確率分布から算出され、分布が集中しているほど高くなります。2 つの選択肢がそれぞれ 0.5 の場合でも choice はどちらか一方を返しますが、confidence は低くなります。

一般的には、コード内でしきい値を設定し、信頼度が高ければ自動で処理し、低ければ人による確認やより高性能なモデルでの再確認に回します。

課金

トークン単位で課金されます。単価はモデルページ をご覧ください。typesafe/jev-latest は入力トークンのみ課金され、出力は課金されません(completion_tokens / output_tokens は通常どおり返ります)。

1 回のリクエスト内のすべての質問は同じ入力を共有するため、複数の質問を 1 回のリクエストにまとめるほうが、複数回に分けて呼び出すよりも大幅に安く、高速です。

制限

項目制限
リクエストボディ最大 32 MiB
コンテキストJev は 64K トークン。超えると 400 が返ります
choice の選択肢最大 255 個
score の段階2–10 段階
JSON のネストinput/state、instructions、criteria はそれぞれ最大 64 階層
ストリーミング非対応

よくあるエラー

HTTP · typeエラーメッセージ原文原因対処方法
400 invalid_request_errorquestion "a" has kind choice and requires criteria optionschoice の質問に choices がない選択肢の配列を追加する
400 invalid_request_errorquestion name "a" is used more than once2 つの質問の name が同じ重複しない名前に変更する
400 invalid_request_errorToo many score levels. Must have at most 10 levels.score の段階が 10 を超えている段階を統合するか、複数の質問に分ける
400 invalid_request_errordecision input carries an "input_image" part, which Typesafe cannot readJev に画像を渡した画像を削除するか、画像を読み取れるモデルに切り替える
400 invalid_request_errorInvalid request payload/v1/decisions で TypeSafe ネイティブフォーマット(state + オブジェクト形式の questions)を使用した統一フォーマットに変更するか、/typesafe/v1/systemone を呼び出す
400 endpoint_not_supportedModel 'openai/gpt-4o' does not support the /v1/decisions endpoint on this platform.そのモデルは判定モデルではない利用可能なモデルに切り替える
404 model_not_foundModel 'typesafe/jev-9' not foundモデル ID の誤りtypesafe/jev-latest を使用する
404 invalid_request_errorUnsupported API endpoint.パスを /v1/systemone と記述したTypeSafe ネイティブフォーマットのパスは /typesafe/v1/systemone

その他の共通エラーはエラー処理をご覧ください。

最終更新日