Skip to content

Commit bbb5f75

Browse files
authored
Update use-structured-outputs.mdx
Update examples for Using structured outputs with JSON schema (manual definition or with (Pydantic) The API requires the response_format when using a json_schema to have a name attribute.
1 parent 4f27706 commit bbb5f75

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ai-data/generative-apis/how-to/use-structured-outputs.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ extract = client.chat.completions.create(
162162
response_format={
163163
"type": "json_schema",
164164
"json_schema": {
165+
"name": "VoiceNote",
165166
"schema": VoiceNote.model_json_schema(),
166167
}
167168
},
@@ -203,6 +204,7 @@ extract = client.chat.completions.create(
203204
response_format={
204205
"type": "json_schema",
205206
"json_schema": {
207+
"name": "VoiceNote",
206208
"schema": {
207209
"type": "object",
208210
"properties": {
@@ -243,4 +245,4 @@ By choosing between JSON mode and Structured outputs with JSON schema, you contr
243245
- **JSON mode** is flexible but less predictable.
244246
- **Structured outputs** provide strict adherence to a predefined schema, ensuring consistency.
245247

246-
Experiment with both methods to determine which best fits your application's requirements.
248+
Experiment with both methods to determine which best fits your application's requirements.

0 commit comments

Comments
 (0)