संदेश बनाएँ
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 endpoint।
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 payload स्वीकार करता है और Anthropic फ़ॉर्मैट में प्रतिक्रिया देता है।
स्ट्रीमिंग
Anthropic फ़ॉर्मैट में server-sent events (message_start, content_block_*, message_delta, message_stop) पाने के लिए stream: true सेट करें।
ध्यान दें
- Anthropic tool-use fields समर्थित हैं।
stream: truetool loops के साथ भी काम करता है। Gateway-प्रबंधित server tools के लिए Phaseo upstream turn को materialize करके loop जारी रख सकता है और synthetic stream फिर से भेज सकता है।- Anthropic-native web search tool shape को
toolsमें सीधे भी दिया जा सकता है, जैसेtype: "web_search_20250305"। X-Phaseo-Strictnessheader तय करता है कि असमर्थित parameters को कैसे संभालना है।
सर्वर टूल
/v1/messages इन Gateway-प्रबंधित server tools को भी सपोर्ट करता है:
gateway:datetimephaseo:web_searchphaseo:web_fetchphaseo:advisorphaseo:image_generation
प्रदाता की native web search
जब कोई संगत Anthropic model/provider जोड़ी native web search सपोर्ट करती है, तो आप native tool definition सीधे भी भेज सकते हैं: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 support की जाँच करता है।
दिनांक और समय का उदाहरण
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.* counters server-tool invocations बताते हैं।प्राधिकरण
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 टूल चयन का object या string। गेटवे-प्रबंधित सर्वर टूल नाम भी स्वीकार किए जाते हैं और गेटवे द्वारा बदले जाते हैं।
ऑब्ज़र्वेबिलिटी के लिए संबंधित अनुरोधों (जैसे बातचीत या एजेंट वर्कफ़्लो) को समूहित करने वाला विशिष्ट पहचानकर्ता।
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
अंतिम संशोधन 2 अक्टूबर 2026
वाज़ दिस पेज हेल्पफुल