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
The Langflow API supports streaming responses. Instead of calling `run` on a `Flow` object, you can call `stream` with the same arguments and the response will be a [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) of objects.
There are three different events: `add_message`, `token`, and `end`. The events mean:
159
+
160
+
-`add_message`: a message being added to the chat and can refer to a human input message or a response from an AI
161
+
-`token`: a token that is emitted as part of a message being generated by the flow
162
+
-`end`: all tokens have been returned, this message will also contain a full `FlowResponse`
163
+
164
+
Event objects have the format:
165
+
166
+
```typescript
167
+
{
168
+
event: "add_message"|"token"|"end",
169
+
data: object
170
+
}
171
+
```
172
+
173
+
The `event.data` is different per event type. The `token` event type is the simplest and looks like this:
174
+
175
+
```typescript
176
+
{
177
+
"event": "token",
178
+
"data": {
179
+
"chunk": "hello ",
180
+
"id": "6686ff20-0c95-40bb-8879-fd90ed3d634e",
181
+
"timestamp": "2025-02-12 22:18:04 UTC"
182
+
}
183
+
}
184
+
```
185
+
186
+
There's more [documentation and examples of a streaming response in the Langflow docs](https://docs.langflow.org/api-reference-api-examples#run-flow).
187
+
145
188
### File upload
146
189
147
190
Chat input components support files as input as well as text. You need to upload your file first, using the file upload function, then provide the file path to the flow as a tweak.
0 commit comments