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
For structured tasks like data extraction, you can force the model to return a valid JSON object using the `response_format` parameter. We use the Fireworks AI provider.
180
182
181
-
<hfoptions>
183
+
<hfoptionsid="structured">
182
184
<hfoptionid="python">
183
185
184
186
```python
@@ -301,7 +303,7 @@ The implementation is based on the open-source [huggingface/responses.js](https:
301
303
302
304
Unlike traditional text streaming, the Responses API uses a system of semantic events for streaming. This means the stream is not just raw text, but a series of structured event objects. Each event has a type, so you can listen for the specific events you care about, such as content being added (`output_text.delta`) or the message being completed (`completed). The example below shows how to iterate through these events and print the content as it arrives.
303
305
304
-
<hfoptions>
306
+
<hfoptionsid="stream">
305
307
<hfoptionid="python">
306
308
307
309
```python
@@ -327,6 +329,7 @@ for event in stream:
327
329
```
328
330
329
331
</hfoption>
332
+
330
333
<hfoptionid="javascript">
331
334
332
335
```ts
@@ -357,7 +360,7 @@ for await (const event of stream) {
357
360
358
361
You can extend the model with tools to access external data. The example below defines a get_current_weather function that the model can choose to call.
359
362
360
-
<hfoptions>
363
+
<hfoptionsid="tool-call-resp">
361
364
<hfoptionid="python">
362
365
363
366
```python
@@ -399,6 +402,7 @@ print(response)
399
402
```
400
403
401
404
</hfoption>
405
+
402
406
<hfoptionid="javascript">
403
407
404
408
```ts
@@ -445,7 +449,7 @@ console.log(response);
445
449
446
450
The API's most advanced feature is Remote MCP calls, which allow the model to delegate tasks to external services. Calling a remote MCP server with the Responses API is straightforward. For example, here's how you can use the DeepWiki MCP server to ask questions about nearly any public GitHub repository.
447
451
448
-
<hfoptions>
452
+
<hfoptionsid="mcp">
449
453
<hfoptionid="python">
450
454
451
455
```python
@@ -474,6 +478,7 @@ print(response)
474
478
```
475
479
476
480
</hfoption>
481
+
477
482
<hfoptionid="javascript">
478
483
479
484
```ts
@@ -508,7 +513,7 @@ console.log(response);
508
513
509
514
You can also control the model's "thinking" time with the `reasoning` parameter. The following example nudges the model to spend a medium amount of effort on the answer.
0 commit comments