Chat completion & streaming
POST
/v1/ai/{project_id}/chatProxies chat completions to OpenAI, Anthropic Claude, and Google Gemini with prompt injection defenses and automated fallback.
#
Request
Headers
| Header | Required | Value |
|---|---|---|
apikey | yes | Project public anon key or private service_role key |
Authorization | no | Bearer <user_jwt> |
Content-Type | yes | application/json |
Accept | no | text/event-stream (when calling /chat/stream) |
#
Request
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
messages | ChatMessage[] | yes | Array of conversation turns. Only roles user and assistant are permitted. |
system | string | no | System prompt instructing the model. Composed automatically with project-level prompt. |
provider | string | no | Target LLM provider (anthropic, openai, google). Defaults to project setting. |
model | string | no | Provider model identifier (e.g., claude-3-5-sonnet, gpt-4o). |
temperature | number | no | Sampling temperature (0.0 to 1.0). |
max_tokens | number | no | Maximum output tokens generated. |
#
Security
Prompt Injection Protection
Info
System messages are strictly forbidden inside the messages array (validate_roles). They must be passed via the system parameter. The server concatenates the project's administrator-configured system_prompt ahead of any user-supplied prompt, guaranteeing that platform policies cannot be overridden by user requests.
v1.0 · revised Oct 31, 2026