You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,6 +127,40 @@ async def main() -> None:
127
127
asyncio.run(main())
128
128
```
129
129
130
+
## Streaming responses
131
+
132
+
We provide support for streaming responses using Server Side Events (SSE).
133
+
134
+
```python
135
+
from stagehand import Stagehand
136
+
137
+
client = Stagehand()
138
+
139
+
stream = client.sessions.act(
140
+
id="00000000-your-session-id-000000000000",
141
+
input="click the first link on the page",
142
+
stream_response=True,
143
+
)
144
+
for response in stream:
145
+
print(response.data)
146
+
```
147
+
148
+
The async client uses the exact same interface.
149
+
150
+
```python
151
+
from stagehand import AsyncStagehand
152
+
153
+
client = AsyncStagehand()
154
+
155
+
stream =await client.sessions.act(
156
+
id="00000000-your-session-id-000000000000",
157
+
input="click the first link on the page",
158
+
stream_response=True,
159
+
)
160
+
asyncfor response in stream:
161
+
print(response.data)
162
+
```
163
+
130
164
## Using types
131
165
132
166
Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:
0 commit comments