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

VAPI 整合

VAPI 整合提供了一個專門設計用於透過語音 API 服務處理電話通話對話的聊天完成端點。

聊天完成

路徑參數

projectId
string
required

您的專案 ID

請求體

messages
array
required

對話中的訊息陣列。每條訊息都應該有一個 role(“system”、“user” 或 “assistant”)和 content

stream
boolean

是否流式傳輸回應。默認為 false。

call
object
required

當前通話會話的資訊。

{
  id: string;          // 通話 ID
  orgId: string;       // 組織 ID
  createdAt: string;   // 通話創建時間戳
  updatedAt: string;   // 通話更新時間戳
}

請求範例:

{
  "messages": [
    {
      "role": "user",
      "content": "你好!"
    }
  ],
  "stream": false,
  "call": {
    "id": "call_abc123",
    "orgId": "org_xyz789",
    "createdAt": "2024-03-15T08:00:00Z",
    "updatedAt": "2024-03-15T08:00:00Z"
  }
}

回應

id
string

完成的唯一標識符

object
string

物件類型(“chat.completion”)

created
number

完成創建時的 Unix 時間戳

model
string

用於完成的模型

choices
array

完成選項陣列

回應範例:

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1677858242,
  "model": "pathway-default",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "你好!我能幫你什麼忙?"
      },
      "finish_reason": "stop"
    }
  ]
}

錯誤回應

狀態碼描述
400無效的請求體
401無效的認證
500內部伺服器錯誤

設置指南

  1. 在您的 Pathors 專案設置中啟用 VAPI 整合
  2. 在您專案的整合設置中生成 API 金鑰
  3. 在您的請求中使用 API 金鑰作為 Authorization 頭部