API REFERENCE
Start Chat Run
On this page
/api/chat/runsStart an asynchronous, headless chat-generation run on the durable agent workflow — the same engine as interactive POST /api/chat.
Related endpoints
- POST /api/chat — use that for interactive, streaming turns on an existing chat; use this for headless/programmatic runs (no browser or pre-provisioned session needed).
- GET /api/chat/runs/{runId} — poll to learn whether the run finished (and if it succeeded).
- GET /api/chat/{chatId}/stream — watch the output live by passing the returned chatId.
Authentication
x-api-key in header
Request
curl --request POST \
--url 'https://api.recoupable.dev/api/chat/runs' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"prompt": "string",
"messages": [
{
"id": "string",
"role": "user",
"content": "string"
}
],
"artistId": "YOUR_ID",
"model": "openai/gpt-5-mini",
"trigger_run_id": "run_06g3i0e3logru439uh9e1m8801"
}'Try it
Fill in the fields, send the request from your browser, and read the live response. The curl below updates as you type.
Kept in this browser tab only and cleared when it closes.
curl --request POST \
--url 'https://recoup-api.vercel.app/api/chat/runs' \
--header 'Content-Type: application/json' \
--data '{
"prompt": "string",
"messages": [
{
"id": "string",
"role": "user",
"content": "string"
}
],
"artistId": "YOUR_ID",
"model": "openai/gpt-5-mini",
"trigger_run_id": "run_06g3i0e3logru439uh9e1m8801"
}'Request body required
Chat generation request
application/json
promptstringSingle text prompt for the assistant. Required if 'messages' is not provided.
messagesarray<UIMessage>Array of UIMessage objects for context. Required if 'prompt' is not provided.
Item properties for messages
idstringUnique identifier for the message
rolestring · enumThe role of the message sender
Values: "user", "assistant", "system"
contentstringThe text content of the message
artistIdstringThe unique identifier of the artist (optional)
format: uuid
modelstringThe AI model to use for text generation (optional)
trigger_run_idstringOptional. When the run is kicked off by a Trigger.dev scheduled task, the Trigger run id (run_...). The started workflow's { sessionId, chatId, workflowRunId } are written to that Trigger run's metadata so the scheduled run can be traced to the chat that did the work.
Responses
202Run accepted. A durable workflow run was started; runId identifies it. chatId / sessionId identify the persisted output — read the result via GET /api/chat/{chatId}/stream (resume the stream) or the chat's persisted messages. Poll GET /api/chat/runs/{runId} for status.+
Locationresponse headerRelative URL of the run-status resource for the started run.
application/json
runIdstringrequiredDurable workflow run id for the started generation. Same identifier surfaced as the x-workflow-run-id header on interactive POST /api/chat.
chatIdstringrequiredChat the run writes its assistant messages to. Use with GET /api/chat/{chatId}/stream to resume the stream, or to fetch the persisted messages.
format: uuid
sessionIdstringrequiredSession (workspace + sandbox) provisioned for the run.
format: uuid
400Bad request - missing required parameters+
application/json
statusstring · enumrequiredStatus of the request
Values: "error"
messagestringrequiredError message describing what went wrong
Full specification
Download the OpenAPI file for complete schemas, constraints, and examples.
Download research.jsonView operation source
{
"description": "Start an asynchronous, headless chat-generation run on the durable agent workflow — the same engine as interactive [`POST /api/chat`](/api-reference/chat/workflow).\n\n**Related endpoints**\n- [`POST /api/chat`](/api-reference/chat/workflow) — use that for **interactive, streaming** turns on an existing chat; use this for **headless/programmatic** runs (no browser or pre-provisioned session needed).\n- [`GET /api/chat/runs/{runId}`](/api-reference/chat/runs-status) — poll to learn **whether** the run finished (and if it succeeded).\n- [`GET /api/chat/{chatId}/stream`](/api-reference/chat/workflow-stream) — **watch the output live** by passing the returned `chatId`.",
"security": [
{
"apiKeyAuth": []
}
],
"requestBody": {
"description": "Chat generation request",
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ChatGenerateRequest"
}
}
}
},
"responses": {
"202": {
"description": "Run accepted. A durable workflow run was started; `runId` identifies it. `chatId` / `sessionId` identify the persisted output — read the result via [`GET /api/chat/{chatId}/stream`](/api-reference/chat/workflow-stream) (resume the stream) or the chat's persisted messages. Poll [`GET /api/chat/runs/{runId}`](/api-reference/chat/runs-status) for status.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ChatGenerateAcceptedResponse"
}
}
},
"headers": {
"Location": {
"description": "Relative URL of the run-status resource for the started run.",
"schema": {
"type": "string",
"format": "uri-reference"
},
"example": "/api/chat/runs/wrun_01KVWZNM82NA7XKNEWWHG8VPHJ"
}
}
},
"400": {
"description": "Bad request - missing required parameters",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ChatGenerateErrorResponse"
}
}
}
}
}
}