応答を作成
Responses API を使用して応答を作成します。
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'openai/gpt-5-nano',
stream: false,
input: [{role: 'user', content: 'Give me the current datetime in Asia/Tokyo.'}],
tools: [{type: 'gateway:datetime', parameters: {timezone: 'Asia/Tokyo'}}],
tool_choice: 'auto'
})
};
fetch('https://api.phaseo.app/v1/responses', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.phaseo.app/v1/responses"
payload = {
"model": "openai/gpt-5-nano",
"stream": False,
"input": [
{
"role": "user",
"content": "Give me the current datetime in Asia/Tokyo."
}
],
"tools": [
{
"type": "gateway:datetime",
"parameters": { "timezone": "Asia/Tokyo" }
}
],
"tool_choice": "auto"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://api.phaseo.app/v1/responses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "openai/gpt-5-nano",
"stream": false,
"input": [
{
"role": "user",
"content": "Give me the current datetime in Asia/Tokyo."
}
],
"tools": [
{
"type": "gateway:datetime",
"parameters": {
"timezone": "Asia/Tokyo"
}
}
],
"tool_choice": "auto"
}
'package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.phaseo.app/v1/responses"
payload := strings.NewReader("{\n \"model\": \"openai/gpt-5-nano\",\n \"stream\": false,\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": \"Give me the current datetime in Asia/Tokyo.\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"gateway:datetime\",\n \"parameters\": {\n \"timezone\": \"Asia/Tokyo\"\n }\n }\n ],\n \"tool_choice\": \"auto\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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.phaseo.app/v1/responses")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"openai/gpt-5-nano\",\n \"stream\": false,\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": \"Give me the current datetime in Asia/Tokyo.\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"gateway:datetime\",\n \"parameters\": {\n \"timezone\": \"Asia/Tokyo\"\n }\n }\n ],\n \"tool_choice\": \"auto\"\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.phaseo.app/v1/responses",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'openai/gpt-5-nano',
'stream' => false,
'input' => [
[
'role' => 'user',
'content' => 'Give me the current datetime in Asia/Tokyo.'
]
],
'tools' => [
[
'type' => 'gateway:datetime',
'parameters' => [
'timezone' => 'Asia/Tokyo'
]
]
],
'tool_choice' => 'auto'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api.phaseo.app/v1/responses")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"openai/gpt-5-nano\",\n \"stream\": false,\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": \"Give me the current datetime in Asia/Tokyo.\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"gateway:datetime\",\n \"parameters\": {\n \"timezone\": \"Asia/Tokyo\"\n }\n }\n ],\n \"tool_choice\": \"auto\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "<string>",
"created": 123,
"model": "<string>",
"provider": "<string>",
"provider_id": "<string>",
"nativeResponseId": "<string>",
"status": "completed",
"finish_reason": "<string>",
"meta": {},
"cost_nanos": 123,
"cost_cents": 123,
"currency": "<string>",
"pricing_lines": [
{}
],
"output": [
{
"type": "<string>",
"id": "<string>",
"role": "<string>",
"content": [
{
"type": "output_text",
"text": "<string>",
"annotations": [
{}
]
}
],
"call_id": "<string>",
"name": "<string>",
"arguments": "<string>",
"summary": [
{
"type": "summary_text",
"text": "<string>"
}
],
"encrypted_content": "<string>"
}
],
"output_items": [
{
"type": "<string>",
"id": "<string>",
"role": "<string>",
"content": [
{
"type": "output_text",
"text": "<string>",
"annotations": [
{}
]
}
],
"call_id": "<string>",
"name": "<string>",
"arguments": "<string>",
"summary": [
{
"type": "summary_text",
"text": "<string>"
}
],
"encrypted_content": "<string>"
}
],
"content": [
{}
],
"role": "<string>",
"stop_reason": "<string>",
"type": "<string>",
"usage": {
"prompt_tokens": 123,
"prompt_tokens_details": {
"cached_tokens": 123,
"cache_write_tokens": 123,
"cache_write_tokens_details": {
"ttl_30m_tokens": 123,
"ttl_12h_tokens": 123
}
},
"completion_tokens": 123,
"input_tokens": 123,
"input_tokens_details": {
"cached_tokens": 123,
"cache_write_tokens": 123,
"cache_write_tokens_details": {
"ttl_30m_tokens": 123,
"ttl_12h_tokens": 123
}
},
"output_tokens": 123,
"total_tokens": 123,
"server_tool_use": {
"datetime_requests": 1,
"web_search_requests": 1,
"subagent_requests": 1,
"fusion_requests": 1,
"search_models_requests": 1,
"web_fetch_requests": 1,
"advisor_requests": 1,
"image_generation_requests": 1,
"apply_patch_requests": 1
},
"cost": 0.001234567,
"cost_details": {
"upstream_inference_cost": null
}
}
}{
"error": {
"code": "validation_error",
"message": "Unknown parameter: foo",
"type": "invalid_request_error",
"param": "foo"
},
"ok": false,
"code": "validation_error",
"message": "Human-readable error message",
"description": "Additional error details.",
"generation_id": "G-abc123",
"status_code": 502,
"error_type": "system",
"error_origin": "upstream",
"reason": "all_candidates_failed",
"attempt_count": 2,
"failed_providers": [
"google-ai-studio",
"openai"
],
"failed_statuses": [
403,
429
],
"upstream_error": {
"code": "PERMISSION_DENIED",
"message": "The caller does not have permission.",
"description": "<string>",
"param": "<string>"
},
"failure_sample": [
{
"provider": "<string>",
"type": "<string>",
"status": 123,
"upstream_error_code": "<string>",
"upstream_error_message": "<string>",
"upstream_error_description": "<string>",
"upstream_error_param": "<string>",
"upstream_payload_preview": "<string>",
"retryable": true
}
],
"provider_failure_diagnostics": {
"category": "credentials_not_configured",
"hint": "<string>",
"provider": "<string>"
},
"routing_diagnostics": {
"filterStages": [
{
"stage": "<string>",
"beforeCount": 123,
"afterCount": 123,
"droppedProviders": [
{
"providerId": "<string>",
"reason": "<string>"
}
]
}
]
},
"provider_candidate_diagnostics": {
"totalProviders": 123,
"supportsEndpointCount": 123,
"candidateCount": 123,
"droppedUnsupportedEndpoint": [
"<string>"
],
"droppedMissingAdapter": [
{
"providerId": "<string>",
"endpoint": "<string>"
}
]
},
"provider_enablement": {
"capability": "<string>",
"providersBefore": [
"<string>"
],
"providersAfter": [
"<string>"
],
"dropped": [
{
"providerId": "<string>",
"reason": "<string>"
}
]
},
"missing_pricing_providers": [
"<string>"
],
"provider_payment_required_provider": "openai",
"provider_payment_required_support_notice": "Our upstream provider billing appears to be unavailable. If this persists, contact support.",
"details": [
{}
]
}サーバーツールを使う
自分の関数ツールと並べてtools に phaseo: ツールを追加すると、モデルがそれを呼び出したときに Phaseo が実行します。/v1/responses は、このエンドポイントだけが対応する phaseo:apply_patch を含め、すべてのサーバーツールを受け付けます。一覧はサーバーツールガイドにあります。
curl https://api.phaseo.app/v1/responses \
-H "Authorization: Bearer $PHASEO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-6-astra",
"input": [
{ "role": "user", "content": "Give me the current datetime in Asia/Tokyo." }
],
"tools": [
{ "type": "phaseo:datetime", "parameters": { "timezones": ["Asia/Tokyo"] } }
],
"tool_choice": "auto"
}'
usage.server_tool_use に計数されます。
| ツール | カウンター |
|---|---|
phaseo:datetime | datetime_requests |
phaseo:web_search | web_search_requests、web_search_results、web_search_extra_results |
phaseo:web_fetch | web_fetch_requests |
phaseo:advisor | advisor_requests |
phaseo:subagent | subagent_requests |
phaseo:fusion | fusion_requests |
phaseo:search_models | search_models_requests |
phaseo:image_generation | image_generation_requests |
phaseo:apply_patch | apply_patch_requests |
gateway:datetime タイプも引き続き動作します。stream: true の場合、Phaseo がツールのターンを自分で実行し、続きの回答を 1 つのストリームとして送信します。
ツールループでの推論
OpenAI、Azure OpenAI、xAI では、Phaseo は Responses リクエストをstore: false で上流に送信するため、ツールループのステップ間でモデルの推論が引き継がれるのは reasoning 出力アイテムを通じてのみです。
各 reasoning アイテムには id、summary、content があります。プロバイダーが推論の状態を返す場合、アイテムには encrypted_content も含まれ、次のいずれかが入ります。
- OpenAI、Azure OpenAI、xAI の暗号化された推論。推論モデルでは、Phaseo が
include: ["reasoning.encrypted_content"]で要求します。 - Claude の思考の署名と秘匿化された思考。
- Gemini の思考の署名。署名が属する関数呼び出しの直前に置かれる、別の
reasoningアイテムも含みます。 - Claude の返信が実行された度合い。出力の最後の
reasoningアイテムに入り、テキストはありません。
response.output_item.done と response.completed で届きます。
input で送り返してください。encrypted_content の有無にかかわらず、テキストのないアイテムも含め、reasoning アイテムを削除、編集、並べ替えしないでください。encrypted_content は不透明で、それを生成したプロバイダーとモデルを記録しています。Phaseo はこれをそのプロバイダーの系統とモデルにのみ送信するため、別のプロバイダーにフォールバックした場合は失敗せずに除外されます。これがないと、Claude はツールループのステップ間で推論を失い、reasoning.effort を変更すると Claude のプロンプトキャッシュがやり直しになります。会話の途中で推論の度合いを変えるを参照してください。ボディ
null として送信された省略可能なトップレベルのフィールドは、省略した場合と同じく未設定として扱われます。
model の後に試行される、任意の順序付きフォールバックモデルです。model は必須で、常にプライマリモデルです。試行が 429、500、502、503、504 で失敗すると次のエントリーが試行され、その他のエラーはそのまま返されます。最大 25 個のモデル ID またはプリセットを指定でき、重複や model と同じエントリーは無視されます。各試行は個別のリクエストとして検証、記録、課金され、レスポンスの model フィールドとルーティングトレースには、リクエストを処理したモデルが表示されます。ストリーミングリクエストは最初のバイトの送信前にのみフォールバックし、動画と音楽のジョブは送信時にのみフォールバックします。Batch、realtime、council のリクエストは models を拒否します。動的ルートで設定されたフォールバックが優先され、phaseo/auto は models と併用できません。
1 - 25 elements1[
"anthropic/claude-sonnet-5-5",
"google/gemini-2.5-flash"
]
このリクエストで使うゲートウェイプラグイン。web は任意のモデルに Web 検索を、web-fetch はページの取得を追加します。response-healing はストリーミングしない構造化レスポンスの不正な JSON を修復します。ワークスペースとプリセットの既定値はこのリストとマージされます。不明なプラグイン ID には 400 unknown_gateway_plugin が返ります。
リクエストにサーバーツール phaseo:web_search を追加し、任意のモデルが Web を検索できるようにします。リクエストの実行、検索の計数と課金は phaseo:web_search ツールを使った場合とまったく同じです。リクエストにすでに Web 検索ツールがある場合、プラグインは何も追加しません。その他のオプションは無視されます。
- Option 1
- Option 2
- Option 3
Show child attributes
Show child attributes
ツール選択の方法です。Phaseo サーバーツールのタイプを受け付け、上流の関数またはツールの指定に変換します。allowed_tools オブジェクトは、すべてのツールとともに OpenAI にそのまま送られます。その他のプロバイダーには、許可されたツールとそのモード(auto または required)だけが送られ、required で許可されるツールが 1 つだけの場合はそのツールの呼び出しが強制されます。tools に定義されていないツールが allowed_tools に含まれる場合、リクエストを処理できるのは OpenAI だけです。それ以外の場合は 400 エラーが返されます。
auto, none, required, phaseo:datetime, phaseo:web_search, phaseo:web_fetch, phaseo:subagent, phaseo:fusion, phaseo:search_models, gateway:datetime, gateway:web_search, gateway:web_fetch レスポンス
応答
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'openai/gpt-5-nano',
stream: false,
input: [{role: 'user', content: 'Give me the current datetime in Asia/Tokyo.'}],
tools: [{type: 'gateway:datetime', parameters: {timezone: 'Asia/Tokyo'}}],
tool_choice: 'auto'
})
};
fetch('https://api.phaseo.app/v1/responses', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.phaseo.app/v1/responses"
payload = {
"model": "openai/gpt-5-nano",
"stream": False,
"input": [
{
"role": "user",
"content": "Give me the current datetime in Asia/Tokyo."
}
],
"tools": [
{
"type": "gateway:datetime",
"parameters": { "timezone": "Asia/Tokyo" }
}
],
"tool_choice": "auto"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://api.phaseo.app/v1/responses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "openai/gpt-5-nano",
"stream": false,
"input": [
{
"role": "user",
"content": "Give me the current datetime in Asia/Tokyo."
}
],
"tools": [
{
"type": "gateway:datetime",
"parameters": {
"timezone": "Asia/Tokyo"
}
}
],
"tool_choice": "auto"
}
'package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.phaseo.app/v1/responses"
payload := strings.NewReader("{\n \"model\": \"openai/gpt-5-nano\",\n \"stream\": false,\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": \"Give me the current datetime in Asia/Tokyo.\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"gateway:datetime\",\n \"parameters\": {\n \"timezone\": \"Asia/Tokyo\"\n }\n }\n ],\n \"tool_choice\": \"auto\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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.phaseo.app/v1/responses")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"openai/gpt-5-nano\",\n \"stream\": false,\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": \"Give me the current datetime in Asia/Tokyo.\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"gateway:datetime\",\n \"parameters\": {\n \"timezone\": \"Asia/Tokyo\"\n }\n }\n ],\n \"tool_choice\": \"auto\"\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.phaseo.app/v1/responses",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'openai/gpt-5-nano',
'stream' => false,
'input' => [
[
'role' => 'user',
'content' => 'Give me the current datetime in Asia/Tokyo.'
]
],
'tools' => [
[
'type' => 'gateway:datetime',
'parameters' => [
'timezone' => 'Asia/Tokyo'
]
]
],
'tool_choice' => 'auto'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api.phaseo.app/v1/responses")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"openai/gpt-5-nano\",\n \"stream\": false,\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": \"Give me the current datetime in Asia/Tokyo.\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"gateway:datetime\",\n \"parameters\": {\n \"timezone\": \"Asia/Tokyo\"\n }\n }\n ],\n \"tool_choice\": \"auto\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "<string>",
"created": 123,
"model": "<string>",
"provider": "<string>",
"provider_id": "<string>",
"nativeResponseId": "<string>",
"status": "completed",
"finish_reason": "<string>",
"meta": {},
"cost_nanos": 123,
"cost_cents": 123,
"currency": "<string>",
"pricing_lines": [
{}
],
"output": [
{
"type": "<string>",
"id": "<string>",
"role": "<string>",
"content": [
{
"type": "output_text",
"text": "<string>",
"annotations": [
{}
]
}
],
"call_id": "<string>",
"name": "<string>",
"arguments": "<string>",
"summary": [
{
"type": "summary_text",
"text": "<string>"
}
],
"encrypted_content": "<string>"
}
],
"output_items": [
{
"type": "<string>",
"id": "<string>",
"role": "<string>",
"content": [
{
"type": "output_text",
"text": "<string>",
"annotations": [
{}
]
}
],
"call_id": "<string>",
"name": "<string>",
"arguments": "<string>",
"summary": [
{
"type": "summary_text",
"text": "<string>"
}
],
"encrypted_content": "<string>"
}
],
"content": [
{}
],
"role": "<string>",
"stop_reason": "<string>",
"type": "<string>",
"usage": {
"prompt_tokens": 123,
"prompt_tokens_details": {
"cached_tokens": 123,
"cache_write_tokens": 123,
"cache_write_tokens_details": {
"ttl_30m_tokens": 123,
"ttl_12h_tokens": 123
}
},
"completion_tokens": 123,
"input_tokens": 123,
"input_tokens_details": {
"cached_tokens": 123,
"cache_write_tokens": 123,
"cache_write_tokens_details": {
"ttl_30m_tokens": 123,
"ttl_12h_tokens": 123
}
},
"output_tokens": 123,
"total_tokens": 123,
"server_tool_use": {
"datetime_requests": 1,
"web_search_requests": 1,
"subagent_requests": 1,
"fusion_requests": 1,
"search_models_requests": 1,
"web_fetch_requests": 1,
"advisor_requests": 1,
"image_generation_requests": 1,
"apply_patch_requests": 1
},
"cost": 0.001234567,
"cost_details": {
"upstream_inference_cost": null
}
}
}{
"error": {
"code": "validation_error",
"message": "Unknown parameter: foo",
"type": "invalid_request_error",
"param": "foo"
},
"ok": false,
"code": "validation_error",
"message": "Human-readable error message",
"description": "Additional error details.",
"generation_id": "G-abc123",
"status_code": 502,
"error_type": "system",
"error_origin": "upstream",
"reason": "all_candidates_failed",
"attempt_count": 2,
"failed_providers": [
"google-ai-studio",
"openai"
],
"failed_statuses": [
403,
429
],
"upstream_error": {
"code": "PERMISSION_DENIED",
"message": "The caller does not have permission.",
"description": "<string>",
"param": "<string>"
},
"failure_sample": [
{
"provider": "<string>",
"type": "<string>",
"status": 123,
"upstream_error_code": "<string>",
"upstream_error_message": "<string>",
"upstream_error_description": "<string>",
"upstream_error_param": "<string>",
"upstream_payload_preview": "<string>",
"retryable": true
}
],
"provider_failure_diagnostics": {
"category": "credentials_not_configured",
"hint": "<string>",
"provider": "<string>"
},
"routing_diagnostics": {
"filterStages": [
{
"stage": "<string>",
"beforeCount": 123,
"afterCount": 123,
"droppedProviders": [
{
"providerId": "<string>",
"reason": "<string>"
}
]
}
]
},
"provider_candidate_diagnostics": {
"totalProviders": 123,
"supportsEndpointCount": 123,
"candidateCount": 123,
"droppedUnsupportedEndpoint": [
"<string>"
],
"droppedMissingAdapter": [
{
"providerId": "<string>",
"endpoint": "<string>"
}
]
},
"provider_enablement": {
"capability": "<string>",
"providersBefore": [
"<string>"
],
"providersAfter": [
"<string>"
],
"dropped": [
{
"providerId": "<string>",
"reason": "<string>"
}
]
},
"missing_pricing_providers": [
"<string>"
],
"provider_payment_required_provider": "openai",
"provider_payment_required_support_notice": "Our upstream provider billing appears to be unavailable. If this persists, contact support.",
"details": [
{}
]
}