Skip to content

Commit ae7ac81

Browse files
docs: Add streaming execution status with Python SDK example
1 parent b431247 commit ae7ac81

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

documentation/concepts/execution.mdx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ Example:
221221

222222
## Streaming Execution Status Updates
223223

224+
### Using the raw SSE endpoint
225+
224226
You can subscribe to real-time status updates using the Server-Sent Events (SSE) endpoint. Each event conforms to the `ExecutionStatusEvent` schema and includes the following fields:
225227

226228
- **execution_id**: The UUID of the execution.
@@ -243,7 +245,34 @@ data: {"execution_id":"068306ff-e0f3-7fe9-8000-0013626a759a","status":"running",
243245
data: {"execution_id":"068306ff-e0f3-7fe9-8000-0013626a759a","status":"succeeded","updated_at":"2025-05-23T12:56:12.054067Z","error":null,"transition_count":3,"metadata":{}}
244246
```
245247

246-
**Note:** This streaming endpoint is not yet available in the SDKs, but support is coming soon.
248+
### Using the Python SDK `AsyncClient`
249+
250+
<CodeGroup>
251+
```python Python
252+
from julep import AsyncClient
253+
254+
client = AsyncClient(api_key="YOUR_API_KEY")
255+
execution_id = "YOUR_EXECUTION_ID"
256+
257+
# Subscribe to the live status stream (async generator)
258+
status_stream = await client.executions.status.stream(execution_id=execution_id)
259+
260+
# Consume events in real-time using async for
261+
async for event in status_stream:
262+
print("Execution status:", event.status, "updated at", event.updated_at)
263+
264+
265+
```
266+
</CodeGroup>
267+
268+
<Tip>
269+
This approach relies on Python's async / await syntax. Make sure to:
270+
271+
1. Use `AsyncClient` not `Client`.
272+
2. `await client.executions.status.stream(...)` to obtain the async generator.
273+
3. Iterate with `async for` to consume events.
274+
275+
</Tip>
247276

248277
## Updating/Cancelling an Execution
249278

0 commit comments

Comments
 (0)