インテリジェントモデルルーティング
OfoxAIのインテリジェントモデルルーティングは、コスト、速度、品質などの観点でリクエストに最適なモデルを自動選択します。
Auto モード
最もシンプルな使い方 — model: "auto" を設定するだけで、OfoxAI が自動的に選択します:
response = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "量子コンピューティングについて説明してください"}]
)
# 実際に使用されたモデルを確認
print(response.model) # 例: "openai/gpt-4o"Auto モードはリクエスト内容の複雑さと利用可能なモデルのステータスに基づいて、最適なモデルを自動的に選択します。
モデルプール設定
候補モデルプールとルーティング優先度を指定できます:
model_routing.py
response = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "このコードを最適化してください"}],
extra_body={
"model_routing_config": {
"models": [
"openai/gpt-4o",
"anthropic/claude-sonnet-4.5",
"google/gemini-3-flash-preview"
],
"preference": "quality" # 品質優先
}
}
)ルーティングプリファレンス
| プリファレンス | 説明 |
|---|---|
balanced | 品質・速度・コストを総合的に考慮(デフォルト) |
quality | 品質優先、最も能力の高いモデルを選択 |
speed | 速度優先、レスポンスが最も速いモデルを選択 |
cost | コスト優先、最も安価なモデルを選択 |
ユースケース
コスト最適化
シンプルな対話には安価なモデルを自動使用し、複雑なタスクにはハイエンドモデルを使用します:
# シンプルなシナリオ → gpt-4o-mini や gemini-3-flash-preview が選択される可能性あり
response = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "今日は何曜日ですか?"}],
extra_body={"model_routing_config": {"preference": "cost"}}
)高可用性
複数の候補モデルを指定して、サービスの中断を防ぎます:
response = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "市場トレンドを分析してください"}],
extra_body={
"model_routing_config": {
"models": [
"openai/gpt-4o",
"anthropic/claude-sonnet-4.5",
"google/gemini-3.1-pro-preview"
],
"preference": "balanced"
}
}
)インテリジェントルーティングは各モデルのリアルタイムステータス(レイテンシ、可用性、負荷)を自動的に検知し、候補プールの中から最適な選択を行います。
Last updated on