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.app/v1/messages', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "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
  }
}

Documentation Index

Fetch the complete documentation index at: https://docs.ai-stats.phaseo.app/llms.txt

Use this file to discover all available pages before exploring further.

Use /v1/messages to send Anthropic Messages API payloads through the gateway. The gateway normalizes your request into its internal IR, routes it to a compatible provider surface, and emits Anthropic-formatted responses.

Endpoint

POST /v1/messages

Streaming

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

Notes

  • The gateway honors the Anthropic request shape and supports tool use fields.
  • At current request-validation level, stream: true with tools is rejected with 400 invalid_request. Use non-streaming tool loops for now.
  • The X-AIStats-Strictness header controls how unsupported parameters are handled.

Server tools

/v1/messages also supports one gateway-managed server tool:
  • gateway:datetime
Web-search tool types are temporarily disabled at the gateway request layer. The gateway accepts this tool in tools, rewrites it to Anthropic-compatible tool format upstream, executes it server-side, and continues the tool loop.

Datetime example

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" }
  }'
When used, usage.server_tool_use.datetime_requests reports datetime 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 tool is gateway:datetime. Web-search tool types are temporarily disabled by the gateway.

tool_choice

Anthropic tool choice object/string. gateway:datetime is also accepted and rewritten by the gateway. Web-search tool choices are temporarily disabled.

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 April 1, 2026