POST
/
api
/
project
/
{projectId}
/
integration
/
vapi
/
chat
/
completions
curl --request POST \
  --url https://app.pathors.com/api/project/{projectId}/integration/vapi/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "messages": [
    {}
  ],
  "stream": true,
  "call": {},
  "phoneNumber": {},
  "customer": {}
}'
{
  "id": "<string>",
  "object": "<string>",
  "created": 123,
  "model": "<string>",
  "choices": [
    {}
  ],
  "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.

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"
  }
}

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

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"
}

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

Session Management

The VAPI integration automatically manages sessions based on the call ID. It will:

  1. Look up existing sessions for returning callers
  2. Create new sessions for first-time callers
  3. Maintain conversation context throughout the call