POST /api/v1/playground/stream
Stream an LLM completion using a project's configured provider key. Used internally by the dashboard playground, but available to any authenticated client.
Request
POST /api/v1/playground/stream
Authorization: Bearer ts_...
Content-Type: application/json
{
"model": "gpt-4o",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Explain quicksort in one paragraph." }
],
"temperature": 0.7,
"max_tokens": 500
}Parameters
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model identifier (e.g., gpt-4o, claude-3-opus) |
messages | array | Yes | Chat messages with role and content |
temperature | number | No | Sampling temperature (0–2) |
max_tokens | number | No | Maximum tokens to generate |
Response
Returns a Server-Sent Events (SSE) stream. Each event contains a chunk of the completion:
event: token
data: {"content": "Quick"}
event: token
data: {"content": "sort"}
event: done
data: {"usage": {"prompt_tokens": 25, "completion_tokens": 150, "total_tokens": 175}}Requirements
- The project must have an LLM provider key configured for the requested model's provider.
- Provider keys are managed via the
llmKeytRPC router or the Project Settings page in the dashboard.
Errors
| Status | Meaning |
|---|---|
400 | Invalid request body or unsupported model |
401 | Invalid API key |
404 | No provider key configured for the requested model |
429 | Rate limited |
502 | LLM provider error (upstream failure) |