Skip to content

Commit 60323ec

Browse files
Merge pull request #40 from mrbullwinkle/mrb_08_28_2024_s_outputs_003
[Azure OpenAI] [Release Branch] JSON Mode
2 parents afe9af4 + 34decbf commit 60323ec

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

articles/ai-services/openai/how-to/json-mode.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services: cognitive-services
66
manager: nitinme
77
ms.service: azure-ai-openai
88
ms.topic: how-to
9-
ms.date: 12/05/2023
9+
ms.date: 08/29/2024
1010
author: mrbullwinkle
1111
ms.author: mbullwin
1212
recommendations: false
@@ -17,6 +17,9 @@ recommendations: false
1717

1818
JSON mode allows you to set the models response format to return a valid JSON object as part of a chat completion. While generating valid JSON was possible previously, there could be issues with response consistency that would lead to invalid JSON objects being generated.
1919

20+
> [!NOTE]
21+
> While JSON mode is still supported, when possible we recommend using [structured outputs](./structured-outputs.md). Like JSON mode structured outputs generates valid JSON, but with the added benefit that you can constrain the model to use a specific JSON schema.
22+
2023
## JSON mode support
2124

2225
JSON mode is only currently supported with the following models:
@@ -27,6 +30,8 @@ JSON mode is only currently supported with the following models:
2730
* `gpt-35-turbo` (0125)
2831
* `gpt-4` (1106-Preview)
2932
* `gpt-4` (0125-Preview)
33+
* `gpt-4o`
34+
* `gpt-4o-mini`
3035

3136
### API support
3237

@@ -47,7 +52,7 @@ client = AzureOpenAI(
4752
)
4853

4954
response = client.chat.completions.create(
50-
model="gpt-4-0125-Preview", # Model = should match the deployment name you chose for your 0125-Preview model deployment
55+
model="YOUR-MODEL_DEPLOYMENT_NAME", # Model = should match the deployment name you chose for your model deployment
5156
response_format={ "type": "json_object" },
5257
messages=[
5358
{"role": "system", "content": "You are a helpful assistant designed to output JSON."},

0 commit comments

Comments
 (0)