@@ -117,6 +117,95 @@ except ApiError as e:
117117 print (e.body)
118118```
119119
120+ ## Streaming
121+
122+ The SDK supports streaming responses, as well, the response will be a generator that you can loop over.
123+
124+ ``` python
125+ from humanloop import Humanloop
126+
127+ client = Humanloop(
128+ api_key = " YOUR_API_KEY" ,
129+ )
130+ response = client.prompts.call_stream(
131+ version_id = " string" ,
132+ environment = " string" ,
133+ path = " string" ,
134+ id = " string" ,
135+ messages = [
136+ {
137+ " content" : " string" ,
138+ " name" : " string" ,
139+ " tool_call_id" : " string" ,
140+ " role" : " user" ,
141+ " tool_calls" : [
142+ {
143+ " id" : " string" ,
144+ " type" : " function" ,
145+ " function" : {
146+ " name" : " string" ,
147+ " arguments" : {" key" : " value" },
148+ },
149+ }
150+ ],
151+ }
152+ ],
153+ prompt = {
154+ " model" : " string" ,
155+ " endpoint" : " complete" ,
156+ " template" : " string" ,
157+ " provider" : " openai" ,
158+ " max_tokens" : 1 ,
159+ " temperature" : 1.1 ,
160+ " top_p" : 1.1 ,
161+ " stop" : " string" ,
162+ " presence_penalty" : 1.1 ,
163+ " frequency_penalty" : 1.1 ,
164+ " other" : {" string" : {" key" : " value" }},
165+ " seed" : 1 ,
166+ " response_format" : {
167+ " type" : " json_object" ,
168+ " json_schema" : {" string" : {" key" : " value" }},
169+ },
170+ " tools" : [
171+ {
172+ " name" : " string" ,
173+ " description" : " string" ,
174+ " strict" : {" key" : " value" },
175+ " parameters" : {" key" : " value" },
176+ }
177+ ],
178+ " linked_tools" : [" string" ],
179+ " attributes" : {" string" : {" key" : " value" }},
180+ },
181+ inputs = {" string" : {" key" : " value" }},
182+ source = " string" ,
183+ metadata = {" string" : {" key" : " value" }},
184+ session_id = " string" ,
185+ parent_id = " string" ,
186+ source_datapoint_id = " string" ,
187+ batches = [" string" ],
188+ user = " string" ,
189+ prompts_call_stream_request_environment = " string" ,
190+ save = True ,
191+ provider_api_keys = {
192+ " openai" : " string" ,
193+ " ai_21" : " string" ,
194+ " mock" : " string" ,
195+ " anthropic" : " string" ,
196+ " cohere" : " string" ,
197+ " openai_azure" : " string" ,
198+ " openai_azure_endpoint" : " string" ,
199+ },
200+ num_samples = 1 ,
201+ return_inputs = True ,
202+ logprobs = 1 ,
203+ suffix = " string" ,
204+ )
205+ for chunk in response:
206+ yield chunk
207+ ```
208+
120209## Pagination
121210
122211Paginated requests will return a ` SyncPager ` or ` AsyncPager ` , which can be used as generators for the underlying object.
0 commit comments