/api/ai and are protected by authentication and rate limiting.
The AI and LLM features require the Pro or Enterprise tier. Requests from Basic tier accounts will be rejected with
403 Forbidden.Sending a chat message
Send aPOST request to /api/ai/chat with a messages array following the OpenAI-style role format. Choose your provider, model, and generation parameters. Set stream: false (the default) to receive the full response at once.
Request
Response — 200 OK
ChatRequest schema:
Streaming responses
Setstream: true in your request to receive a text/event-stream response. Each event carries a single token. The stream ends with a [DONE] sentinel.
Streaming request
EventSource or the fetch API with a ReadableStream:
Consuming SSE in JavaScript
Text completions
For single-turn generation from a plain-text prompt, usePOST /api/ai/completions. You can optionally provide a system_prompt to set context.
Request
Response — 200 OK
Supported providers
Set theprovider field in any request to switch between backends. The model name must be valid for the chosen provider.
- OpenAI
- Anthropic
- Gemini
OPENAI_API_KEY in your environment. Supported models include gpt-4o, gpt-4o-mini, gpt-4-turbo, and gpt-3.5-turbo.