Skip to main content
POST
/
chat
/
completions
Create chat completion
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    model: 'openai/gpt-5-nano',
    stream: false,
    messages: [{role: 'user', content: 'What is the current datetime in Europe/London?'}],
    tools: [{type: 'gateway:datetime', parameters: {timezone: 'Europe/London'}}],
    tool_choice: 'auto'
  })
};

fetch('https://api.phaseo.ai/v1/chat/completions', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
import requests

url = "https://api.phaseo.ai/v1/chat/completions"

payload = {
"model": "openai/gpt-5-nano",
"stream": False,
"messages": [
{
"role": "user",
"content": "What is the current datetime in Europe/London?"
}
],
"tools": [
{
"type": "gateway:datetime",
"parameters": { "timezone": "Europe/London" }
}
],
"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.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "openai/gpt-5-nano",
"stream": false,
"messages": [
{
"role": "user",
"content": "What is the current datetime in Europe/London?"
}
],
"tools": [
{
"type": "gateway:datetime",
"parameters": {
"timezone": "Europe/London"
}
}
],
"tool_choice": "auto"
}
'
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.phaseo.ai/v1/chat/completions"

payload := strings.NewReader("{\n \"model\": \"openai/gpt-5-nano\",\n \"stream\": false,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What is the current datetime in Europe/London?\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"gateway:datetime\",\n \"parameters\": {\n \"timezone\": \"Europe/London\"\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.ai/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"openai/gpt-5-nano\",\n \"stream\": false,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What is the current datetime in Europe/London?\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"gateway:datetime\",\n \"parameters\": {\n \"timezone\": \"Europe/London\"\n }\n }\n ],\n \"tool_choice\": \"auto\"\n}")
.asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.phaseo.ai/v1/chat/completions",
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,
'messages' => [
[
'role' => 'user',
'content' => 'What is the current datetime in Europe/London?'
]
],
'tools' => [
[
'type' => 'gateway:datetime',
'parameters' => [
'timezone' => 'Europe/London'
]
]
],
'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.ai/v1/chat/completions")

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 \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What is the current datetime in Europe/London?\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"gateway:datetime\",\n \"parameters\": {\n \"timezone\": \"Europe/London\"\n }\n }\n ],\n \"tool_choice\": \"auto\"\n}"

response = http.request(request)
puts response.read_body
{
  "id": "<string>",
  "nativeResponseId": "<string>",
  "object": "<string>",
  "created": 123,
  "model": "<string>",
  "provider": "<string>",
  "choices": [
    {
      "index": 123,
      "message": {
        "content": "<string>",
        "name": "<string>",
        "tool_calls": [
          {
            "id": "<string>",
            "type": "function",
            "function": {
              "name": "<string>",
              "arguments": "<string>",
              "description": "<string>",
              "parameters": {}
            }
          }
        ],
        "images": [
          {
            "type": "image_url",
            "image_url": {
              "url": "<string>"
            },
            "mime_type": "<string>"
          }
        ],
        "audios": [
          {
            "type": "audio_url",
            "audio_url": {
              "url": "<string>"
            },
            "mime_type": "<string>"
          }
        ],
        "tool_call_id": "<string>"
      }
    }
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123,
    "server_tool_use": {
      "datetime_requests": 1,
      "web_search_requests": 1,
      "web_fetch_requests": 1
    }
  }
}

Server tools

/v1/chat/completions supports regular function tools and these gateway-managed server tools:
  • gateway:datetime
  • phaseo:web_search
  • phaseo:web_fetch
  • phaseo:advisor
  • phaseo:image_generation

Datetime example

curl https://api.phaseo.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5-nano",
    "stream": false,
    "messages": [
      { "role": "user", "content": "What is the current datetime in Europe/London?" }
    ],
    "tools": [
      {
        "type": "gateway:datetime",
        "parameters": { "timezone": "Europe/London" }
      }
    ],
    "tool_choice": "auto"
  }'
When a server tool is used, usage includes:
{
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 34,
    "total_tokens": 46,
    "server_tool_use": {
      "datetime_requests": 1
    }
  }
}
phaseo:web_search adds server_tool_use.web_search_requests, server_tool_use.web_search_results, and server_tool_use.web_search_extra_results. phaseo:web_fetch adds server_tool_use.web_fetch_requests.

Streaming note

stream: true is also supported. For gateway-managed server tools, Phaseo may materialize the upstream tool-call turn and re-emit a synthetic stream after continuing the loop.

Authorizations

Authorization
string
header
required

Bearer token authentication

Body

application/json
model
string
required
messages
object[]
required
Minimum array length: 1
reasoning
object
frequency_penalty
number
Required range: -2 <= x <= 2
logit_bias
object
max_completion_tokens
integer
Required range: x >= 1
max_tokens
integer
Required range: x >= 1
metadata
object
session_id
string

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

Maximum string length: 256
presence_penalty
number
Required range: -2 <= x <= 2
seed
integer
Required range: -9223372036854776000 <= x <= 9223372036854776000
store
boolean
stream
boolean
default:false
stream_options
object
temperature
number
default:1
Required range: 0 <= x <= 2
tools
object[]

Tool definitions for model function calls and gateway server tools. Built-in gateway server tools are gateway:datetime, gateway:web_search, and gateway:web_fetch.

max_tool_calls
integer
Required range: x >= 1
parallel_tool_calls
boolean
default:true
tool_choice

Tool selection strategy. gateway:datetime, gateway:web_search, and gateway:web_fetch are accepted and rewritten by the gateway into upstream function/tool targets.

Available options:
auto,
none,
required,
gateway:datetime,
gateway:web_search,
gateway:web_fetch
logprobs
boolean
default:false
top_logprobs
integer
Required range: 0 <= x <= 20
top_p
number
Required range: 0 <= x <= 1
stop
response_format
modalities
enum<string>[]
Available options:
text,
image,
audio
image_config
object
usage
boolean
provider
object

Provider routing preferences for gateway selection.

provider_options
object

Optional provider-specific options.

user_id
string
user
string
service_tier
enum<string>
Available options:
standard,
priority,
flex,
batch
prompt_cache_key
string | null
safety_identifier
string | null
meta
boolean
default:false
echo_upstream_request
boolean
debug
object

Gateway debug controls. These flags are never forwarded upstream.

Response

200 - application/json

Chat completion response

id
string
nativeResponseId
string | null
object
string
created
integer
model
string
provider
string
choices
object[]
usage
object
Last modified on July 9, 2026