Skip to main content
POST
/
messages
Create message
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.ai/v1/messages', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
import requests

url = "https://api.phaseo.ai/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.ai/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.ai/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.ai/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.ai/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.ai/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": [
    {
      "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 accepts Anthropic Messages API payloads and returns Anthropic-formatted responses.

Streaming

Set stream: true to receive server-sent events in Anthropic format (message_start, content_block_*, message_delta, message_stop).

Notes

  • Anthropic tool-use fields are supported.
  • stream: true also works with tool loops. For gateway-managed server tools, Phaseo may materialize the upstream tool-call turn, continue the loop, and re-emit a synthetic stream.
  • The Anthropic-native web search tool shape is also accepted directly in tools, for example type: "web_search_20250305".
  • The X-Phaseo-Strictness header controls how unsupported parameters are handled.

Server tools

/v1/messages also supports these gateway-managed server tools:
  • gateway:datetime
  • phaseo:web_search
  • phaseo:web_fetch
  • phaseo:advisor
  • phaseo:image_generation
Phaseo rewrites these tools to Anthropic-compatible format upstream, executes them server-side, and continues the tool loop. When a compatible Anthropic model/provider pair supports native web search, you can also pass the native tool definition through directly:
curl https://api.phaseo.ai/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" }
  }'
Provider routing still filters for web_search_options support before execution.

Datetime example

curl https://api.phaseo.ai/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" }
  }'
When used, the usage.server_tool_use.* counters report server-tool invocations.

Authorizations

Authorization
string
header
required

Bearer token authentication

Body

application/json
model
string
required
messages
object[]
required
Minimum array length: 1
max_tokens
integer
required
Required range: x >= 1
system
temperature
number
Required range: 0 <= x <= 1
top_p
number
Required range: 0 <= x <= 1
top_k
integer
Required range: x >= 1
tools
object[]

Anthropic-compatible tools plus gateway server tools. The only built-in gateway server tools are gateway:datetime, gateway:web_search, and gateway:web_fetch.

tool_choice

Anthropic tool choice object/string. gateway:datetime, gateway:web_search, and gateway:web_fetch are also accepted and rewritten by the gateway.

stream
boolean
metadata
object
session_id
string

Unique identifier for grouping related requests (for example, a conversation or agent workflow) for observability.

Maximum string length: 256
reasoning
object
stop_sequences
string[]
provider_options
object

Optional provider-specific options.

usage
boolean
meta
boolean
echo_upstream_request
boolean
debug
object

Gateway debug controls. These flags are never forwarded upstream.

provider
object

Provider routing preferences for gateway selection.

Response

Message response

id
string
type
string
role
enum<string>
Available options:
assistant
model
string
content
object[]
stop_reason
string
stop_sequence
string
usage
object
Last modified on July 9, 2026