POST
/
api
/
project
/
{projectId}
/
integration
/
vapi
/
chat
/
completions
VAPI Integration
curl --request POST \
  --url https://app.pathors.com/api/project/{projectId}/integration/vapi/chat/completions \
  --header 'Content-Type: application/json' \
  --data '{
  "messages": [
    {}
  ],
  "stream": true,
  "tools": [
    {}
  ],
  "call": {},
  "phoneNumber": {},
  "customer": {}
}'
{
  "id": "<string>",
  "object": "<string>",
  "created": 123,
  "model": "<string>",
  "choices": [
    {}
  ],
  "choices[].message.tool_calls": [
    {}
  ],
  "choices[].finish_reason": "<string>",
  "session_id": "<string>"
}

VAPI Integration

The VAPI integration provides a chat completions endpoint specifically designed for handling phone call conversations through the Voice API service.

Chat Completions

POST /api/project/{projectId}/integration/vapi/chat/completions

Path Parameters

projectId
string
required
The ID of your project

Request Body

messages
array
required
Array of messages in the conversation. Each message should have a role (“system”, “user”, or “assistant”) and content.
stream
boolean
Whether to stream the response. Defaults to false.
tools
array
Array of external tool definitions that will be available for the assistant to use during the phone call. Each tool should have a type (currently only “function” is supported) and a function object with name, description, and parameters (JSON Schema format).
call
object
required
Information about the current call session.
{
  id: string;          // Call ID
  orgId: string;       // Organization ID
  createdAt: string;   // Call creation timestamp
  updatedAt: string;   // Call update timestamp
  type: string;        // Call type
  status: string;      // Call status
  assistantId: string; // Assistant ID
  customer?: {
    number: string;    // Customer phone number
  };
  phoneNumberId?: string;        // Phone number ID
  phoneCallProvider?: string;    // Call provider (e.g., Twilio)
  phoneCallProviderId?: string;  // Provider-specific call ID
  phoneCallTransport?: string;   // Call transport method
}
phoneNumber
object
Optional phone number configuration.
{
  id: string;              // Phone number ID
  orgId: string;           // Organization ID
  number: string;          // Phone number
  createdAt: string;       // Creation timestamp
  updatedAt: string;       // Update timestamp
  twilioAccountSid: string;// Twilio account SID
  twilioAuthToken: string; // Twilio auth token
  name: string;            // Phone number name
  provider: string;        // Phone provider
}
customer
object
Optional customer information.
{
  number: string;  // Customer phone number
}
Example request:
{
  "messages": [
    {
      "role": "user",
      "content": "Hello!"
    }
  ],
  "stream": false,
  "call": {
    "id": "call_abc123",
    "orgId": "org_xyz789",
    "type": "inbound",
    "status": "in-progress",
    "assistantId": "asst_def456"
  }
}
Example request with tools:
{
  "messages": [
    {
      "role": "user",
      "content": "Can you check my account status?"
    }
  ],
  "stream": false,
  "call": {
    "id": "call_abc123",
    "orgId": "org_xyz789",
    "type": "inbound",
    "status": "in-progress",
    "assistantId": "asst_def456",
    "customer": {
      "number": "+1234567890"
    }
  },
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "check_account_status",
        "description": "Check customer account status and information",
        "parameters": {
          "type": "object",
          "properties": {
            "customer_phone": {
              "type": "string",
              "description": "Customer's phone number"
            }
          },
          "required": ["customer_phone"]
        }
      }
    }
  ]
}

Response

The response format is identical to the API integration’s chat completions endpoint, with the addition of session management for phone calls.
id
string
Unique identifier for the completion
object
string
Object type (“chat.completion”)
created
number
Unix timestamp of when the completion was created
model
string
Model used for the completion
choices
array
Array of completion choices
choices[].message.tool_calls
array
Array of tool calls made by the assistant (when tools are provided and used)
choices[].finish_reason
string
Reason for completion termination. Can be “stop” for normal completion or “tool_calls” when tools are invoked.
session_id
string
Session ID for the conversation
Example response:
{
  "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"
}
Example response with tool calls:
{
  "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": "check_account_status",
              "arguments": "{\"customer_phone\": \"+1234567890\"}"
            }
          }
        ]
      },
      "finish_reason": "tool_calls"
    }
  ],
  "usage": {
    "prompt_tokens": -1,
    "completion_tokens": -1,
    "total_tokens": -1
  },
  "session_id": "session-xyz789"
}

Streaming Response

The streaming response format is identical to the API integration’s streaming format.

Error Responses

Status CodeDescription
400Invalid request body or missing call ID
500Internal server error

Working with Tools

When you provide tools in the VAPI request, the assistant can invoke them during the phone call conversation. The tool calling workflow is handled automatically:
  1. Tool Execution: When the assistant needs to call a tool, it will return a response with tool_calls
  2. Tool Results: You should execute the requested tools and send the results back in a follow-up request
  3. Final Response: The assistant will use the tool results to formulate its final response to the caller

Tool Message Format

After receiving tool calls, send the results back in your next request:
{
  "messages": [
    {"role": "user", "content": "Can you check my account status?"},
    {
      "role": "assistant", 
      "content": "",
      "tool_calls": [
        {
          "id": "call_123",
          "type": "function", 
          "function": {
            "name": "check_account_status",
            "arguments": "{\"customer_phone\": \"+1234567890\"}"
          }
        }
      ]
    },
    {
      "role": "tool",
      "content": "Account status: Active, Balance: $150.00",
      "tool_call_id": "call_123",
      "name": "check_account_status"
    }
  ],
  "call": {
    "id": "call_abc123",
    "orgId": "org_xyz789",
    "type": "inbound",
    "status": "in-progress", 
    "assistantId": "asst_def456"
  }
}

Session Management

The VAPI integration uses the call ID as the session identifier for conversation continuity. Each unique call ID represents a separate conversation session.