Skip to main content

Overview

The Text Chat API enables developers to integrate TalkifAI text agents into websites, mobile apps, and other applications using REST + Server-Sent Events (SSE) streaming. Base URL: https://api.talkifai.dev/v1/chat Authentication:
  • Session Creation: X-API-Key or X-Studio-Token header
  • All Other Requests: Authorization: Bearer {session_token} (JWT)

Endpoints

Create Session

POST /sessions — Create a new chat session

Send Message

POST /sessions/{id}/messages — Send message (SSE stream)

Get History

GET /sessions/{id}/messages — Retrieve message history

End Session

POST /sessions/{id}/end — End session and cleanup

Create Voice Session

POST /voice-sessions — Create LiveKit voice session

Authentication

Session Creation (Server-Side)

Two authentication methods supported: Method 1: API Key
Method 2: Studio Token

All Other Requests (Client-Side)

Session tokens are JWTs returned from /sessions endpoint, valid for 24 hours.

Request/Response Models

CreateSessionRequest

CreateSessionResponse

SendMessageRequest

Message

MessagesResponse

EndSessionResponse


SSE Event Types

When sending messages, the response is streamed via Server-Sent Events:

Error Codes


Session Lifecycle

Auto-Expiry: Sessions expire after 30 minutes of inactivity.

SDK Support

Official SDKs:
  • JavaScript/TypeScript (coming soon)
  • Python (coming soon)
  • React Hook (see guide)
Community SDKs:
  • Check npm and PyPI for community-maintained packages

Rate Limits

Rate limits are per API key or session token.

CORS

Allowed Origins:
  • All origins allowed (*)
  • Configure in your API key settings
Allowed Methods:
  • GET, POST, OPTIONS
Allowed Headers:
  • Content-Type
  • Authorization
  • X-API-Key
  • X-Studio-Token
  • Origin

Webhooks

When a chat session ends, a webhook is sent if configured on the agent:

Next Steps

Create Session

Start with POST /sessions to create your first chat session.

Integration Guide

See the complete guide with React/Next.js examples.