メッセージを作成
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'anthropic/claude-sonnet-4',
max_tokens: 512,
stream: false,
messages: [{role: 'user', content: 'What time is it in America/New_York right now?'}],
tools: [{type: 'gateway:datetime', parameters: {timezone: 'America/New_York'}}],
tool_choice: {type: 'auto'}
})
};
fetch('https://api.phaseo.app/v1/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.phaseo.app/v1/messages"
payload = {
"model": "anthropic/claude-sonnet-4",
"max_tokens": 512,
"stream": False,
"messages": [
{
"role": "user",
"content": "What time is it in America/New_York right now?"
}
],
"tools": [
{
"type": "gateway:datetime",
"parameters": { "timezone": "America/New_York" }
}
],
"tool_choice": { "type": "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/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "anthropic/claude-sonnet-4",
"max_tokens": 512,
"stream": false,
"messages": [
{
"role": "user",
"content": "What time is it in America/New_York right now?"
}
],
"tools": [
{
"type": "gateway:datetime",
"parameters": {
"timezone": "America/New_York"
}
}
],
"tool_choice": {
"type": "auto"
}
}
'package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.phaseo.app/v1/messages"
payload := strings.NewReader("{\n \"model\": \"anthropic/claude-sonnet-4\",\n \"max_tokens\": 512,\n \"stream\": false,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What time is it in America/New_York right now?\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"gateway:datetime\",\n \"parameters\": {\n \"timezone\": \"America/New_York\"\n }\n }\n ],\n \"tool_choice\": {\n \"type\": \"auto\"\n }\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/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"anthropic/claude-sonnet-4\",\n \"max_tokens\": 512,\n \"stream\": false,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What time is it in America/New_York right now?\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"gateway:datetime\",\n \"parameters\": {\n \"timezone\": \"America/New_York\"\n }\n }\n ],\n \"tool_choice\": {\n \"type\": \"auto\"\n }\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.phaseo.app/v1/messages",
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' => 'anthropic/claude-sonnet-4',
'max_tokens' => 512,
'stream' => false,
'messages' => [
[
'role' => 'user',
'content' => 'What time is it in America/New_York right now?'
]
],
'tools' => [
[
'type' => 'gateway:datetime',
'parameters' => [
'timezone' => 'America/New_York'
]
]
],
'tool_choice' => [
'type' => '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/messages")
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\": \"anthropic/claude-sonnet-4\",\n \"max_tokens\": 512,\n \"stream\": false,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What time is it in America/New_York right now?\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"gateway:datetime\",\n \"parameters\": {\n \"timezone\": \"America/New_York\"\n }\n }\n ],\n \"tool_choice\": {\n \"type\": \"auto\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"type": "<string>",
"role": "assistant",
"model": "<string>",
"content": [
{
"type": "text",
"text": "<string>",
"cache_control": {
"type": "<string>",
"ttl": "<string>",
"scope": "<string>"
},
"source": {
"type": "<string>",
"media_type": "<string>",
"data": "<string>",
"url": "<string>"
},
"id": "<string>",
"name": "<string>",
"input": {},
"tool_use_id": "<string>",
"content": "<string>"
}
],
"stop_reason": "<string>",
"stop_sequence": "<string>",
"usage": {
"input_tokens": 123,
"output_tokens": 123
}
}Anthropic Messages
メッセージを作成
/v1/messages の Anthropic 互換 Messages エンドポイントです。
POST
/
messages
メッセージを作成
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'anthropic/claude-sonnet-4',
max_tokens: 512,
stream: false,
messages: [{role: 'user', content: 'What time is it in America/New_York right now?'}],
tools: [{type: 'gateway:datetime', parameters: {timezone: 'America/New_York'}}],
tool_choice: {type: 'auto'}
})
};
fetch('https://api.phaseo.app/v1/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.phaseo.app/v1/messages"
payload = {
"model": "anthropic/claude-sonnet-4",
"max_tokens": 512,
"stream": False,
"messages": [
{
"role": "user",
"content": "What time is it in America/New_York right now?"
}
],
"tools": [
{
"type": "gateway:datetime",
"parameters": { "timezone": "America/New_York" }
}
],
"tool_choice": { "type": "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/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "anthropic/claude-sonnet-4",
"max_tokens": 512,
"stream": false,
"messages": [
{
"role": "user",
"content": "What time is it in America/New_York right now?"
}
],
"tools": [
{
"type": "gateway:datetime",
"parameters": {
"timezone": "America/New_York"
}
}
],
"tool_choice": {
"type": "auto"
}
}
'package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.phaseo.app/v1/messages"
payload := strings.NewReader("{\n \"model\": \"anthropic/claude-sonnet-4\",\n \"max_tokens\": 512,\n \"stream\": false,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What time is it in America/New_York right now?\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"gateway:datetime\",\n \"parameters\": {\n \"timezone\": \"America/New_York\"\n }\n }\n ],\n \"tool_choice\": {\n \"type\": \"auto\"\n }\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/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"anthropic/claude-sonnet-4\",\n \"max_tokens\": 512,\n \"stream\": false,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What time is it in America/New_York right now?\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"gateway:datetime\",\n \"parameters\": {\n \"timezone\": \"America/New_York\"\n }\n }\n ],\n \"tool_choice\": {\n \"type\": \"auto\"\n }\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.phaseo.app/v1/messages",
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' => 'anthropic/claude-sonnet-4',
'max_tokens' => 512,
'stream' => false,
'messages' => [
[
'role' => 'user',
'content' => 'What time is it in America/New_York right now?'
]
],
'tools' => [
[
'type' => 'gateway:datetime',
'parameters' => [
'timezone' => 'America/New_York'
]
]
],
'tool_choice' => [
'type' => '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/messages")
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\": \"anthropic/claude-sonnet-4\",\n \"max_tokens\": 512,\n \"stream\": false,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What time is it in America/New_York right now?\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"gateway:datetime\",\n \"parameters\": {\n \"timezone\": \"America/New_York\"\n }\n }\n ],\n \"tool_choice\": {\n \"type\": \"auto\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"type": "<string>",
"role": "assistant",
"model": "<string>",
"content": [
{
"type": "text",
"text": "<string>",
"cache_control": {
"type": "<string>",
"ttl": "<string>",
"scope": "<string>"
},
"source": {
"type": "<string>",
"media_type": "<string>",
"data": "<string>",
"url": "<string>"
},
"id": "<string>",
"name": "<string>",
"input": {},
"tool_use_id": "<string>",
"content": "<string>"
}
],
"stop_reason": "<string>",
"stop_sequence": "<string>",
"usage": {
"input_tokens": 123,
"output_tokens": 123
}
}/v1/messages は Anthropic Messages API のリクエスト形式を受け取り、Anthropic 形式の応答を返します。
ストリーミング
stream: true を設定すると、Anthropic 形式の Server-Sent Events(message_start、content_block_*、message_delta、message_stop)を受信できます。
補足
- Anthropic のツール使用フィールドに対応しています。
stream: trueはツールループでも利用できます。Gateway 管理サーバーツールでは、Phaseo が上流のターンを処理してループを続行し、合成ストリームを再送する場合があります。- Anthropic ネイティブの Web 検索ツール形式も
toolsで直接指定できます。例:type: "web_search_20250305"。 X-Phaseo-Strictnessヘッダーで、未対応パラメーターの扱いを制御します。
サーバーツール
/v1/messages は次の Gateway 管理サーバーツールにも対応しています。
gateway:datetimephaseo:web_searchphaseo:web_fetchphaseo:advisorphaseo:image_generation
プロバイダーのネイティブ Web 検索
互換性のある Anthropic モデルとプロバイダーの組み合わせがネイティブ Web 検索に対応している場合は、ネイティブのツール定義を直接渡すこともできます。curl https://api.phaseo.app/v1/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4",
"max_tokens": 512,
"messages": [
{ "role": "user", "content": "Find the latest Anthropic web search guidance." }
],
"tools": [
{
"type": "web_search_20250305",
"name": "web_search",
"max_uses": 3,
"allowed_domains": ["docs.anthropic.com"]
}
],
"tool_choice": { "type": "tool", "name": "web_search" }
}'
web_search_options の対応状況が引き続き確認されます。
日時の例
curl https://api.phaseo.app/v1/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4",
"max_tokens": 512,
"stream": false,
"messages": [
{ "role": "user", "content": "What time is it in America/New_York right now?" }
],
"tools": [
{
"type": "gateway:datetime",
"parameters": { "timezone": "America/New_York" }
}
],
"tool_choice": { "type": "auto" }
}'
usage.server_tool_use.* カウンターにサーバーツールの呼び出し回数が記録されます。承認
Bearer トークンによる認証
ボディ
application/json
Minimum array length:
1Show child attributes
Show child attributes
必須範囲:
x >= 1対応するテキスト API で、サポートされるルーティングまたは料金のティアを選択します。
利用可能なオプション:
standard, default, fast, ultrafast, priority, flex, batch 必須範囲:
0 <= x <= 1必須範囲:
0 <= x <= 1必須範囲:
x >= 1Anthropic 互換ツールと、ゲートウェイ管理のサーバーツールです。
- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
- Option 6
- Option 7
Show child attributes
Show child attributes
Anthropic のツール選択オブジェクトまたは文字列です。ゲートウェイ管理のサーバーツール名も受け付け、ゲートウェイによって書き換えられます。
関連するリクエスト(会話やエージェントのワークフローなど)を可観測性のためにまとめる一意の識別子です。
Maximum string length:
256Show child attributes
Show child attributes
任意のプロバイダー固有オプションです。
Show child attributes
Show child attributes
ゲートウェイのデバッグ設定です。これらのフラグがプロバイダーに転送されることはありません。
Show child attributes
Show child attributes
ゲートウェイでの選択に使用するプロバイダーのルーティング設定。
Show child attributes
Show child attributes
最終更新日 2026年10月2日