Skip to main content
POST
Stream a chat completion with an intern

Authorizations

Authorization
string
header
required

API key as bearer token in Authorization header

Path Parameters

internId
string
required

The intern to talk to.

Example:

"a11e0000-0000-4000-8000-000000000005"

Body

application/json

An OpenAI-compatible streaming chat completion request for one intern. Other OpenAI fields such as temperature or tools are ignored. The intern owns its sampling and its tools.

messages
object[]
required

The conversation. Only the last message is read. A last user message starts a run. A last tool message answers the interaction named by its tool_call_id and requires session_id.

Minimum array length: 1

One OpenAI-compatible chat message, discriminated by role.

Example:
stream
boolean
required

Must be true. This endpoint only streams.

Example:

true

approval_mode
enum<string>

How the run started by this prompt handles tool approvals. self-drive (the default when omitted) consents on your behalf and runs the shell unsandboxed. manual asks you before an approval-bearing tool runs, as an openrouter.provide_input permission request, and keeps the shell sandboxed until an escalation is allowed. The mode applies to the run this prompt starts and is not remembered by the session. Repeat it on each new prompt that should use it. A tool reply continues the run under the mode it started with.

Available options:
manual,
self-drive
Example:

"manual"

model
string

Echoed as model on the streamed chunks; the final chunk may carry the model the intern reported instead. The intern chooses its own model, so this value does not change what runs.

Required string length: 1 - 256
Example:

"openrouter/intern"

session_id
string

The daemon session to continue, as returned in session_id on the final chunk of an earlier response. Omit it to start a new session. Required when the last message has role tool.

Required string length: 1 - 256
Example:

"ses_7f3c9a"

Response

The streamed completion. Chunks carry text, then a finish chunk: finish_reason: "stop" when the turn is complete, finish_reason: "tool_calls" when the intern is waiting for an answer, or finish_reason: "error" for a failure after this status. A final chunk with empty choices follows in every case, carrying session_id and usage (null unless the intern reported usage, and always null after tool_calls), and the stream ends with data: [DONE].

A server-sent event carrying one chunk. The stream ends with data: [DONE].

data
object
required

One data: line of the stream. A run streams a role chunk, content and reasoning chunks, then a finish chunk: stop, tool_calls (the run is paused for input) or error (with an error object). A final chunk with empty choices follows in every case, carrying session_id and usage (null unless the daemon reported usage, and always null after tool_calls). Every stream ends with [DONE].

Example: