Генерация изображения
Генерация изображения возможна только по моделям, которые поддерживают на выходе генерацию изображения. Подробно о функциональности моделей можно почитать на странице тарифы и цены.
Параметры запроса
Параметр | Тип | Обязательный | Описание |
---|---|---|---|
ai | object | Да | Настройка запроса |
--model | string | Да | Название модели из списка в тарифах API |
--temperature | float | Нет | Настройка температуры (креативности) модели (0 - 1.0) |
--top_p | float | Нет | Настройка разнообразности (неожиданности) слов (0 - 1.0) |
content | string | Да | Запрос к нейросети |
type | string | Нет | Тип генерации (out_text/out_image). По умолчанию type = out_text. |
response_format | string | Нет | Формат возвращаемого результата (b64_json/url). По умолчанию response_format = url. |
Пример запроса
cURL
Python
PHP
curl -X POST "https://ai.mitup.ru/api/v2" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"ai": {
"model": "gemini-2.0-flash-image",
"temperature": 0.9,
"top_p": 1.0
},
"type": "out_image",
"response_format": "url",
"content": "Нарисуй 3 варианта логотипа сервиса Mitup AI."
}'
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 = {
"ai": {
"model": "gemini-2.0-flash-image",
"temperature": 0.9,
"top_p": 1.0
},
"type": "out_image",
"response_format": "url",
"content": "Нарисуй 3 варианта логотипа сервиса Mitup AI."
}
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 = [
"ai" => [
"model" => "gemini-2.0-flash-image",
"temperature" => 0.9,
"top_p" => 1.0
],
"type" => "out_image",
"response_format" => "url",
"content" => "Нарисуй 3 варианта логотипа сервиса Mitup AI."
];
$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, 60);
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 POST "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, 60);
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": 200.00,
"balance_bonus": 0.00,
"balance_referral": 0.00
},
"contents": {
"status": 2,
"text": "Нарисовал тебе 3 варианта логотипа Mitup AI",
"files": [
{
"data": "ссылка на файл",
"mime_type": "image/png",
"path": "/api/fcf242d7-f0c0-416a-84ef-5f2773bf3696/b66894d5490a8b0f0e515a7b5f49a03fba2f858a.png",
"name": "b66894d5490a8b0f0e515a7b5f49a03fba2f858a.png",
"size": 501641,
"available": "22.10.25",
},
],
"cost": {
"amount": 1.73,
"input": 97,
"output": 768
},
},
"limits": {
"minute": 1,
"day": 5,
},
"uniq": {
"result": None,
"status": 4,
"cost": {
"amount": 0.00,
"input": 0
},
},
"error": None
}