API-справочник
Используйте полный собственный URL из результата и Bearer ключ клиента. Ответ содержит бинарные данные, фактический Content-Type, Content-Length, Accept-Ranges: bytes. Файлы размещены вне публичного каталога.
Поддержан один Range: bytes=0-1023 или bytes=-1024. Успешный диапазон — HTTP 206; неподдержанный/невозможный — 416. Чужой ID — 404; истёкший файл — 410.
Допустимые типы и размеры определяет настройка сервиса. Сохраните файл до content_expires_at или указанного администратором срока хранения результатов.
cURL · GET /media/MEDIA_ID
curl "https://formula-ai.ru/api/v1/media/MEDIA_ID" \
-H "Authorization: Bearer $AI_SERVICE_API_KEY"
PHP · GET /media/
<?php
$key = getenv("AI_SERVICE_API_KEY");
$url = "https://formula-ai.ru/api/v1/media/";
$url .= rawurlencode(getenv("AI_SERVICE_MEDIA_ID"));
$handle = curl_init($url);
curl_setopt_array($handle, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . $key],
]);
if (getenv("AI_SERVICE_CA")) {
curl_setopt($handle, CURLOPT_CAINFO, getenv("AI_SERVICE_CA"));
}
$body = curl_exec($handle);
if ($body === false) {
throw new RuntimeException(curl_error($handle));
}
$status = curl_getinfo($handle, CURLINFO_RESPONSE_CODE);
curl_close($handle);
if ($status !== 200 && $status !== 206) {
throw new RuntimeException("HTTP " . $status . ": " . $body);
}
file_put_contents("result.bin", $body);
echo "Saved result.bin";
Схемы метода
Обязательные поля, типы, параметры и ответы описаны в OpenAPI 3.1. Полный машинный справочник
Показать JSON-схемы
{
"openapi": "3.1.1",
"info": {
"title": "Formula AI API",
"version": "1",
"description": "Методы нашего сервиса. Доступность модели и её параметров определяется опубликованным проверенным маршрутом. Suno: 23 музыкальные и вспомогательные операции, схемы и ограничения параметров. Streaming текста, изображений и аудио: SSE, сохранённые части и собственный расчёт."
},
"servers": [
{
"url": "https://formula-ai.ru/api/v1"
}
],
"security": [
{
"ClientKey": []
}
],
"paths": {
"/media/{id}": {
"get": {
"operationId": "getMedia",
"summary": "Собственный сохранённый файл",
"parameters": [
{
"name": "Range",
"in": "header",
"schema": {
"type": "string"
},
"description": "Один диапазон bytes=0-1023 либо bytes=-1024."
},
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"$ref": "#/components/schemas/PublicId"
}
}
],
"responses": {
"200": {
"description": "Бинарный файл. Content-Type соответствует проверенному содержимому.",
"headers": {
"Content-Length": {
"schema": {
"type": "integer"
}
},
"Accept-Ranges": {
"schema": {
"type": "string",
"const": "bytes"
}
},
"Content-Range": {
"schema": {
"type": "string"
}
}
},
"content": {
"application/octet-stream": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
},
"206": {
"description": "Бинарный файл. Content-Type соответствует проверенному содержимому.",
"headers": {
"Content-Length": {
"schema": {
"type": "integer"
}
},
"Accept-Ranges": {
"schema": {
"type": "string",
"const": "bytes"
}
},
"Content-Range": {
"schema": {
"type": "string"
}
}
},
"content": {
"application/octet-stream": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
},
"416": {
"description": "Невозможный либо неподдержанный диапазон.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"410": {
"description": "Срок хранения истёк.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"default": {
"description": "Ошибка доступа или файл не найден.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
}
},
"components": {
"securitySchemes": {
"ClientKey": {
"type": "http",
"scheme": "bearer",
"description": "API-ключ клиента Formula AI."
}
},
"schemas": {
"PublicId": {
"type": "string",
"pattern": "^[a-f0-9]{32}$"
},
"ErrorDetail": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"code": {
"type": "string"
},
"type": {
"type": "string"
},
"param": {
"type": [
"string",
"null"
]
}
},
"required": [
"message",
"code"
]
},
"Error": {
"type": "object",
"properties": {
"error": {
"$ref": "#/components/schemas/ErrorDetail"
},
"request_id": {
"$ref": "#/components/schemas/PublicId"
}
},
"required": [
"error",
"request_id"
]
}
}
},
"externalDocs": {
"url": "https://formula-ai.ru/docs"
}
}Примеры cURL используют Bash. Задайте AI_SERVICE_API_KEY и AI_SERVICE_MODEL; модель выберите из /models. В PHP для опроса/файла задайте AI_SERVICE_REQUEST_ID/AI_SERVICE_MEDIA_ID, для правки — AI_SERVICE_SOURCE_URL. Для локального сертификата используйте доверенный CA через --cacert, для PHP — AI_SERVICE_CA. Проверку TLS сохраняйте включённой.