Skip to content

Commit 05aa217

Browse files
authored
Merge pull request #544 from mistralai/sync/latest
Sync docs to v1.2.1
2 parents 385e4f6 + eb7db8f commit 05aa217

19 files changed

Lines changed: 293 additions & 211 deletions

File tree

public/studio-api/audio/text_to_speech/voices.md

Lines changed: 47 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Save audio samples as reusable voices. Once created, a voice can be referenced b
2424
```python
2525
import base64
2626
from pathlib import Path
27-
from mistralai import Mistral
27+
from mistralai.client import Mistral
2828

2929
client = Mistral(api_key="your-api-key")
3030

@@ -151,25 +151,27 @@ curl -X POST "https://api.mistral.ai/v1/audio/voices" \
151151
<TabItem value="v1" label="V1" default>
152152

153153
```python
154-
from mistralai import Mistral
154+
from mistralai.client import Mistral
155155

156156
client = Mistral(api_key="your-api-key")
157157

158-
result = client.audio.voices.list(limit=10, offset=0)
159-
160-
print(f"Total voices: {result.total}")
161-
for voice in result.items:
162-
print(f" - {voice.name} ({voice.id}) languages={voice.languages}")
163-
164-
# Paginate through all voices
158+
limit = 10
165159
offset = 0
166160
all_voices = []
161+
167162
while True:
168-
page = client.audio.voices.list(limit=10, offset=offset)
169-
all_voices.extend(page.items)
170-
if offset + len(page.items) >= page.total:
163+
page = client.audio.voices.list(limit=limit, offset=offset)
164+
items = page.items or []
165+
all_voices.extend(items)
166+
167+
if offset + len(items) >= page.total:
171168
break
172-
offset += len(page.items)
169+
170+
offset += len(items)
171+
172+
print(f"Total voices: {len(all_voices)}")
173+
for voice in all_voices:
174+
print(f" - {voice.name} ({voice.id}) languages={voice.languages}")
173175
```
174176

175177
</TabItem>
@@ -180,21 +182,23 @@ from mistralai.client import Mistral
180182

181183
client = Mistral(api_key="your-api-key")
182184

183-
result = client.audio.voices.list(limit=10, offset=0)
184-
185-
print(f"Total voices: {result.total}")
186-
for voice in result.items:
187-
print(f" - {voice.name} ({voice.id}) languages={voice.languages}")
188-
189-
# Paginate through all voices
185+
limit = 10
190186
offset = 0
191187
all_voices = []
188+
192189
while True:
193-
page = client.audio.voices.list(limit=10, offset=offset)
194-
all_voices.extend(page.items)
195-
if offset + len(page.items) >= page.total:
190+
page = client.audio.voices.list(limit=limit, offset=offset)
191+
items = page.items or []
192+
all_voices.extend(items)
193+
194+
if offset + len(items) >= page.total:
196195
break
197-
offset += len(page.items)
196+
197+
offset += len(items)
198+
199+
print(f"Total voices: {len(all_voices)}")
200+
for voice in all_voices:
201+
print(f" - {voice.name} ({voice.id}) languages={voice.languages}")
198202
```
199203

200204
</TabItem>
@@ -206,21 +210,24 @@ while True:
206210

207211
const client = new Mistral({ apiKey: "your-api-key" });
208212

209-
const result = await client.audio.voices.list({ limit: 10, offset: 0 });
210-
211-
console.log(`Total voices: ${result.total}`);
212-
for (const voice of result.items ?? []) {
213-
console.log(` - ${voice.name} (${voice.id}) languages=${voice.languages}`);
214-
}
215-
216-
// Paginate through all voices
213+
const limit = 10;
217214
let offset = 0;
218215
const allVoices = [];
216+
219217
while (true) {
220-
const page = await client.audio.voices.list({ limit: 10, offset });
221-
allVoices.push(...(page.items ?? []));
222-
if (offset + (page.items?.length ?? 0) >= page.total) break;
223-
offset += page.items?.length ?? 0;
218+
const page = await client.audio.voices.list({ limit, offset });
219+
const items = page.items ?? [];
220+
221+
allVoices.push(...items);
222+
223+
if (offset + items.length >= page.total) break;
224+
225+
offset += items.length;
226+
}
227+
228+
console.log(`Total voices: ${allVoices.length}`);
229+
for (const voice of allVoices) {
230+
console.log(` - ${voice.name} (${voice.id}) languages=${voice.languages}`);
224231
}
225232
```
226233

@@ -268,7 +275,7 @@ curl "https://api.mistral.ai/v1/audio/voices?limit=10&offset=0" \
268275
<TabItem value="v1" label="V1" default>
269276

270277
```python
271-
from mistralai import Mistral
278+
from mistralai.client import Mistral
272279

273280
client = Mistral(api_key="your-api-key")
274281

@@ -349,7 +356,7 @@ curl "https://api.mistral.ai/v1/audio/voices/$VOICE_ID" \
349356
<TabItem value="v1" label="V1" default>
350357

351358
```python
352-
from mistralai import Mistral
359+
from mistralai.client import Mistral
353360

354361
client = Mistral(api_key="your-api-key")
355362

@@ -447,7 +454,7 @@ curl -X PATCH "https://api.mistral.ai/v1/audio/voices/$VOICE_ID" \
447454
<TabItem value="v1" label="V1" default>
448455

449456
```python
450-
from mistralai import Mistral
457+
from mistralai.client import Mistral
451458

452459
client = Mistral(api_key="your-api-key")
453460

@@ -517,7 +524,7 @@ curl -X DELETE "https://api.mistral.ai/v1/audio/voices/$VOICE_ID" \
517524

518525
```python
519526
from pathlib import Path
520-
from mistralai import Mistral
527+
from mistralai.client import Mistral
521528

522529
client = Mistral(api_key="your-api-key")
523530

src/content/en/api/endpoint/chat/page.mdx

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -104,28 +104,19 @@ TypeScript
104104
```typescript
105105
import { Mistral } from "@mistralai/mistralai";
106106

107-
const mistral = new Mistral({
108-
apiKey: "MISTRAL_API_KEY",
109-
});
107+
const client = new Mistral({ apiKey: process.env.MISTRAL_API_KEY });
110108

111-
async function run() {
112-
const result = await mistral.chat.complete({
113-
model: "mistral-large-latest",
114-
messages: [
115-
{
116-
role: "user",
117-
content: "Who is the best French painter? Answer in one short sentence.",
118-
},
119-
],
120-
responseFormat: {
121-
type: "text",
109+
const response = await client.chat.complete({
110+
model: "mistral-large-latest",
111+
messages: [
112+
{
113+
role: "user",
114+
content: "Who is the best French painter? Answer in one short sentence.",
122115
},
123-
});
124-
125-
console.log(result);
126-
}
116+
],
117+
});
127118

128-
run();
119+
console.log(response.choices[0].message.content);
129120

130121
```
131122

@@ -151,26 +142,22 @@ Python
151142
<CodeSample>
152143

153144
```python
154-
from mistralai.client import Mistral
155145
import os
146+
from mistralai.client import Mistral
156147

148+
client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])
157149

158-
with Mistral(
159-
api_key=os.getenv("MISTRAL_API_KEY", ""),
160-
) as mistral:
161-
162-
res = mistral.chat.complete(model="mistral-large-latest", messages=[
150+
response = client.chat.complete(
151+
model="mistral-large-latest",
152+
messages=[
163153
{
164154
"role": "user",
165155
"content": "Who is the best French painter? Answer in one short sentence.",
166-
},
167-
], stream=False, response_format={
168-
"type": "text",
169-
})
170-
171-
# Handle response
172-
print(res)
156+
}
157+
],
158+
)
173159

160+
print(response.choices[0].message.content)
174161

175162
```
176163

@@ -197,17 +184,18 @@ cURL
197184

198185
```curl
199186
curl https://api.mistral.ai/v1/chat/completions \
200-
-X POST \
201-
-H 'Authorization: Bearer YOUR_APIKEY_HERE' \
202-
-H 'Content-Type: application/json' \
203-
-d '{
204-
"messages": [
205-
{
206-
"content": "Example content."
207-
}
208-
],
209-
"model": "mistral-large-latest"
210-
}'
187+
-H "Content-Type: application/json" \
188+
-H "Authorization: Bearer $MISTRAL_API_KEY" \
189+
-d '{
190+
"model": "mistral-large-latest",
191+
"messages": [
192+
{
193+
"role": "user",
194+
"content": "Who is the best French painter? Answer in one short sentence."
195+
}
196+
]
197+
}'
198+
211199
```
212200

213201
</CodeSample>
@@ -234,7 +222,8 @@ curl https://api.mistral.ai/v1/chat/completions \
234222
{
235223
"messages": [
236224
{
237-
"content": "Example content."
225+
"role": "user",
226+
"content": "Who is the best French painter? Answer in one short sentence."
238227
}
239228
],
240229
"model": "mistral-large-latest"

src/content/en/docs/studio-api/audio/text_to_speech/voices/list_tab/_page.mdx

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,23 @@ from mistralai.client import Mistral
1212

1313
client = Mistral(api_key="your-api-key")
1414

15-
result = client.audio.voices.list(limit=10, offset=0)
16-
17-
print(f"Total voices: {result.total}")
18-
for voice in result.items:
19-
print(f" - {voice.name} ({voice.id}) languages={voice.languages}")
20-
21-
# Paginate through all voices
15+
limit = 10
2216
offset = 0
2317
all_voices = []
18+
2419
while True:
25-
page = client.audio.voices.list(limit=10, offset=offset)
26-
all_voices.extend(page.items)
27-
if offset + len(page.items) >= page.total:
20+
page = client.audio.voices.list(limit=limit, offset=offset)
21+
items = page.items or []
22+
all_voices.extend(items)
23+
24+
if offset + len(items) >= page.total:
2825
break
29-
offset += len(page.items)
26+
27+
offset += len(items)
28+
29+
print(f"Total voices: {len(all_voices)}")
30+
for voice in all_voices:
31+
print(f" - {voice.name} ({voice.id}) languages={voice.languages}")
3032
```
3133

3234
</TabItem>
@@ -37,21 +39,23 @@ from mistralai.client import Mistral
3739

3840
client = Mistral(api_key="your-api-key")
3941

40-
result = client.audio.voices.list(limit=10, offset=0)
41-
42-
print(f"Total voices: {result.total}")
43-
for voice in result.items:
44-
print(f" - {voice.name} ({voice.id}) languages={voice.languages}")
45-
46-
# Paginate through all voices
42+
limit = 10
4743
offset = 0
4844
all_voices = []
45+
4946
while True:
50-
page = client.audio.voices.list(limit=10, offset=offset)
51-
all_voices.extend(page.items)
52-
if offset + len(page.items) >= page.total:
47+
page = client.audio.voices.list(limit=limit, offset=offset)
48+
items = page.items or []
49+
all_voices.extend(items)
50+
51+
if offset + len(items) >= page.total:
5352
break
54-
offset += len(page.items)
53+
54+
offset += len(items)
55+
56+
print(f"Total voices: {len(all_voices)}")
57+
for voice in all_voices:
58+
print(f" - {voice.name} ({voice.id}) languages={voice.languages}")
5559
```
5660

5761
</TabItem>
@@ -64,21 +68,24 @@ import { Mistral } from "@mistralai/mistralai";
6468

6569
const client = new Mistral({ apiKey: "your-api-key" });
6670

67-
const result = await client.audio.voices.list({ limit: 10, offset: 0 });
68-
69-
console.log(`Total voices: ${result.total}`);
70-
for (const voice of result.items ?? []) {
71-
console.log(` - ${voice.name} (${voice.id}) languages=${voice.languages}`);
72-
}
73-
74-
// Paginate through all voices
71+
const limit = 10;
7572
let offset = 0;
7673
const allVoices = [];
74+
7775
while (true) {
78-
const page = await client.audio.voices.list({ limit: 10, offset });
79-
allVoices.push(...(page.items ?? []));
80-
if (offset + (page.items?.length ?? 0) >= page.total) break;
81-
offset += page.items?.length ?? 0;
76+
const page = await client.audio.voices.list({ limit, offset });
77+
const items = page.items ?? [];
78+
79+
allVoices.push(...items);
80+
81+
if (offset + items.length >= page.total) break;
82+
83+
offset += items.length;
84+
}
85+
86+
console.log(`Total voices: ${allVoices.length}`);
87+
for (const voice of allVoices) {
88+
console.log(` - ${voice.name} (${voice.id}) languages=${voice.languages}`);
8289
}
8390
```
8491

src/content/en/docs/studio-api/batch-processing/page.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,8 @@ const listJob = await client.batch.jobs.list({
512512
<TabItem value="curl" label="curl">
513513

514514
```bash
515-
curl 'https://api.mistral.ai/v1/batch/jobs?status=RUNNING&job_type=testing'\
516-
--header 'x-api-key: $MISTRAL_API_KEY'
515+
curl 'https://api.mistral.ai/v1/batch/jobs?status=RUNNING' \
516+
--header "Authorization: Bearer $MISTRAL_API_KEY"
517517
```
518518

519519
</TabItem>

0 commit comments

Comments
 (0)