Interns

Stream a chat completion with an intern

Sends a prompt to one of your interns and streams the reply as OpenAI-compatible server-sent events ending with [DONE]. The run executes on the intern, which may pause to ask you something. It then streams one openrouter.provide_input tool call and finishes with finish_reason: "tool_calls", and the run stays open on the intern.

Every response, whether it ends with stop, tool_calls or error, is followed by a final chunk with empty choices that carries session_id, then data: [DONE]. That chunk carries the usage the intern reported for the run, after stop or error, and null when the intern reported none. After tool_calls its usage is null because the turn is not over. Read through [DONE]: the session_id you need to reply arrives after the tool_calls finish chunk.

To answer, send a second request with the same session_id, the assistant message echoing that tool call, and a tool message whose tool_call_id is the tool call id and whose content is the answer. The answer is delivered to the run that asked and the stream continues from where it paused. A question stays open for its interaction deadline (5 minutes by default) and the run is cancelled when that passes. Rejected replies do not extend the deadline.

Closing the connection after the [DONE] that follows finish_reason: "tool_calls" keeps the run alive. Disconnecting while a response is still streaming cancels the run. The disconnect is noticed when the intern next writes to the stream, which during a silent tool run can take more than one 30 second heartbeat interval.

A run the intern ends while you are still connected, by cancellation or by a deadline, ends the stream with a finish_reason: "error" chunk carrying 410 and reason run_ended, then the final empty-choices chunk and [DONE]. That error reports only an ending the intern confirmed. A connection that breaks without that confirmation ends with reason stream_severed, and a client that has already disconnected is promised no final event.

Set approval_mode to manual to have the intern ask before approval-bearing tools such as the shell. Omitted, the run self-drives and consents on your behalf. The mode belongs to the run started by that prompt and must be repeated on later prompts.

Available to interns programme members. Callers outside the programme receive 404 for every path under /api/v1/interns.

post/interns/{internId}/chat/completions

Path parameters

internIdstring required

The intern to talk to.

Example:a11e0000-0000-4000-8000-000000000005

The intern to talk to.

Request body

approval_mode'manual' | 'self-drive'

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.

modelstring

Accepted for OpenAI compatibility and ignored. Streamed chunks report the model the intern actually used, or openrouter/intern when it did not report one.

session_idstring

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.

streamtrue required

Must be true. This endpoint only streams.

Example request

{
  "approval_mode": "manual",
  "messages": [
    {
      "content": "Summarize the open pull requests.",
      "role": "user"
    }
  ],
  "stream": true
}

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].

Changes