chatapi

module
v0.1.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2026 License: MIT

README

ChatAPI

Real-time chat infrastructure for AI-powered apps.

Go version License Release CI

Docs · Quick Start · API Reference · AI Bots


ChatAPI is a self-hosted messaging server for apps where AI participates in conversations. It handles real-time delivery, message history, presence, typing indicators, and LLM streaming — so you focus on your product, not the plumbing.

Users connect over WebSocket. When a message is sent in a room that has a bot, ChatAPI calls your backend webhook to get the system prompt, then calls the LLM and streams the response back token by token. Your backend stays in control of context — RAG results, customer data, escalation logic — without managing a separate agent process.

Features

  • Managed AI bots — register a bot with an LLM provider URL; ChatAPI calls the model, streams tokens back via message.stream.* events, and stores the reply
  • Real-time messaging — rooms (DM or group) with presence, typing indicators, and at-least-once delivery
  • JWT auth — your backend signs tokens, ChatAPI validates them; no vendor accounts, no sessions
  • Offline delivery — messages queue for offline users; webhook fires so you can send push notifications
  • Escalation support — webhook can return {"skip": true} to silence a bot when a human agent takes over
  • Single binary — SQLite included, no external services required
  • Portable — swap SQLite → PostgreSQL or local pub/sub → Redis by implementing one interface

Get started

Full setup guide, configuration reference, and API docs at docs.chatapi.cloud.

See AI Bots in the docs for a full walkthrough.

Deploy

Docker Compose, single binary, and reverse proxy setup — see docs.chatapi.cloud/deploy.

Contributing

Requires Go 1.22+ and gcc (for the SQLite driver).

git clone https://github.com/getchatapi/chatapi.git
cd chatapi
go build -o bin/chatapi ./cmd/chatapi
export JWT_SECRET=$(openssl rand -base64 32)
export ALLOWED_ORIGINS="*"
./bin/chatapi

Run tests: go test ./...

License

MIT — see LICENSE.

Directories

Path Synopsis
cmd
chatapi command
internal
auth
Package auth provides JWT validation for ChatAPI.
Package auth provides JWT validation for ChatAPI.
db
services/bot
Package bot manages registered AI bot participants and their LLM triggering.
Package bot manages registered AI bot participants and their LLM triggering.
testutil
Package testutil provides helpers for setting up test infrastructure.
Package testutil provides helpers for setting up test infrastructure.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL