Jevによる判断
curl --request POST \
--url https://api.mixroute.ai/typesafe/v1/systemoneimport requests
url = "https://api.mixroute.ai/typesafe/v1/systemone"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.mixroute.ai/typesafe/v1/systemone', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mixroute.ai/typesafe/v1/systemone",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.mixroute.ai/typesafe/v1/systemone"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mixroute.ai/typesafe/v1/systemone")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mixroute.ai/typesafe/v1/systemone")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body意思決定モデル
Jevによる判断
ネイティブTypeSafeのJev Choice、Score、Noulのパラメーター、構造化入力、レスポンス、および料金。
Jevによる判断
curl --request POST \
--url https://api.mixroute.ai/typesafe/v1/systemoneimport requests
url = "https://api.mixroute.ai/typesafe/v1/systemone"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.mixroute.ai/typesafe/v1/systemone', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mixroute.ai/typesafe/v1/systemone",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.mixroute.ai/typesafe/v1/systemone"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mixroute.ai/typesafe/v1/systemone")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mixroute.ai/typesafe/v1/systemone")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyJevは、TypeSafeの構造化された意思決定モデルです。アプリケーションの状態と名前付きの質問を送信すると、生成されたチャットテキストではなく、分類、スコア、またはyes/noの確率が同期的に返されます。
質問IDはリクエストと回答を対応付けるためのもので、モデルには表示されません。実際の質問はIDだけでなくinstructionsに記述してください。複数の質問は同じstateに対して独立して評価され、3種類すべてを混在させることができます。ある質問が別の回答に依存する場合は、アプリケーション内で個別の呼び出しを組み合わせてください。
返されるchoiceは、確率が最も高い選択肢です。probabilitiesにはすべての選択肢が含まれ、その合計はおおむね1になります。入力の一部が指定したカテゴリに当てはまらない可能性がある場合は、otherまたはinsufficient_informationを含めてください。
レベルのインデックスは0から始まります。3つのレベルは0、1、2に対応します。scoreは確率で重み付けされた位置で、0からレベル数マイナス1までの値を取り、小数になる場合があります。常に0〜1のスコアとは限りません。legendは文字列のインデックスを元の説明に対応付け、probabilitiesも同じインデックスを使用します。返されたscoreは切り捨てずに使用してください。離散的なレベルが必要な場合は、アプリケーション側で判定ルールを定めてください。
返されるnoulは、ブール値ではなく0~1の確率です。1に近いほどtrue、0に近いほどfalseを支持し、0.5付近は不確実であることを示します。Noulには独立したconfidenceフィールドがなく、程度を測定するものでもありません。段階的な評価にはScoreを使用してください。
テキスト、指示、評価基準はすべてコンテキストを消費します。質問間でstateは共有されますが、質問が増えるごとに入力全体の量も増えます。プロバイダーが公表するレート制限は、MixRouteアカウントの利用可能枠を定めるものではありません。ご自身のアカウントの制限を使用してください。
確率とトークン数はレスポンス形式を示すための例です。値は入力や呼び出しによって異なる場合があります。
アプリケーションで確率や信頼度のしきい値を設定し、不確実な入力に対してはレビューや確認を行う経路を用意してください。信頼度が高くても正確さが保証されるわけではありません。英語以外のタスクは、ご自身のアプリケーションデータで評価してください。
これらは米ドル建ての基本価格です。実際の請求額は、現在のモデルマーケットプレイスの価格、アカウントグループの倍率、および請求明細によって決まります。入力使用量にはstateと質問の定義が含まれ、質問や選択肢が増えると入力トークンも増えます。出力トークンが無料でも、
ネットワークのタイムアウトは、リクエストが実行されなかった証拠にはなりません。再送信すると新たな評価が作成され、再度料金が発生する場合があります。アプリケーション側で再試行を明示的に制御してください。
POST https://api.mixroute.ai/v1/systemone
Authorization: Bearer $MIXROUTE_API_KEYでContent-Type: application/jsonとともにMixRouteのAPIキーを使用してください。ネイティブのTypeSafeボディ構造であるmodel、state、questionsを維持してください。metadataでラップしたり、チャットメッセージや非同期タスクのポーリングを使用したりしないでください。
対応モデル
| モデル | リクエストID |
|---|---|
| Jev 1.13 | jev-1.13.0 / jev-latest |
jev-1.13.0は固定バージョンID、jev-latestは最新安定版のエイリアスです。現在はいずれもJev 1.13を呼び出しており、別々の2つのモデルではなく、1つのモデルを指します。最新エイリアスの参照先は今後のリリースで変更される可能性があります。安定性を重視する場合はバージョンを固定し、レスポンスのmodelで使用されたバージョンを確認してください。
アカウントのモデル一覧で利用可能な、正確なモデルIDのみを使用してください。
質問タイプの選択
| 型 | 目的 | 主な回答フィールド |
|---|---|---|
choice | チケットのカテゴリなど、あらかじめ定義した選択肢を1つ選びます。 | choice, probabilities, confidence |
score | 問題の重大度など、順序のある記述的な尺度で評価します。 | score, legend, probabilities, confidence |
noul | 返金が求められているかどうかなど、1つの命題が真であるかを推定します。 | noul |
トップレベルのパラメーター
| フィールド | 型 | 要件 | 説明 |
|---|---|---|---|
model | string | 必須 | jev-1.13.0またはjev-latest。エイリアスの更新が連携に影響する場合は、バージョンを固定してください。 |
state | string / object / array | 必須 | すべての質問によって評価されるコンテンツ。テキスト、アプリケーションのレコード、または会話配列を使用します。ルートはnull、数値、ブール値にできません。ネストされたJSONには、アプリケーションの数値フィールドやブール値フィールドを保持できます。 |
questions | object | 必須 | 空でない質問マップ。配列ではありません。各キーはquestion_idで、各値は質問オブジェクトです。 |
質問のパラメーター
以下のフィールドはquestions[question_id]内に配置します。各質問にinstructionsを明示的に指定し、1つの明確な判断内容を記述してください。Choiceによる分類
| フィールド | 型 | 要件 | 説明 |
|---|---|---|---|
type | string | 必須 | choiceである必要があります。 |
instructions | string / object / array | 推奨 | 何を選択するかを説明します。複雑な指示はオブジェクトまたは配列にまとめてください。 |
criteria | object | 必須 | 1~255個の選択肢名と説明のマップ。options配列ではありません。名前と説明の両方が判断に用いられます。 |
criteria[option] | string / object / array / null | 選択肢ごと | この選択肢の説明。名前だけで十分に明確な場合はnullを使用してください。 |
スコア評価
| フィールド | 型 | 要件 | 説明 |
|---|---|---|---|
type | string | 必須 | scoreである必要があります。 |
instructions | string / object / array | 推奨 | 重大度など、評価する1つの観点を記述します。 |
criteria | array | 必須 | 順序付きのレベルの説明。空にはできず、最大10件です。2件以上を推奨します。各項目にはstring、object、arrayを指定できます。単に数値のラベルを付けるのではなく、各レベルを説明してください。 |
NoulによるYes/No評価
| フィールド | 型 | 要件 | 説明 |
|---|---|---|---|
type | string | 必須 | noulである必要があります。 |
instructions | string / object / array | 推奨 | はい/いいえで答える質問または命題を1つ指定します。値が高いほど、はい/真であるとの判断が強くなります。 |
criteria | object / null | 任意 | yesとnoに対する任意の指針。省略時は、instructionsが判断内容を定義します。 |
criteria.true | string / object / array / null | 任意 | 何をyes/trueとみなすか。 |
criteria.false | string / object / array / null | 任意 | no/falseと判定する条件。 |
入力とコンテキストの上限
| 項目 | 上限 |
|---|---|
| 入力モダリティ | テキストのみ。テキスト文字列、またはテキストとアプリケーションデータを含むJSONオブジェクト/配列を指定してください。画像、音声、動画は、先にテキストに変換してください。 |
| リクエスト全体のコンテキスト | stateとすべての質問を合わせて最大64kトークンです。 |
| 質問ごとのコンテキスト | stateと最も長い個別の質問を合わせて最大32kトークンです。リクエスト全体の制限も満たす必要があります。 |
| 選択 | 質問ごとに最大255の選択肢。criteriaは空にできません。 |
| スコア | 質問ごとに最大10レベル。criteriaは空にできません。意味のあるスコア評価には、異なるレベルを少なくとも2つ使用してください。 |
リクエスト例
サーバー側で環境変数MIXROUTE_API_KEYを設定してください。このリクエストでは、3種類すべての質問を混在させています。curl --request POST "https://api.mixroute.ai/v1/systemone" \
--header "Authorization: Bearer $MIXROUTE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "jev-latest",
"state": "I was charged twice for order 123. Please refund the duplicate charge today.",
"questions": {
"department": {
"type": "choice",
"instructions": "Which team should handle this request?",
"criteria": {
"billing": "Duplicate charges, payments and refunds",
"technical": "Broken software and integration issues",
"shipping": "Shipment delivery and tracking"
}
},
"urgency": {
"type": "score",
"instructions": "How time-sensitive is the request?",
"criteria": [
"No deadline; routine request",
"Needs attention within a week",
"Explicitly requires action today"
]
},
"duplicate_charge": {
"type": "noul",
"instructions": "The customer was charged twice for the same order.",
"criteria": {
"true": "Explicit duplicate payment for the same order",
"false": "No duplicate payment is mentioned"
}
}
}
}'
レスポンス例
{
"model": "jev-1.13.0",
"answers": {
"department": {
"type": "choice",
"choice": "billing",
"confidence": 1,
"probabilities": {
"technical": 0,
"billing": 1,
"shipping": 0
}
},
"urgency": {
"type": "score",
"score": 2,
"confidence": 1,
"legend": {
"0": "No deadline; routine request",
"1": "Needs attention within a week",
"2": "Explicitly requires action today"
},
"probabilities": {
"0": 0,
"1": 0,
"2": 1
}
},
"duplicate_charge": {
"type": "noul",
"noul": 0.9
}
},
"usage": {
"input_tokens": 447,
"output_tokens": 70
}
}
| フィールド | 型 | 要件 | 説明 |
|---|---|---|---|
model | string | 返される値 | 推論に使用されたバージョンです。リクエストしたエイリアスと異なる場合があります。 |
answers | object | 返される値 | 元の質問IDをキーとする回答。各回答の型は、対応する質問の型と一致します。 |
answers[id].type | string | 返される値 | choice、score、またはnoul。対応する質問の型と一致します。 |
answers[id].choice | string | 選択 | 選択された選択肢名。リクエストのcriteriaのキーから選ばれます。 |
answers[id].probabilities | object | 選択 / スコア | 選択肢名またはレベルのインデックスと確率のマップ。値は0~1で、合計はおおむね1になります。 |
answers[id].score | number | スコア | レベルのインデックスを確率で重み付けした位置。小数になる場合があり、範囲は基準レベルの数によって決まります。 |
answers[id].legend | object | スコア | 文字列のレベルインデックスから元の基準の説明へのマップ。説明の文字列、オブジェクト、配列を保持します。 |
answers[id].noul | number | Noul | 命題が真である確率。0~1の値であり、ブール値ではありません。 |
answers[id].confidence | number | 選択 / スコア | 分布から算出した確信度の要約値で、範囲は0~1です。正確性を保証するものではなく、選択肢の確率の最大値と同一視してはなりません。 |
usage.input_tokens | integer | 返される値 | この評価における課金対象の入力トークン数。 |
usage.output_tokens | integer | 返される値 | 回答で使用された出力トークン。現在は無料です。 |
構造化入力
状態、指示、説明形式の基準には、ネイティブのJSON構造を使用してください。この例では、オブジェクト/配列形式の指示と、構造化されたレベルの説明を組み合わせています。{
"model": "jev-1.13.0",
"state": {
"incident": {
"feature": "export",
"symptom": "CSV export always fails",
"workaround": "Download JSON instead"
},
"customer_request": "Please fix this when convenient; no immediate deadline."
},
"questions": {
"route": {
"type": "choice",
"instructions": {
"question": "Which team owns the incident?",
"field": "incident"
},
"criteria": {
"engineering": {
"covers": [
"software errors",
"broken export"
],
"excludes": "billing"
},
"billing": [
"payments",
"refunds"
]
}
},
"impact": {
"type": "score",
"instructions": [
"Assess the functionality impact of incident only.",
"Use the documented workaround when judging."
],
"criteria": [
{
"description": "Cosmetic only",
"examples": [
"misaligned label"
]
},
[
"A feature fails but a workaround is available"
],
{
"description": "Completely blocked and no workaround"
}
]
},
"has_workaround": {
"type": "noul",
"instructions": {
"question": "Does incident describe a usable workaround?"
},
"criteria": {
"true": {
"description": "A concrete alternative is provided"
},
"false": [
"No alternative",
"Explicitly no workaround"
]
}
}
}
}
会話配列
会話記録をstate配列として渡してください。ここでのrole/textはアプリケーションのフィールドであり、Chat Completionsのメッセージプロトコルではありません。{
"model": "jev-1.13.0",
"state": [
{
"role": "customer",
"text": "Please check order 123. It was charged twice."
},
{
"role": "agent",
"text": "The duplicate charge has now been refunded."
}
],
"questions": {
"refund_done": {
"type": "noul",
"instructions": "The agent says the duplicate charge has been refunded."
},
"shipment_lost": {
"type": "noul",
"instructions": "The conversation says a shipment was lost."
}
}
}
Python
Python 3とrequestsが必要です。この例では、タスクのポーリングや自動再送信を行わずに同期的な回答を読み取ります。import json
import os
import requests
def evaluate_jev(payload):
response = requests.post(
"https://api.mixroute.ai/v1/systemone",
headers={"Authorization": "Bearer " + os.environ["MIXROUTE_API_KEY"]},
json=payload,
timeout=60,
allow_redirects=False,
)
request_id = response.headers.get("x-oneapi-request-id", "")
try:
result = response.json()
except ValueError as exc:
raise RuntimeError(
f"HTTP {response.status_code}; request_id={request_id}; invalid JSON"
) from exc
if not 200 <= response.status_code < 300:
detail = result.get("detail", result) if isinstance(result, dict) else result
raise RuntimeError(
f"HTTP {response.status_code}; request_id={request_id}; detail={detail}"
)
if not isinstance(result, dict) or not isinstance(result.get("answers"), dict):
raise RuntimeError("Invalid Jev response; request_id=" + request_id)
if set(result["answers"]) != set(payload["questions"]):
raise RuntimeError("Response question IDs do not match the request")
return result
if __name__ == "__main__":
payload = json.loads(r'''
{
"model": "jev-latest",
"state": "I was charged twice for order 123. Please refund the duplicate charge today.",
"questions": {
"department": {
"type": "choice",
"instructions": "Which team should handle this request?",
"criteria": {
"billing": "Duplicate charges, payments and refunds",
"technical": "Broken software and integration issues",
"shipping": "Shipment delivery and tracking"
}
},
"urgency": {
"type": "score",
"instructions": "How time-sensitive is the request?",
"criteria": [
"No deadline; routine request",
"Needs attention within a week",
"Explicitly requires action today"
]
},
"duplicate_charge": {
"type": "noul",
"instructions": "The customer was charged twice for the same order.",
"criteria": {
"true": "Explicit duplicate payment for the same order",
"false": "No duplicate payment is mentioned"
}
}
}
}
''')
result = evaluate_jev(payload)
print(result["model"])
print(result["answers"]["department"]["choice"])
print(result["answers"]["urgency"]["score"])
print(result["answers"]["duplicate_charge"]["noul"])
print(result["usage"])
JavaScript
Node.js 18以降をESモジュール(.mjs)で使用してください。APIキーはブラウザーのコードではなく、サーバー側で保持してください。async function evaluateJev(payload) {
const apiKey = process.env.MIXROUTE_API_KEY;
if (!apiKey) throw new Error("Set MIXROUTE_API_KEY");
const response = await fetch("https://api.mixroute.ai/v1/systemone", {
method: "POST",
headers: {
Authorization: "Bearer " + apiKey,
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
redirect: "error",
signal: AbortSignal.timeout(60000),
});
const requestId = response.headers.get("x-oneapi-request-id") ?? "";
let result;
try {
result = await response.json();
} catch {
throw new Error("HTTP " + response.status + "; request_id=" + requestId + "; invalid JSON");
}
if (!response.ok) {
throw new Error("HTTP " + response.status + "; request_id=" + requestId +
"; detail=" + JSON.stringify(result?.detail ?? result));
}
if (!result?.answers || typeof result.answers !== "object" || Array.isArray(result.answers)) {
throw new Error("Invalid Jev response; request_id=" + requestId);
}
const requested = Object.keys(payload.questions).sort();
const returned = Object.keys(result.answers).sort();
if (JSON.stringify(requested) !== JSON.stringify(returned)) {
throw new Error("Response question IDs do not match the request");
}
return result;
}
const payload = {
"model": "jev-latest",
"state": "I was charged twice for order 123. Please refund the duplicate charge today.",
"questions": {
"department": {
"type": "choice",
"instructions": "Which team should handle this request?",
"criteria": {
"billing": "Duplicate charges, payments and refunds",
"technical": "Broken software and integration issues",
"shipping": "Shipment delivery and tracking"
}
},
"urgency": {
"type": "score",
"instructions": "How time-sensitive is the request?",
"criteria": [
"No deadline; routine request",
"Needs attention within a week",
"Explicitly requires action today"
]
},
"duplicate_charge": {
"type": "noul",
"instructions": "The customer was charged twice for the same order.",
"criteria": {
"true": "Explicit duplicate payment for the same order",
"false": "No duplicate payment is mentioned"
}
}
}
};
const result = await evaluateJev(payload);
console.log(result.model);
console.log(result.answers.department.choice);
console.log(result.answers.urgency.score);
console.log(result.answers.duplicate_charge.noul);
console.log(result.usage);
料金と使用量
| モデル | 入力 / 100万トークン | 出力 / 100万トークン |
|---|---|---|
Jev 1.13 (jev-1.13.0 / jev-latest) | $0.042 | $0 |
usage.output_tokensがゼロ以外になる場合があります。
usage.input_tokensに入力単価を掛けて1,000,000で割り、その後アカウントの倍率を適用して料金を見積もります。プラットフォームは各リクエストを内部クォータ単位で精算するため、丸め処理により、丸め前の米ドル計算とはわずかな差が生じる場合があります。
クォータの換算については、認証とクォータを参照してください。
レスポンスの処理
JSONの結果を使用する前に、HTTPのステータスを確認してください。成功レスポンスには回答が直接含まれます。エラーの詳細は、文字列、オブジェクト、またはフィールドエラーの配列の場合があります。APIキー全体をログに記録せず、トラブルシューティング用にx-oneapi-request-idレスポンスヘッダーを保持してください。| ステータス | 操作 |
|---|---|
200 | model、answers、usageを読み取り、question_idで結果を対応付けます。 |
400 / 422 | モデル、フィールドの型、空でないことの制約、選択肢/レベルの数、コンテキスト長を確認し、リクエストを修正してから再送信してください。 |
401 / 403 | MixRouteキー、モデルへのアクセス権、認証ヘッダーを確認してください。 |
429 / 529 | レート制限、または上流の過負荷です。Retry-Afterがある場合はそれに従い、上限付きのバックオフを使用してください。 |
5xx | エラーを確認し、リクエストIDを保持してください。無制限の再送信は避けてください。 |