Генерация аудио
Генерация аудио возможна только по моделям, которые поддерживают на выходе генерацию аудио. Подробно о функциональности моделей можно почитать на странице тарифы и цены.
Параметры запроса
| Параметр | Тип | Обязательный | Описание |
|---|---|---|---|
| type | string | Да | Тип генерации (out_text/out_image/out_video/out_audio). По умолчанию type = out_text. |
| ai | object | Да | Настройка запроса |
| --model | string | Да | Название модели из списка |
| --audio_voice | string | Да | Голос озвучки (например: "alloy", "Kore", "eve"). Поддерживаемые значения для конкретной модели можно посмотреть в окне настройки чатов |
| --audio_speed | string | Нет | Скорость озвучки (например: "0.25", "1.0", "1.5", "2.0"). Поддерживаемые значения для конкретной модели можно посмотреть в окне настройки чатов |
| --audio_format | string | Да | Формат генерируемого аудио (например: "mp3", "wav", "opus", "flac"). Поддерживаемые значения для конкретной модели можно посмотреть в окне настройки чатов |
| content | array | Да | Массив объектов с запросом к нейросети |
| --type | string | Да | Тип передаваемого контента (input_file/input_text) |
| --text | string | Да | Текст запроса к нейросети |
| --file_data | string | Нет | Файл для генерации. Может содержать ссылку на файл (URL), либо base64 строку. Максимум 10 файлов / 5 МБ |
| response_format | string | Нет | Формат возвращаемого результата (b64_json/url). По умолчанию response_format = url. |
| stop_sequences | list | Нет | Список стоп фраз в запросе (не больше 50). Если указаны, будет произведен поиск вхождений. Запрос будет заблокирован, если в тексте запроса указаны стоп-фразы |
Пример запроса на генерацию аудио
cURL
Python
PHP
curl -X POST "https://ai.mitup.ru/api/v2" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"type": "out_audio",
"ai": {
"model": "gpt-4o-mini-tts",
"audio_voice": "alloy",
"audio_speed": "1.0",
"audio_format": "mp3"
},
"content": [
{
"type": "input_text",
"text": "Озвучь текст: Добро пожаловать в Mitup AI"
}
],
"response_format": "url",
"stop_sequences": []
}'import requests
url = "https://ai.mitup.ru/api/v2"
api_key = "YOUR_API_KEY"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
}
params = {
"type": "out_audio",
"ai": {
"model": "gpt-4o-mini-tts",
"audio_voice": "alloy",
"audio_speed": "1.0",
"audio_format": "mp3"
},
"content": [
{
"type": "input_text",
"text": "Озвучь текст: Добро пожаловать в Mitup AI"
}
],
"response_format": "url",
"stop_sequences": []
}
response = requests.post(url, json=params, headers=headers)
print(response.json())<?php
$url = "https://ai.mitup.ru/api/v2";
$api_key = "YOUR_API_KEY";
$headers = [
'Content-Type: application/json',
'Authorization: Bearer ' . $api_key,
];
$params = [
"type" => "out_audio",
"ai" => [
"model" => "gpt-4o-mini-tts",
"audio_voice" => "alloy",
"audio_speed" => "1.0",
"audio_format" => "mp3"
],
"content" => [
[
"type" => "input_text",
"text" => "Озвучь текст: Добро пожаловать в Mitup AI"
]
],
"response_format" => "url",
"stop_sequences" => []
];
$data = json_encode($params, JSON_UNESCAPED_UNICODE);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'mitupai-API-client');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
curl_close($ch);
$response = json_decode($response, true);
print_r($response);
?>Пример возвращаемого результата:
JSON
{'message': 'Ваш запрос отправлен', 'task_id': 'YOUR_TASK_ID'}Получение результата
cURL
Python
PHP
curl -X GET "https://ai.mitup.ru/api/v2/status/{task_id}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \import requests
api_key = "YOUR_API_KEY"
task_id = "YOUR_TASK_ID"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
}
url = f'https://ai.mitup.ru/api/v2/status/{task_id}'
response = requests.get(url, headers=headers)
print(response.json())<?php
$api_key = "YOUR_API_KEY";
$task_id = "YOUR_TASK_ID"
$url = "https://ai.mitup.ru/api/v2/status/" . task_id;
$headers = [
"Content-Type: application/json",
"Authorization: Bearer " . $api_key
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'mitupai-API-client');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_POSTFIELDS, "");
$response = curl_exec($ch);
curl_close($ch);
$response = json_decode($response, true);
print_r($response);
?>Пример возвращаемого результата:
JSON
{
"balance": {
"balance": 49202.0,
"balance_referral": 0.0,
"balance_bonus": -1.9
},
"contents": {
"status": 2,
"text": "Вот, что у меня получилось:",
"cost": {
"amount": 1.2,
"input": 42,
"output": 42
},
"files": [
{
"data": "https://s3.ru1.storage.beget.cloud/.../api/YOUR_TASK_ID/audio.mp3",
"mime_type": "audio/mp3",
"path": "api/YOUR_TASK_ID/audio.mp3",
"name": "audio.mp3",
"size": 245760,
"endpoint": "https://s3.ru1.storage.beget.cloud/.../",
"available": "12.08.26"
}
]
},
"limits": {
"minute": 0,
"day": 5
},
"error": None
}