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
Copy file name to clipboardExpand all lines: README.md
+55Lines changed: 55 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ It is generated from our [OpenAPI specification](https://github.com/openai/opena
17
17
-[Using the `OpenAIClient` class](#using-the-openaiclient-class)
18
18
-[How to use chat completions with streaming](#how-to-use-chat-completions-with-streaming)
19
19
-[How to use chat completions with tools and function calling](#how-to-use-chat-completions-with-tools-and-function-calling)
20
+
-[How to use structured outputs](#how-to-use-structured-outputs)
20
21
-[How to generate text embeddings](#how-to-generate-text-embeddings)
21
22
-[How to generate images](#how-to-generate-images)
22
23
-[How to transcribe audio](#how-to-transcribe-audio)
@@ -296,6 +297,60 @@ do
296
297
} while (requiresAction);
297
298
```
298
299
300
+
## How to use structured outputs
301
+
302
+
Beginning with the `gpt-4o-mini`, `gpt-4o-mini-2024-07-18`, and `gpt-4o-2024-08-06` model snapshots, structured outputs are available for both top-level response content and tool calls in the chat completion and assistants APIs.
303
+
304
+
For information about the feature, see [the Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs/introduction).
305
+
306
+
To use structured outputs to constrain chat completion content, set an appropriate `ChatResponseFormat` as in the following example:
In this example, you want to create a trip-planning website that allows customers to write a prompt describing the kind of hotel that they are looking for and then offers hotel recommendations that closely match this description. To achieve this, it is possible to use text embeddings to measure the relatedness of text strings. In summary, you can get embeddings of the hotel descriptions, store them in a vector database, and use them to build a search index that you can query using the embedding of a given customer's prompt.
0 commit comments