Создать генерацию медиа
curl --request POST \
--url https://polza.ai/api/v1/media \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "seedream-3",
"input": {
"prompt": "Космический корабль в стиле киберпанк",
"aspect_ratio": "16:9",
"images": [
{
"type": "url",
"data": "https://example.com/image.png"
}
],
"callBackUrl": "<string>",
"seed": 42,
"watermark": "MyBrand",
"image_resolution": "2K",
"quality": "high",
"output_format": "png",
"animation": true,
"max_images": 1,
"isEnhance": false,
"guidance_scale": 2.5,
"strength": 0.8,
"enable_safety_checker": true,
"upscale_factor": "2",
"font_inputs": [
{
"font_url": "https://example.com/fonts/custom-font.ttf",
"text": "Hello World"
}
],
"super_resolution_references": [
"https://example.com/reference1.jpg"
]
},
"provider": {
"require_parameters": true,
"allow_fallbacks": true,
"order": [
"OpenAI",
"Anthropic"
],
"only": [
"OpenAI",
"Google"
],
"ignore": [
"DeepInfra"
],
"sort": "price",
"data_residency": "ru",
"max_price": {
"prompt": 10,
"completion": 20,
"image": 5,
"audio": 15,
"request": 1,
"video_per_second": 50,
"stt_per_minute": 5,
"tts_per_million_characters": 1500
}
},
"async": false,
"user": "user-123"
}
'import requests
url = "https://polza.ai/api/v1/media"
payload = {
"model": "seedream-3",
"input": {
"prompt": "Космический корабль в стиле киберпанк",
"aspect_ratio": "16:9",
"images": [
{
"type": "url",
"data": "https://example.com/image.png"
}
],
"callBackUrl": "<string>",
"seed": 42,
"watermark": "MyBrand",
"image_resolution": "2K",
"quality": "high",
"output_format": "png",
"animation": True,
"max_images": 1,
"isEnhance": False,
"guidance_scale": 2.5,
"strength": 0.8,
"enable_safety_checker": True,
"upscale_factor": "2",
"font_inputs": [
{
"font_url": "https://example.com/fonts/custom-font.ttf",
"text": "Hello World"
}
],
"super_resolution_references": ["https://example.com/reference1.jpg"]
},
"provider": {
"require_parameters": True,
"allow_fallbacks": True,
"order": ["OpenAI", "Anthropic"],
"only": ["OpenAI", "Google"],
"ignore": ["DeepInfra"],
"sort": "price",
"data_residency": "ru",
"max_price": {
"prompt": 10,
"completion": 20,
"image": 5,
"audio": 15,
"request": 1,
"video_per_second": 50,
"stt_per_minute": 5,
"tts_per_million_characters": 1500
}
},
"async": False,
"user": "user-123"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'seedream-3',
input: {
prompt: 'Космический корабль в стиле киберпанк',
aspect_ratio: '16:9',
images: [{type: 'url', data: 'https://example.com/image.png'}],
callBackUrl: '<string>',
seed: 42,
watermark: 'MyBrand',
image_resolution: '2K',
quality: 'high',
output_format: 'png',
animation: true,
max_images: 1,
isEnhance: false,
guidance_scale: 2.5,
strength: 0.8,
enable_safety_checker: true,
upscale_factor: '2',
font_inputs: [{font_url: 'https://example.com/fonts/custom-font.ttf', text: 'Hello World'}],
super_resolution_references: ['https://example.com/reference1.jpg']
},
provider: {
require_parameters: true,
allow_fallbacks: true,
order: ['OpenAI', 'Anthropic'],
only: ['OpenAI', 'Google'],
ignore: ['DeepInfra'],
sort: 'price',
data_residency: 'ru',
max_price: {
prompt: 10,
completion: 20,
image: 5,
audio: 15,
request: 1,
video_per_second: 50,
stt_per_minute: 5,
tts_per_million_characters: 1500
}
},
async: false,
user: 'user-123'
})
};
fetch('https://polza.ai/api/v1/media', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://polza.ai/api/v1/media",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'seedream-3',
'input' => [
'prompt' => 'Космический корабль в стиле киберпанк',
'aspect_ratio' => '16:9',
'images' => [
[
'type' => 'url',
'data' => 'https://example.com/image.png'
]
],
'callBackUrl' => '<string>',
'seed' => 42,
'watermark' => 'MyBrand',
'image_resolution' => '2K',
'quality' => 'high',
'output_format' => 'png',
'animation' => true,
'max_images' => 1,
'isEnhance' => false,
'guidance_scale' => 2.5,
'strength' => 0.8,
'enable_safety_checker' => true,
'upscale_factor' => '2',
'font_inputs' => [
[
'font_url' => 'https://example.com/fonts/custom-font.ttf',
'text' => 'Hello World'
]
],
'super_resolution_references' => [
'https://example.com/reference1.jpg'
]
],
'provider' => [
'require_parameters' => true,
'allow_fallbacks' => true,
'order' => [
'OpenAI',
'Anthropic'
],
'only' => [
'OpenAI',
'Google'
],
'ignore' => [
'DeepInfra'
],
'sort' => 'price',
'data_residency' => 'ru',
'max_price' => [
'prompt' => 10,
'completion' => 20,
'image' => 5,
'audio' => 15,
'request' => 1,
'video_per_second' => 50,
'stt_per_minute' => 5,
'tts_per_million_characters' => 1500
]
],
'async' => false,
'user' => 'user-123'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://polza.ai/api/v1/media"
payload := strings.NewReader("{\n \"model\": \"seedream-3\",\n \"input\": {\n \"prompt\": \"Космический корабль в стиле киберпанк\",\n \"aspect_ratio\": \"16:9\",\n \"images\": [\n {\n \"type\": \"url\",\n \"data\": \"https://example.com/image.png\"\n }\n ],\n \"callBackUrl\": \"<string>\",\n \"seed\": 42,\n \"watermark\": \"MyBrand\",\n \"image_resolution\": \"2K\",\n \"quality\": \"high\",\n \"output_format\": \"png\",\n \"animation\": true,\n \"max_images\": 1,\n \"isEnhance\": false,\n \"guidance_scale\": 2.5,\n \"strength\": 0.8,\n \"enable_safety_checker\": true,\n \"upscale_factor\": \"2\",\n \"font_inputs\": [\n {\n \"font_url\": \"https://example.com/fonts/custom-font.ttf\",\n \"text\": \"Hello World\"\n }\n ],\n \"super_resolution_references\": [\n \"https://example.com/reference1.jpg\"\n ]\n },\n \"provider\": {\n \"require_parameters\": true,\n \"allow_fallbacks\": true,\n \"order\": [\n \"OpenAI\",\n \"Anthropic\"\n ],\n \"only\": [\n \"OpenAI\",\n \"Google\"\n ],\n \"ignore\": [\n \"DeepInfra\"\n ],\n \"sort\": \"price\",\n \"data_residency\": \"ru\",\n \"max_price\": {\n \"prompt\": 10,\n \"completion\": 20,\n \"image\": 5,\n \"audio\": 15,\n \"request\": 1,\n \"video_per_second\": 50,\n \"stt_per_minute\": 5,\n \"tts_per_million_characters\": 1500\n }\n },\n \"async\": false,\n \"user\": \"user-123\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://polza.ai/api/v1/media")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"seedream-3\",\n \"input\": {\n \"prompt\": \"Космический корабль в стиле киберпанк\",\n \"aspect_ratio\": \"16:9\",\n \"images\": [\n {\n \"type\": \"url\",\n \"data\": \"https://example.com/image.png\"\n }\n ],\n \"callBackUrl\": \"<string>\",\n \"seed\": 42,\n \"watermark\": \"MyBrand\",\n \"image_resolution\": \"2K\",\n \"quality\": \"high\",\n \"output_format\": \"png\",\n \"animation\": true,\n \"max_images\": 1,\n \"isEnhance\": false,\n \"guidance_scale\": 2.5,\n \"strength\": 0.8,\n \"enable_safety_checker\": true,\n \"upscale_factor\": \"2\",\n \"font_inputs\": [\n {\n \"font_url\": \"https://example.com/fonts/custom-font.ttf\",\n \"text\": \"Hello World\"\n }\n ],\n \"super_resolution_references\": [\n \"https://example.com/reference1.jpg\"\n ]\n },\n \"provider\": {\n \"require_parameters\": true,\n \"allow_fallbacks\": true,\n \"order\": [\n \"OpenAI\",\n \"Anthropic\"\n ],\n \"only\": [\n \"OpenAI\",\n \"Google\"\n ],\n \"ignore\": [\n \"DeepInfra\"\n ],\n \"sort\": \"price\",\n \"data_residency\": \"ru\",\n \"max_price\": {\n \"prompt\": 10,\n \"completion\": 20,\n \"image\": 5,\n \"audio\": 15,\n \"request\": 1,\n \"video_per_second\": 50,\n \"stt_per_minute\": 5,\n \"tts_per_million_characters\": 1500\n }\n },\n \"async\": false,\n \"user\": \"user-123\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://polza.ai/api/v1/media")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"seedream-3\",\n \"input\": {\n \"prompt\": \"Космический корабль в стиле киберпанк\",\n \"aspect_ratio\": \"16:9\",\n \"images\": [\n {\n \"type\": \"url\",\n \"data\": \"https://example.com/image.png\"\n }\n ],\n \"callBackUrl\": \"<string>\",\n \"seed\": 42,\n \"watermark\": \"MyBrand\",\n \"image_resolution\": \"2K\",\n \"quality\": \"high\",\n \"output_format\": \"png\",\n \"animation\": true,\n \"max_images\": 1,\n \"isEnhance\": false,\n \"guidance_scale\": 2.5,\n \"strength\": 0.8,\n \"enable_safety_checker\": true,\n \"upscale_factor\": \"2\",\n \"font_inputs\": [\n {\n \"font_url\": \"https://example.com/fonts/custom-font.ttf\",\n \"text\": \"Hello World\"\n }\n ],\n \"super_resolution_references\": [\n \"https://example.com/reference1.jpg\"\n ]\n },\n \"provider\": {\n \"require_parameters\": true,\n \"allow_fallbacks\": true,\n \"order\": [\n \"OpenAI\",\n \"Anthropic\"\n ],\n \"only\": [\n \"OpenAI\",\n \"Google\"\n ],\n \"ignore\": [\n \"DeepInfra\"\n ],\n \"sort\": \"price\",\n \"data_residency\": \"ru\",\n \"max_price\": {\n \"prompt\": 10,\n \"completion\": 20,\n \"image\": 5,\n \"audio\": 15,\n \"request\": 1,\n \"video_per_second\": 50,\n \"stt_per_minute\": 5,\n \"tts_per_million_characters\": 1500\n }\n },\n \"async\": false,\n \"user\": \"user-123\"\n}"
response = http.request(request)
puts response.read_body{
"id": "gen_581761234567890123",
"object": "media.generation",
"status": "pending",
"created": 1703001234,
"model": "google/gemini-2.5-flash-image",
"completed_at": 1703001244,
"data": {
"url": "https://example.com/image.png",
"b64_json": "iVBORw0KGgoAAAANSUhEUgAAAAUA...",
"revised_prompt": "A beautiful sunset over the ocean"
},
"usage": {
"input_units": 1,
"output_units": 1,
"duration_seconds": 5,
"input_tokens": 10,
"output_tokens": 0,
"total_tokens": 10,
"cost_rub": 1.5,
"cost": 1.5
},
"error": {
"code": "BAD_GATEWAY",
"message": "Ошибка генерации медиа контента",
"metadata": {
"raw": "content policy violation",
"provider_name": "alibaba"
}
},
"content": "Банан и яблоко — это фрукты.",
"reasoning_summary": "Preparing image generation prompt with camera settings...",
"warnings": [
"Параметр isEnhance не поддерживается и будет проигнорирован"
]
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}Медиа
POST Media
Универсальный API генерации медиа (изображения, видео, аудио)
POST
/
v1
/
media
Создать генерацию медиа
curl --request POST \
--url https://polza.ai/api/v1/media \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "seedream-3",
"input": {
"prompt": "Космический корабль в стиле киберпанк",
"aspect_ratio": "16:9",
"images": [
{
"type": "url",
"data": "https://example.com/image.png"
}
],
"callBackUrl": "<string>",
"seed": 42,
"watermark": "MyBrand",
"image_resolution": "2K",
"quality": "high",
"output_format": "png",
"animation": true,
"max_images": 1,
"isEnhance": false,
"guidance_scale": 2.5,
"strength": 0.8,
"enable_safety_checker": true,
"upscale_factor": "2",
"font_inputs": [
{
"font_url": "https://example.com/fonts/custom-font.ttf",
"text": "Hello World"
}
],
"super_resolution_references": [
"https://example.com/reference1.jpg"
]
},
"provider": {
"require_parameters": true,
"allow_fallbacks": true,
"order": [
"OpenAI",
"Anthropic"
],
"only": [
"OpenAI",
"Google"
],
"ignore": [
"DeepInfra"
],
"sort": "price",
"data_residency": "ru",
"max_price": {
"prompt": 10,
"completion": 20,
"image": 5,
"audio": 15,
"request": 1,
"video_per_second": 50,
"stt_per_minute": 5,
"tts_per_million_characters": 1500
}
},
"async": false,
"user": "user-123"
}
'import requests
url = "https://polza.ai/api/v1/media"
payload = {
"model": "seedream-3",
"input": {
"prompt": "Космический корабль в стиле киберпанк",
"aspect_ratio": "16:9",
"images": [
{
"type": "url",
"data": "https://example.com/image.png"
}
],
"callBackUrl": "<string>",
"seed": 42,
"watermark": "MyBrand",
"image_resolution": "2K",
"quality": "high",
"output_format": "png",
"animation": True,
"max_images": 1,
"isEnhance": False,
"guidance_scale": 2.5,
"strength": 0.8,
"enable_safety_checker": True,
"upscale_factor": "2",
"font_inputs": [
{
"font_url": "https://example.com/fonts/custom-font.ttf",
"text": "Hello World"
}
],
"super_resolution_references": ["https://example.com/reference1.jpg"]
},
"provider": {
"require_parameters": True,
"allow_fallbacks": True,
"order": ["OpenAI", "Anthropic"],
"only": ["OpenAI", "Google"],
"ignore": ["DeepInfra"],
"sort": "price",
"data_residency": "ru",
"max_price": {
"prompt": 10,
"completion": 20,
"image": 5,
"audio": 15,
"request": 1,
"video_per_second": 50,
"stt_per_minute": 5,
"tts_per_million_characters": 1500
}
},
"async": False,
"user": "user-123"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'seedream-3',
input: {
prompt: 'Космический корабль в стиле киберпанк',
aspect_ratio: '16:9',
images: [{type: 'url', data: 'https://example.com/image.png'}],
callBackUrl: '<string>',
seed: 42,
watermark: 'MyBrand',
image_resolution: '2K',
quality: 'high',
output_format: 'png',
animation: true,
max_images: 1,
isEnhance: false,
guidance_scale: 2.5,
strength: 0.8,
enable_safety_checker: true,
upscale_factor: '2',
font_inputs: [{font_url: 'https://example.com/fonts/custom-font.ttf', text: 'Hello World'}],
super_resolution_references: ['https://example.com/reference1.jpg']
},
provider: {
require_parameters: true,
allow_fallbacks: true,
order: ['OpenAI', 'Anthropic'],
only: ['OpenAI', 'Google'],
ignore: ['DeepInfra'],
sort: 'price',
data_residency: 'ru',
max_price: {
prompt: 10,
completion: 20,
image: 5,
audio: 15,
request: 1,
video_per_second: 50,
stt_per_minute: 5,
tts_per_million_characters: 1500
}
},
async: false,
user: 'user-123'
})
};
fetch('https://polza.ai/api/v1/media', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://polza.ai/api/v1/media",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'seedream-3',
'input' => [
'prompt' => 'Космический корабль в стиле киберпанк',
'aspect_ratio' => '16:9',
'images' => [
[
'type' => 'url',
'data' => 'https://example.com/image.png'
]
],
'callBackUrl' => '<string>',
'seed' => 42,
'watermark' => 'MyBrand',
'image_resolution' => '2K',
'quality' => 'high',
'output_format' => 'png',
'animation' => true,
'max_images' => 1,
'isEnhance' => false,
'guidance_scale' => 2.5,
'strength' => 0.8,
'enable_safety_checker' => true,
'upscale_factor' => '2',
'font_inputs' => [
[
'font_url' => 'https://example.com/fonts/custom-font.ttf',
'text' => 'Hello World'
]
],
'super_resolution_references' => [
'https://example.com/reference1.jpg'
]
],
'provider' => [
'require_parameters' => true,
'allow_fallbacks' => true,
'order' => [
'OpenAI',
'Anthropic'
],
'only' => [
'OpenAI',
'Google'
],
'ignore' => [
'DeepInfra'
],
'sort' => 'price',
'data_residency' => 'ru',
'max_price' => [
'prompt' => 10,
'completion' => 20,
'image' => 5,
'audio' => 15,
'request' => 1,
'video_per_second' => 50,
'stt_per_minute' => 5,
'tts_per_million_characters' => 1500
]
],
'async' => false,
'user' => 'user-123'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://polza.ai/api/v1/media"
payload := strings.NewReader("{\n \"model\": \"seedream-3\",\n \"input\": {\n \"prompt\": \"Космический корабль в стиле киберпанк\",\n \"aspect_ratio\": \"16:9\",\n \"images\": [\n {\n \"type\": \"url\",\n \"data\": \"https://example.com/image.png\"\n }\n ],\n \"callBackUrl\": \"<string>\",\n \"seed\": 42,\n \"watermark\": \"MyBrand\",\n \"image_resolution\": \"2K\",\n \"quality\": \"high\",\n \"output_format\": \"png\",\n \"animation\": true,\n \"max_images\": 1,\n \"isEnhance\": false,\n \"guidance_scale\": 2.5,\n \"strength\": 0.8,\n \"enable_safety_checker\": true,\n \"upscale_factor\": \"2\",\n \"font_inputs\": [\n {\n \"font_url\": \"https://example.com/fonts/custom-font.ttf\",\n \"text\": \"Hello World\"\n }\n ],\n \"super_resolution_references\": [\n \"https://example.com/reference1.jpg\"\n ]\n },\n \"provider\": {\n \"require_parameters\": true,\n \"allow_fallbacks\": true,\n \"order\": [\n \"OpenAI\",\n \"Anthropic\"\n ],\n \"only\": [\n \"OpenAI\",\n \"Google\"\n ],\n \"ignore\": [\n \"DeepInfra\"\n ],\n \"sort\": \"price\",\n \"data_residency\": \"ru\",\n \"max_price\": {\n \"prompt\": 10,\n \"completion\": 20,\n \"image\": 5,\n \"audio\": 15,\n \"request\": 1,\n \"video_per_second\": 50,\n \"stt_per_minute\": 5,\n \"tts_per_million_characters\": 1500\n }\n },\n \"async\": false,\n \"user\": \"user-123\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://polza.ai/api/v1/media")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"seedream-3\",\n \"input\": {\n \"prompt\": \"Космический корабль в стиле киберпанк\",\n \"aspect_ratio\": \"16:9\",\n \"images\": [\n {\n \"type\": \"url\",\n \"data\": \"https://example.com/image.png\"\n }\n ],\n \"callBackUrl\": \"<string>\",\n \"seed\": 42,\n \"watermark\": \"MyBrand\",\n \"image_resolution\": \"2K\",\n \"quality\": \"high\",\n \"output_format\": \"png\",\n \"animation\": true,\n \"max_images\": 1,\n \"isEnhance\": false,\n \"guidance_scale\": 2.5,\n \"strength\": 0.8,\n \"enable_safety_checker\": true,\n \"upscale_factor\": \"2\",\n \"font_inputs\": [\n {\n \"font_url\": \"https://example.com/fonts/custom-font.ttf\",\n \"text\": \"Hello World\"\n }\n ],\n \"super_resolution_references\": [\n \"https://example.com/reference1.jpg\"\n ]\n },\n \"provider\": {\n \"require_parameters\": true,\n \"allow_fallbacks\": true,\n \"order\": [\n \"OpenAI\",\n \"Anthropic\"\n ],\n \"only\": [\n \"OpenAI\",\n \"Google\"\n ],\n \"ignore\": [\n \"DeepInfra\"\n ],\n \"sort\": \"price\",\n \"data_residency\": \"ru\",\n \"max_price\": {\n \"prompt\": 10,\n \"completion\": 20,\n \"image\": 5,\n \"audio\": 15,\n \"request\": 1,\n \"video_per_second\": 50,\n \"stt_per_minute\": 5,\n \"tts_per_million_characters\": 1500\n }\n },\n \"async\": false,\n \"user\": \"user-123\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://polza.ai/api/v1/media")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"seedream-3\",\n \"input\": {\n \"prompt\": \"Космический корабль в стиле киберпанк\",\n \"aspect_ratio\": \"16:9\",\n \"images\": [\n {\n \"type\": \"url\",\n \"data\": \"https://example.com/image.png\"\n }\n ],\n \"callBackUrl\": \"<string>\",\n \"seed\": 42,\n \"watermark\": \"MyBrand\",\n \"image_resolution\": \"2K\",\n \"quality\": \"high\",\n \"output_format\": \"png\",\n \"animation\": true,\n \"max_images\": 1,\n \"isEnhance\": false,\n \"guidance_scale\": 2.5,\n \"strength\": 0.8,\n \"enable_safety_checker\": true,\n \"upscale_factor\": \"2\",\n \"font_inputs\": [\n {\n \"font_url\": \"https://example.com/fonts/custom-font.ttf\",\n \"text\": \"Hello World\"\n }\n ],\n \"super_resolution_references\": [\n \"https://example.com/reference1.jpg\"\n ]\n },\n \"provider\": {\n \"require_parameters\": true,\n \"allow_fallbacks\": true,\n \"order\": [\n \"OpenAI\",\n \"Anthropic\"\n ],\n \"only\": [\n \"OpenAI\",\n \"Google\"\n ],\n \"ignore\": [\n \"DeepInfra\"\n ],\n \"sort\": \"price\",\n \"data_residency\": \"ru\",\n \"max_price\": {\n \"prompt\": 10,\n \"completion\": 20,\n \"image\": 5,\n \"audio\": 15,\n \"request\": 1,\n \"video_per_second\": 50,\n \"stt_per_minute\": 5,\n \"tts_per_million_characters\": 1500\n }\n },\n \"async\": false,\n \"user\": \"user-123\"\n}"
response = http.request(request)
puts response.read_body{
"id": "gen_581761234567890123",
"object": "media.generation",
"status": "pending",
"created": 1703001234,
"model": "google/gemini-2.5-flash-image",
"completed_at": 1703001244,
"data": {
"url": "https://example.com/image.png",
"b64_json": "iVBORw0KGgoAAAANSUhEUgAAAAUA...",
"revised_prompt": "A beautiful sunset over the ocean"
},
"usage": {
"input_units": 1,
"output_units": 1,
"duration_seconds": 5,
"input_tokens": 10,
"output_tokens": 0,
"total_tokens": 10,
"cost_rub": 1.5,
"cost": 1.5
},
"error": {
"code": "BAD_GATEWAY",
"message": "Ошибка генерации медиа контента",
"metadata": {
"raw": "content policy violation",
"provider_name": "alibaba"
}
},
"content": "Банан и яблоко — это фрукты.",
"reasoning_summary": "Preparing image generation prompt with camera settings...",
"warnings": [
"Параметр isEnhance не поддерживается и будет проигнорирован"
]
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}О Media API
Универсальный эндпоинт для генерации медиа контента. Поддерживает различные модели и провайдеров через единый интерфейс.Общие параметры
| Параметр | Тип | Обязательный | Описание |
|---|---|---|---|
model | string | Да | ID модели для генерации |
input | object | Да | Параметры генерации (зависят от модели) |
async | boolean | Нет | Принудительный асинхронный режим |
user | string | Нет | Идентификатор конечного пользователя |
provider | object | Нет | Конфигурация роутинга по провайдерам |
Передача файлов (URL и base64)
Для моделей, поддерживающих image-to-image или video-to-video, медиа файлы передаются в массивеimages или videos. Каждый элемент — объект с полями:
| Поле | Тип | Описание |
|---|---|---|
type | "url" | "base64" | Формат данных |
data | string | URL файла или base64-строка (с data URI или без) |
Пример с base64
curl -X POST "https://polza.ai/api/v1/media" \
-H "Authorization: Bearer <POLZA_AI_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "seedream-3",
"input": {
"prompt": "Сделай изображение ярче и добавь закат на фоне",
"images": [
{
"type": "base64",
"data": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg..."
}
]
}
}'
{
"model": "gpt-image-1",
"input": {
"prompt": "Объедини эти изображения в коллаж",
"images": [
{ "type": "url", "data": "https://example.com/photo1.png" },
{ "type": "base64", "data": "data:image/jpeg;base64,/9j/4AAQSkZJRg..." }
]
}
}
Base64 поддерживается как с data URI (
data:image/png;base64,...), так и без — просто строка base64.
Если провайдер не поддерживает base64 напрямую, файл автоматически загружается в хранилище и передаётся как URL.Типы контента
- Изображения (Nano Banana, Seedream, GPT Image и др.)
- Видео (Veo, Wan, Kling, Seedance, Sora и др.)
- Аудио — синтез речи (TTS) и распознавание речи (STT)
Хранение результатов
При генерации медиа контента Polza.ai автоматически:- Скачивает результат у AI провайдера на собственное хранилище
- Хранит файлы 7 дней для повторного доступа
- Раздаёт через CDN для быстрого доступа внутри России
После истечения 7 дней файлы автоматически удаляются.
Для постоянного хранения используйте Storage API с политикой
PERMANENT.Руководства по моделям
Подробные примеры, параметры и особенности каждой модели — в руководствах:Видео
Veo 3.1, Wan 2.5/2.6, Kling, Seedance, Sora и другие модели видеогенерации
Изображения
Seedream, Nano Banana, GPT Image, Flux, Grok Imagine и другие модели генерации изображений
Аудио
ElevenLabs TTS и другие модели синтеза и распознавания речи
Ответ
Возвращает объект Media Status со статусомpending:
{
"id": "aig_abc123",
"object": "media.generation",
"status": "pending",
"created": 1703001244,
"model": "google/veo3"
}
Авторизации
Тело
application/json
Ответ
Была ли эта страница полезной?