К обзору модели

API-документация

Подробное подключение Task API для Flux 2

API-документация

Эндпоинт

Базовый URLhttps://api.mashagpt.ru/v1
Эндпоинт
POST
/v1/tasks/flux-2
Авторизация
x-api-key: YOUR_API_KEY
илиAuthorization: Bearer YOUR_API_KEY

Как прикрепить изображение

В запрос модели файл не отправляется напрямую. Сначала загрузите файл в MashaGPT storage, получите публичный URL и передайте его в параметр imageUrls.

Не передавайте в JSON blob:, file://, data:, base64 или сырые байты. Storage принимает multipart/form-data с одним полем file. Подробный контракт: /v1/storage/upload.

1. Загрузить файл
curl -X POST "https://api.mashagpt.ru/v1/storage/upload" \
  -H "x-api-key: YOUR_API_KEY" \
  -F "file=@./reference.png"

Ответ вернет URL вида https://static.mashagpt.ru/...

2. Передать URL в модель
curl -X POST "https://api.mashagpt.ru/v1/tasks/flux-2" \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
  "prompt": "Опишите желаемый результат",
  "imageUrls": [
    "https://static.mashagpt.ru/dl/mashagpt/reference.webp"
  ]
}'

Если файл уже доступен по публичному URL, его можно передать сразу. Загрузка через MashaGPT storage надежнее для файлов с компьютера.

Параметры запроса

ПараметрТипОписание
prompt*
stringText prompt describing the image to generate (3-5000 characters). Пример — A futuristic cityscape at sunset with flying cars.
imageUrls
string[]Reference image URLs for image-to-image mode (1-8 images, max 10MB each). If not provided, operates in text-to-image mode. Пример — ["https://example.com/reference.jpg"].
model
stringДопустимые значения: pro, flex. По умолчанию — pro.
resolution
stringДопустимые значения: 1K, 2K. Output resolution. По умолчанию — 1K.
aspectRatio
stringДопустимые значения: 1:1, 4:3, 3:4, 16:9, 9:16, 3:2, 2:3, auto. Output aspect ratio. 'auto' preserves the first reference image ratio in image-to-image mode; text-to-image requests normalize 'auto' to '1:1'. По умолчанию — 1:1.

Пример запроса и ответа

Запрос
curl -X POST https://api.mashagpt.ru/v1/tasks/flux-2 \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
  "prompt": "A futuristic cityscape at sunset with flying cars",
  "model": "pro",
  "resolution": "1K",
  "aspectRatio": "1:1"
}'
Ответ
{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "550e8400-e29b-41d4-a716-446655440000",
    "state": "queued"
  }
}

Асинхронная обработка

Модель работает асинхронно. После запроса вы получите taskId задачи для отслеживания статуса.

GET
/v1/tasks/{id}статус задачи
Проверка статуса задачи:
curl -X GET "https://api.mashagpt.ru/v1/tasks/{task_id}" \
  -H "x-api-key: YOUR_API_KEY"

Жизненный цикл задачи:

queuedprocessingcompleted|failed