Skip to content

Commit eb4183c

Browse files
committed
Updated api reference docs to guide to use chat completions instead of completions
1 parent 7ea5367 commit eb4183c

File tree

3 files changed

+83
-22
lines changed

3 files changed

+83
-22
lines changed

articles/ai-services/openai/includes/api-surface.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ Azure OpenAI provides two methods for authentication. You can use either API Ke
3838
The service APIs are versioned using the ```api-version``` query parameter. All versions follow the YYYY-MM-DD date structure. For example:
3939

4040
```http
41-
POST https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/completions?api-version=2024-06-01
41+
POST https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/chat/completions?api-version=2024-06-01
4242
```

articles/ai-services/openai/includes/api-versions/latest-inference-preview.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ ms.date: 09/08/2024
1010

1111
## Completions - Create
1212

13+
> [!IMPORTANT]
14+
> Unless you have a specific use case that requires the completions endpoint, we recommend instead using the [chat completions endpoint](#Chat-completions---Create) which allows you to take advantage of the latest models like GPT-4o, GPT-4o mini, and GPT-4 Turbo.
15+
1316
```HTTP
1417
POST https://{endpoint}/openai/deployments/{deployment-id}/completions?api-version=2024-08-01-preview
1518
```

articles/ai-services/openai/includes/api-versions/latest-inference.md

Lines changed: 79 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ ms.date: 07/09/2024
1010

1111
## Completions
1212

13+
> [!IMPORTANT]
14+
> Unless you have a specific use case that requires the completions endpoint, we recommend instead using the [chat completions endpoint](#Chat-completions) which allows you to take advantage of the latest models like GPT-4o, GPT-4o mini, and GPT-4 Turbo.
15+
1316
```HTTP
1417
POST https://{endpoint}/openai/deployments/{deployment-id}/completions?api-version=2024-06-01
1518
```
@@ -96,18 +99,16 @@ Creates a completion for the provided prompt, parameters and chosen model.
9699

97100
### Example
98101

99-
Creates a completion for the provided prompt, parameters and chosen model.
102+
Creates a chat completion for the provided messages.
100103

101104
```HTTP
102-
POST https://{endpoint}/openai/deployments/{deployment-id}/completions?api-version=2024-06-01
105+
POST https://{endpoint}/openai/deployments/{deployment-id}/chat/completions?api-version=2024-06-01
103106
104107
{
105-
"prompt": [
106-
"tell me a joke about mango"
107-
],
108-
"max_tokens": 32,
109-
"temperature": 1.0,
110-
"n": 1
108+
"messages": [
109+
{"role": "system", "content": "Provide some context and/or instructions to the model"},
110+
{"role": "user", "content": "tell me a joke about mango"}
111+
]
111112
}
112113
113114
```
@@ -116,23 +117,80 @@ POST https://{endpoint}/openai/deployments/{deployment-id}/completions?api-versi
116117
Status Code: 200
117118
```json
118119
{
119-
"body": {
120-
"id": "cmpl-7QmVI15qgYVllxK0FtxVGG6ywfzaq",
121-
"created": 1686617332,
122120
"choices": [
123-
{
124-
"text": "es\n\nWhat do you call a mango who's in charge?\n\nThe head mango.",
125-
"index": 0,
126-
"finish_reason": "stop",
127-
"logprobs": null
128-
}
121+
{
122+
"content_filter_results": {
123+
"hate": {
124+
"filtered": false,
125+
"severity": "safe"
126+
},
127+
"profanity": {
128+
"filtered": false,
129+
"detected": false
130+
},
131+
"self_harm": {
132+
"filtered": false,
133+
"severity": "safe"
134+
},
135+
"sexual": {
136+
"filtered": false,
137+
"severity": "safe"
138+
},
139+
"violence": {
140+
"filtered": false,
141+
"severity": "safe"
142+
}
143+
},
144+
"finish_reason": "stop",
145+
"index": 0,
146+
"logprobs": null,
147+
"message": {
148+
"content": "Sure, here's a mango joke for you:\n\nWhy did the mango blush?\n\nBecause it saw the salad dressing!",
149+
"role": "assistant"
150+
}
151+
}
129152
],
153+
"created": 1726694535,
154+
"id": "chatcmpl-A8wPnNAjr2YPtA50Tex0ya7tRDadM",
155+
"model": "gpt-4o-2024-05-13",
156+
"object": "chat.completion",
157+
"prompt_filter_results": [
158+
{
159+
"prompt_index": 0,
160+
"content_filter_results": {
161+
"hate": {
162+
"filtered": false,
163+
"severity": "safe"
164+
},
165+
"jailbreak": {
166+
"filtered": false,
167+
"detected": false
168+
},
169+
"profanity": {
170+
"filtered": false,
171+
"detected": false
172+
},
173+
"self_harm": {
174+
"filtered": false,
175+
"severity": "safe"
176+
},
177+
"sexual": {
178+
"filtered": false,
179+
"severity": "safe"
180+
},
181+
"violence": {
182+
"filtered": false,
183+
"severity": "safe"
184+
}
185+
}
186+
}
187+
],
188+
"system_fingerprint": "fp_80a1bad4c7",
130189
"usage": {
131-
"completion_tokens": 20,
132-
"prompt_tokens": 6,
133-
"total_tokens": 26
190+
"completion_tokens": 22,
191+
"prompt_tokens": 26,
192+
"total_tokens": 48
134193
}
135-
}
136194
}
137195
```
138196

0 commit comments

Comments
 (0)