Stream a run
Returns the run’s stored state as server-sent events, then closes. Requires runs_read. Never calls the model, so it cannot charge.
The body is one snapshot: a state event ({run_id, state}), then, only when the run is completed or failed, a terminal event with run_id, state, input_digest and output_digest (possibly null). A completed run’s terminal event adds kind and the whole verdict or decision. There are no partial-answer events, no id: or retry: fields, and Last-Event-ID is not read. The stream does not wait for a pending run: request it again, or poll GET /v1/runs/{run_id}. Errors before the stream starts are JSON. See Streaming.
curl --request GET \
--url https://api.opentype.dev/v1/runs/{run_id}/stream \
--header 'Authorization: Bearer <token>'const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.opentype.dev/v1/runs/{run_id}/stream', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.opentype.dev/v1/runs/{run_id}/stream"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text){
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"violations": [
"<string>"
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"violations": [
"<string>"
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"violations": [
"<string>"
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"violations": [
"<string>"
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"violations": [
"<string>"
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"violations": [
"<string>"
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"violations": [
"<string>"
]
}
}Authorizations
An API key (otsk_ + 64 hex) or a console session token.
Path Parameters
run_ followed by 32 hex characters, as the API returns it. The hyphenated form the usage routes return is also accepted.
Response
text/event-stream, sent with cache-control: no-cache, no-store. Each frame is event: <name> and one data: line of JSON.
curl --request GET \
--url https://api.opentype.dev/v1/runs/{run_id}/stream \
--header 'Authorization: Bearer <token>'const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.opentype.dev/v1/runs/{run_id}/stream', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.opentype.dev/v1/runs/{run_id}/stream"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text){
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"violations": [
"<string>"
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"violations": [
"<string>"
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"violations": [
"<string>"
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"violations": [
"<string>"
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"violations": [
"<string>"
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"violations": [
"<string>"
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"violations": [
"<string>"
]
}
}