Skip to content

Commit e11523b

Browse files
authored
Update rest.md
1 parent cf8a3bd commit e11523b

File tree

1 file changed

+120
-8
lines changed
  • articles/ai-foundry/model-inference/includes/use-chat-reasoning

1 file changed

+120
-8
lines changed

articles/ai-foundry/model-inference/includes/use-chat-reasoning/rest.md

Lines changed: 120 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,41 @@ To complete this tutorial, you need:
2727

2828
First, create the client to consume the model. The following code uses an endpoint URL and key that are stored in environment variables.
2929

30+
# [OpenAI API](#tab/openai)
31+
3032
```http
31-
POST https://<resource>.services.ai.azure.com/models/chat/completions?api-version=2024-05-01-preview
33+
POST https://<resource>.services.ai.azure.com/openai/deployments/deepseek-r1/chat/completions?api-version=2024-10-21
3234
Content-Type: application/json
3335
api-key: <key>
3436
```
3537

36-
> [!TIP]
37-
> Verify that you have deployed the model to Azure AI Services resource with the Azure AI Foundry Models API. `Deepseek-R1` is also available as standard deployments. However, those endpoints don't take the parameter `model` as explained in this tutorial. You can verify that by going to [Azure AI Foundry portal]() > Models + endpoints, and verify that the model is listed under the section **Azure AI Services**.
38+
# [Model Inference API (preview)](#tab/inference)
39+
40+
```http
41+
POST https://<resource>.services.ai.azure.com/models/chat/completions?api-version=2024-05-01-preview
42+
Content-Type: application/json
43+
api-key: <key>
44+
```
45+
---
3846

3947
If you have configured the resource with **Microsoft Entra ID** support, pass you token in the `Authorization` header with the format `Bearer <token>`. Use scope `https://cognitiveservices.azure.com/.default`.
4048

49+
# [OpenAI API](#tab/openai)
50+
51+
```http
52+
POST https://<resource>.services.ai.azure.com/openai/deployments/deepseek-r1/chat/completions?api-version=2024-10-21
53+
Content-Type: application/json
54+
Authorization: Bearer <token>
55+
```
56+
57+
# [Model Inference API (preview)](#tab/inference)
58+
4159
```http
4260
POST https://<resource>.services.ai.azure.com/models/chat/completions?api-version=2024-05-01-preview
4361
Content-Type: application/json
4462
Authorization: Bearer <token>
4563
```
64+
---
4665

4766
Using Microsoft Entra ID may require additional configuration in your resource to grant access. Learn how to [configure key-less authentication with Microsoft Entra ID](../../how-to/configure-entra-id.md).
4867

@@ -66,6 +85,36 @@ The following example shows how you can create a basic chat request to the model
6685

6786
The response is as follows, where you can see the model's usage statistics:
6887

88+
# [OpenAI API](#tab/openai)
89+
90+
```json
91+
{
92+
"id": "0a1234b5de6789f01gh2i345j6789klm",
93+
"object": "chat.completion",
94+
"created": 1718726686,
95+
"model": "DeepSeek-R1",
96+
"choices": [
97+
{
98+
"index": 0,
99+
"message": {
100+
"role": "assistant",
101+
"reasoning_content": "Okay, the user is asking how many languages exist in the world. I need to provide a clear and accurate answer. Let's start by recalling the general consensus from linguistic sources. I remember that the number often cited is around 7,000, but maybe I should check some reputable organizations.\n\nEthnologue is a well-known resource for language data, and I think they list about 7,000 languages. But wait, do they update their numbers? It might be around 7,100 or so. Also, the exact count can vary because some sources might categorize dialects differently or have more recent data. \n\nAnother thing to consider is language endangerment. Many languages are endangered, with some having only a few speakers left. Organizations like UNESCO track endangered languages, so mentioning that adds context. Also, the distribution isn't even. Some countries have hundreds of languages, like Papua New Guinea with over 800, while others have just a few. \n\nA user might also wonder why the exact number is hard to pin down. It's because the distinction between a language and a dialect can be political or cultural. For example, Mandarin and Cantonese are considered dialects of Chinese by some, but they're mutually unintelligible, so others classify them as separate languages. Also, some regions are under-researched, making it hard to document all languages. \n\nI should also touch on language families. The 7,000 languages are grouped into families like Indo-European, Sino-Tibetan, Niger-Congo, etc. Maybe mention a few of the largest families. But wait, the question is just about the count, not the families. Still, it's good to provide a bit more context. \n\nI need to make sure the information is up-to-date. Let me think – recent estimates still hover around 7,000. However, languages are dying out rapidly, so the number decreases over time. Including that note about endangerment and language extinction rates could be helpful. For instance, it's often stated that a language dies every few weeks. \n\nAnother point is sign languages. Does the count include them? Ethnologue includes some, but not all sources might. If the user is including sign languages, that adds more to the count, but I think the 7,000 figure typically refers to spoken languages. For thoroughness, maybe mention that there are also over 300 sign languages. \n\nSummarizing, the answer should state around 7,000, mention Ethnologue's figure, explain why the exact number varies, touch on endangerment, and possibly note sign languages as a separate category. Also, a brief mention of Papua New Guinea as the most linguistically diverse country. \n\nWait, let me verify Ethnologue's current number. As of their latest edition (25th, 2022), they list 7,168 living languages. But I should check if that's the case. Some sources might round to 7,000. Also, SIL International publishes Ethnologue, so citing them as reference makes sense. \n\nOther sources, like Glottolog, might have a different count because they use different criteria. Glottolog might list around 7,000 as well, but exact numbers vary. It's important to highlight that the count isn't exact because of differing definitions and ongoing research. \n\nIn conclusion, the approximate number is 7,000, with Ethnologue being a key source, considerations of endangerment, and the challenges in counting due to dialect vs. language distinctions. I should make sure the answer is clear, acknowledges the variability, and provides key points succinctly.\n",
102+
"content": "The exact number of languages in the world is challenging to determine due to differences in definitions (e.g., distinguishing languages from dialects) and ongoing documentation efforts. However, widely cited estimates suggest there are approximately **7,000 languages** globally.",
103+
"tool_calls": null
104+
},
105+
"finish_reason": "stop"
106+
}
107+
],
108+
"usage": {
109+
"prompt_tokens": 11,
110+
"total_tokens": 897,
111+
"completion_tokens": 886
112+
}
113+
}
114+
```
115+
116+
# [Model Inference API (preview)](#tab/inference)
117+
69118
```json
70119
{
71120
"id": "0a1234b5de6789f01gh2i345j6789klm",
@@ -90,10 +139,21 @@ The response is as follows, where you can see the model's usage statistics:
90139
}
91140
}
92141
```
142+
---
93143

94144
### Reasoning content
95145

96-
Some reasoning models, like DeepSeek-R1, generate completions and include the reasoning behind it. The reasoning associated with the completion is included in the response's content within the tags `<think>` and `</think>`. The model may select on which scenarios to generate reasoning content.
146+
Some reasoning models, like DeepSeek-R1, generate completions and include the reasoning behind it.
147+
148+
# [OpenAI API](#tab/openai)
149+
150+
The reasoning associated with the completion is included in the field `reasoning_content`. The model may select on which scenearios to generate reasoning content.
151+
152+
# [Model Inference API (preview)](#tab/inference)
153+
154+
The reasoning associated with the completion is included in the response's content within the tags `<think>` and `</think>`. The model may select on which scenarios to generate reasoning content.
155+
156+
---
97157

98158
When making multi-turn conversations, it's useful to avoid sending the reasoning content in the chat history as reasoning tends to generate long explanations.
99159

@@ -110,10 +170,6 @@ To stream completions, set `"stream": true` when you call the model.
110170
{
111171
"model": "DeepSeek-R1",
112172
"messages": [
113-
{
114-
"role": "system",
115-
"content": "You are a helpful assistant."
116-
},
117173
{
118174
"role": "user",
119175
"content": "How many languages are in the world?"
@@ -126,6 +182,8 @@ To stream completions, set `"stream": true` when you call the model.
126182

127183
To visualize the output, define a helper function to print the stream. The following example implements a routing that stream only the answer without the reasoning content:
128184

185+
# [OpenAI API](#tab/openai)
186+
129187
```json
130188
{
131189
"id": "23b54589eba14564ad8a2e6978775a39",
@@ -137,6 +195,7 @@ To visualize the output, define a helper function to print the stream. The follo
137195
"index": 0,
138196
"delta": {
139197
"role": "assistant",
198+
"reasoning_content": "Okay,",
140199
"content": ""
141200
},
142201
"finish_reason": null,
@@ -146,8 +205,60 @@ To visualize the output, define a helper function to print the stream. The follo
146205
}
147206
```
148207

208+
# [Model Inference API (preview)](#tab/inference)
209+
210+
```json
211+
{
212+
"id": "23b54589eba14564ad8a2e6978775a39",
213+
"object": "chat.completion.chunk",
214+
"created": 1718726371,
215+
"model": "DeepSeek-R1",
216+
"choices": [
217+
{
218+
"index": 0,
219+
"delta": {
220+
"role": "assistant",
221+
"content": "<think>Okay,"
222+
},
223+
"finish_reason": null,
224+
"logprobs": null
225+
}
226+
]
227+
}
228+
```
229+
---
230+
149231
The last message in the stream has `finish_reason` set, indicating the reason for the generation process to stop.
150232

233+
# [OpenAI API](#tab/openai)
234+
235+
```json
236+
{
237+
"id": "23b54589eba14564ad8a2e6978775a39",
238+
"object": "chat.completion.chunk",
239+
"created": 1718726371,
240+
"model": "DeepSeek-R1",
241+
"choices": [
242+
{
243+
"index": 0,
244+
"delta": {
245+
"reasoning_content": "",
246+
"content": ""
247+
},
248+
"finish_reason": "stop",
249+
"logprobs": null
250+
}
251+
],
252+
"usage": {
253+
"prompt_tokens": 11,
254+
"total_tokens": 897,
255+
"completion_tokens": 886
256+
}
257+
}
258+
```
259+
260+
# [Model Inference API (preview)](#tab/inference)
261+
151262
```json
152263
{
153264
"id": "23b54589eba14564ad8a2e6978775a39",
@@ -171,6 +282,7 @@ The last message in the stream has `finish_reason` set, indicating the reason fo
171282
}
172283
}
173284
```
285+
---
174286

175287
### Parameters
176288

0 commit comments

Comments
 (0)