Copy
Ask AI
import requests
import json
url = "https://api.stack-ai.com/inference/v0/stream/{org_id}/{flow_id}"
headers = {
"Authorization": "Bearer <your-public-key>",
"Content-Type": "application/json"
}
data = json.dumps({"in-0": "message", "user_id": "conversation identifier"})
response = requests.post(url, headers=headers, data=data)
# Process streaming response
try:
for line in response.iter_lines():
if line:
decoded_line = line.decode('utf-8')
print(decoded_line) # or handle the streaming data as needed
except requests.exceptions.RequestException as e:
print(f"Error occurred: {e}")
finally:
response.close()

