Skip to main content

Overview

The Chat API lets you embed a TalkifAI text agent as a chat interface in any website or application. It uses standard REST + Server-Sent Events (SSE) streaming — no WebRTC or microphone required.
Text agents only. This API requires agents with text architecture. Voice agents (Pipeline/Realtime) cannot be used here.
Base URL:
Authentication — two tokens used at different stages:
Full integration tutorial with code examples → Chat API Guide

Endpoints


Create Session

Request body:
Response:
Make this call from your backend server only. Never expose your API key in frontend JavaScript.

Send Message

Request body:
Response: Server-Sent Events (SSE) stream (Content-Type: text/event-stream) Each SSE event has a named event: field followed by a data: line, separated by a blank line:

SSE Event Types

Parsing the Stream

SSE events are separated by blank lines (\n\n). Each event block contains event: and data: lines. Parse them together — do not rely on the data: line alone to determine event type.

Get Message History

Query parameters: Response:

End Session

Always end sessions explicitly to trigger memory ingestion, post-call analysis, and webhooks.
What happens:
  1. Billing session closed and credits consumed
  2. Memory ingested into Graphiti (for returning user context)
  3. Post-call analysis triggered (if configured on agent)
  4. Webhook fired (if agent has webhook configured)
Response:
Sessions automatically expire after 30 minutes of inactivity. Always call /end explicitly to ensure memory ingestion and webhooks fire correctly.

Error Codes


Session Lifecycle

Sessions expire automatically after 30 minutes of inactivity, even without calling /end. However, calling /end is required to trigger billing finalization, memory ingestion, and post-call analysis.