Completions API
curl --request POST \
--url https://api.pathors.com/project/{projectId}/chat/completions \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{}
],
"stream": true,
"session_id": "<string>",
"tools": [
{}
]
}
'import requests
url = "https://api.pathors.com/project/{projectId}/chat/completions"
payload = {
"messages": [{}],
"stream": True,
"session_id": "<string>",
"tools": [{}]
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({messages: [{}], stream: true, session_id: '<string>', tools: [{}]})
};
fetch('https://api.pathors.com/project/{projectId}/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pathors.com/project/{projectId}/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([
'messages' => [
[
]
],
'stream' => true,
'session_id' => '<string>',
'tools' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.pathors.com/project/{projectId}/chat/completions"
payload := strings.NewReader("{\n \"messages\": [\n {}\n ],\n \"stream\": true,\n \"session_id\": \"<string>\",\n \"tools\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.pathors.com/project/{projectId}/chat/completions")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {}\n ],\n \"stream\": true,\n \"session_id\": \"<string>\",\n \"tools\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pathors.com/project/{projectId}/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"messages\": [\n {}\n ],\n \"stream\": true,\n \"session_id\": \"<string>\",\n \"tools\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "<string>",
"created": 123,
"model": "<string>",
"choices": [
{}
],
"session_id": "<string>",
"choices[].message.tool_calls": [
{}
],
"choices[].finish_reason": "<string>"
}Deprecated APIs
Completions API
Use our OpenAI-compatible chat completions API to integrate with any platform.
POST
/
project
/
{projectId}
/
chat
/
completions
Completions API
curl --request POST \
--url https://api.pathors.com/project/{projectId}/chat/completions \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{}
],
"stream": true,
"session_id": "<string>",
"tools": [
{}
]
}
'import requests
url = "https://api.pathors.com/project/{projectId}/chat/completions"
payload = {
"messages": [{}],
"stream": True,
"session_id": "<string>",
"tools": [{}]
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({messages: [{}], stream: true, session_id: '<string>', tools: [{}]})
};
fetch('https://api.pathors.com/project/{projectId}/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pathors.com/project/{projectId}/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([
'messages' => [
[
]
],
'stream' => true,
'session_id' => '<string>',
'tools' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.pathors.com/project/{projectId}/chat/completions"
payload := strings.NewReader("{\n \"messages\": [\n {}\n ],\n \"stream\": true,\n \"session_id\": \"<string>\",\n \"tools\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.pathors.com/project/{projectId}/chat/completions")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {}\n ],\n \"stream\": true,\n \"session_id\": \"<string>\",\n \"tools\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pathors.com/project/{projectId}/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"messages\": [\n {}\n ],\n \"stream\": true,\n \"session_id\": \"<string>\",\n \"tools\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "<string>",
"created": 123,
"model": "<string>",
"choices": [
{}
],
"session_id": "<string>",
"choices[].message.tool_calls": [
{}
],
"choices[].finish_reason": "<string>"
}Deprecated. This endpoint is deprecated and will be sunset on 2026-07-11. It still works until then. Migrate to the V1 path — see the migration guide for the old -> new path table.
Base URL
https://api.pathors.com
Chat Completions
POST https://api.pathors.com/project/{projectId}/chat/completions
Path Parameters
string
required
The ID of your project
Request Headers
string
required
Bearer token authentication using your Project API Key (starts with
sk_). Format: Bearer {your-api-key}string
Session ID for conversation continuity. Strongly recommended to use this
header for passing session ID instead of the session_id parameter in the
request body.
Request Body
array
Array of messages in the conversation. Each message should have a
role
(“system”, “user”, or “assistant”) and content.boolean
Whether to stream the response. Defaults to false.
string
(deprecated) Session ID for conversation continuity. It is recommended to use
the X-Session-ID header instead. Only use this parameter in environments that
do not support custom headers.
array
Array of external tool definitions that will be available for the assistant to use.
Each tool should have a
type (currently only “function” is supported) and a function
object with name, description, and parameters (JSON Schema format).curl -X POST https://api.pathors.com/project/{projectId}/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{"messages": [{"role": "user", "content": "Hello!"}], "stream": false}'
curl -X POST https://api.pathors.com/project/{projectId}/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"messages": [{"role": "user", "content": "What's the weather in San Francisco?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather information",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city name"
}
},
"required": ["location"]
}
}
}]
}'
Response Headers
string
Session ID for the conversation. This header is returned in the response and can be used in subsequent requests.
Response
string
Unique identifier for the completion
string
Object type (“chat.completion”)
number
Unix timestamp of when the completion was created
string
Model used for the completion
array
Array of completion choices
string
Session ID for the conversation
array
Array of tool calls made by the assistant (when tools are provided and used)
string
Reason for completion termination. Can be “stop” for normal completion or “tool_calls” when tools are invoked.
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1677858242,
"model": "pathway-default",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hi! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": -1,
"completion_tokens": -1,
"total_tokens": -1
},
"session_id": "session-xyz789"
}
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1677858242,
"model": "pathway-default",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "",
"tool_calls": [
{
"id": "call_123",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"location\": \"San Francisco\"}"
}
}
]
},
"finish_reason": "tool_calls"
}
],
"usage": {
"prompt_tokens": -1,
"completion_tokens": -1,
"total_tokens": -1
},
"session_id": "session-xyz789"
}
Streaming Response
Whenstream is set to true, the response will be a stream of server-sent events (SSE). Each event contains a chunk of the response in the following format:
{
"id": "chatcmpl-abc123",
"object": "chat.completion.chunk",
"created": 1677858242,
"model": "pathway-default",
"choices": [
{
"index": 0,
"delta": {
"content": "Hi"
},
"finish_reason": null
}
],
"session_id": "session-xyz789"
}
finish_reason: "stop" and will be followed by data: [DONE].
Error Responses
| Status Code | Description |
|---|---|
| 400 | Invalid request body |
| 401 | Invalid authentication |
| 500 | Internal server error |
Working with Tools
When you provide tools in the request, the assistant can invoke them during the conversation. After receiving a response withtool_calls, you should:
- Execute the requested tools with the provided arguments
- Send the tool results back in a follow-up request with “tool” role messages
- The assistant will then use the tool results to formulate its final response
Tool Message Format
After receiving tool calls, send the results back:{
"messages": [
{"role": "user", "content": "What's the weather?"},
{
"role": "assistant",
"content": "",
"tool_calls": [
{
"id": "call_123",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"location\": \"San Francisco\"}"
}
}
]
},
{
"role": "tool",
"content": "72°F, sunny",
"tool_call_id": "call_123",
"name": "get_weather"
}
],
"session_id": "existing_session_id"
}
Setup Guide
- Go to Project Settings > API Keys and create a new API key
- Copy the key immediately (it is only shown once)
- Use the API key in the
Authorization: Bearer {your-api-key}header for your requests - (Optional) Create sessions for conversation continuity using the Session API
- (Optional) Define and provide tools for extended functionality
