Справочник API
Все операции REST с параметрами, телом и ответами. Страница собирается из спецификации OpenAPI при каждой сборке документации, описания полей взяты из неё и идут на английском.
- Базовый адрес:
https://api.synesta.ai/v1 - Авторизация: заголовок
Authorization: Bearer <ключ>на каждом запросе, см. Аутентификация. - Спецификация: OpenAPI 1.0.0
Коды ошибок и что с ними делать · Ошибки и повторы.
Account
Plan, credit balance and limits of the key
GET /account
Ответы
| Код | Описание | Тип |
|---|---|---|
200 | Account of the key owner. | data: Account |
401 | No key, a wrong key, a revoked or expired key. Code unauthenticated. Заголовки: WWW-Authenticate. | ApiError |
403 | The account or the key cannot use the API. Codes: account_blocked, account_pending_deletion, api_access_required, api_not_enabled, rest_not_included, api_key_suspended, team_not_supported, plan_required. | ApiError |
429 | Too many requests, too many running generations or the daily credit limit of the key is reached. Retry after Retry-After seconds. Codes: rate_limit_exceeded, concurrency_limit, daily_limit_exceeded. Заголовки: Retry-After. | ApiError |
503 | Temporary problem, safe to retry with the same Idempotency-Key. Codes: upload_failed, model_unavailable, model_busy, service_unavailable, webhooks_disabled. A plain 500 internal_error is also possible. Заголовки: Retry-After. | ApiError |
Models
Models you can use, with their limits
GET /models
Параметры
| Имя | Где | Тип | Обяз. | Описание |
|---|---|---|---|---|
type | query | GenerationType | Return models of one type only. |
Ответы
| Код | Описание | Тип |
|---|---|---|
200 | List of models. | data: array of Model |
401 | No key, a wrong key, a revoked or expired key. Code unauthenticated. Заголовки: WWW-Authenticate. | ApiError |
403 | The account or the key cannot use the API. Codes: account_blocked, account_pending_deletion, api_access_required, api_not_enabled, rest_not_included, api_key_suspended, team_not_supported, plan_required. | ApiError |
422 | The request is wrong or cannot be priced. error.details.param names the field. Codes: invalid_parameters, unsupported_input, reference_not_allowed, reference_not_analyzed, moderation_blocked, pricing_not_configured, max_credits_exceeded, api_key_limit_reached, reference_fetch_failed, upload_too_large, reference_library_full, invalid_webhook_url, webhook_secret_required. | ApiError |
429 | Too many requests, too many running generations or the daily credit limit of the key is reached. Retry after Retry-After seconds. Codes: rate_limit_exceeded, concurrency_limit, daily_limit_exceeded. Заголовки: Retry-After. | ApiError |
503 | Temporary problem, safe to retry with the same Idempotency-Key. Codes: upload_failed, model_unavailable, model_busy, service_unavailable, webhooks_disabled. A plain 500 internal_error is also possible. Заголовки: Retry-After. | ApiError |
One model with its capabilities
GET /models/{id}
Параметры
| Имя | Где | Тип | Обяз. | Описание |
|---|---|---|---|---|
id | path | string | да | Model id from GET /models. |
Ответы
| Код | Описание | Тип |
|---|---|---|
200 | The model. | data: Model |
401 | No key, a wrong key, a revoked or expired key. Code unauthenticated. Заголовки: WWW-Authenticate. | ApiError |
403 | The account or the key cannot use the API. Codes: account_blocked, account_pending_deletion, api_access_required, api_not_enabled, rest_not_included, api_key_suspended, team_not_supported, plan_required. | ApiError |
404 | Unknown model or an object that is not yours. Codes: unknown_model, not_found. | ApiError |
429 | Too many requests, too many running generations or the daily credit limit of the key is reached. Retry after Retry-After seconds. Codes: rate_limit_exceeded, concurrency_limit, daily_limit_exceeded. Заголовки: Retry-After. | ApiError |
503 | Temporary problem, safe to retry with the same Idempotency-Key. Codes: upload_failed, model_unavailable, model_busy, service_unavailable, webhooks_disabled. A plain 500 internal_error is also possible. Заголовки: Retry-After. | ApiError |
Generations
Price of a generation without starting it
POST /estimate
Takes the same body as POST /generations. Nothing is charged and no Idempotency-Key is needed.
Тело запроса · application/json
Тип: GenerationInput
Ответы
| Код | Описание | Тип |
|---|---|---|
200 | Price in credits. | data: Estimate |
401 | No key, a wrong key, a revoked or expired key. Code unauthenticated. Заголовки: WWW-Authenticate. | ApiError |
403 | The account or the key cannot use the API. Codes: account_blocked, account_pending_deletion, api_access_required, api_not_enabled, rest_not_included, api_key_suspended, team_not_supported, plan_required. | ApiError |
404 | Unknown model or an object that is not yours. Codes: unknown_model, not_found. | ApiError |
422 | The request is wrong or cannot be priced. error.details.param names the field. Codes: invalid_parameters, unsupported_input, reference_not_allowed, reference_not_analyzed, moderation_blocked, pricing_not_configured, max_credits_exceeded, api_key_limit_reached, reference_fetch_failed, upload_too_large, reference_library_full, invalid_webhook_url, webhook_secret_required. | ApiError |
429 | Too many requests, too many running generations or the daily credit limit of the key is reached. Retry after Retry-After seconds. Codes: rate_limit_exceeded, concurrency_limit, daily_limit_exceeded. Заголовки: Retry-After. | ApiError |
503 | Temporary problem, safe to retry with the same Idempotency-Key. Codes: upload_failed, model_unavailable, model_busy, service_unavailable, webhooks_disabled. A plain 500 internal_error is also possible. Заголовки: Retry-After. | ApiError |
Generations made with API keys, newest first
GET /generations
Параметры
| Имя | Где | Тип | Обяз. | Описание |
|---|---|---|---|---|
type | query | GenerationType | ||
limit | query | integer | Page size. The default is 20, the maximum is set by the service. min 1 | |
before | query | integer | Return generations with an id below this one. Use meta.next_before of the previous page. min 1 |
Ответы
| Код | Описание | Тип |
|---|---|---|
200 | A page of generations. | data: array of Generation |
401 | No key, a wrong key, a revoked or expired key. Code unauthenticated. Заголовки: WWW-Authenticate. | ApiError |
403 | The account or the key cannot use the API. Codes: account_blocked, account_pending_deletion, api_access_required, api_not_enabled, rest_not_included, api_key_suspended, team_not_supported, plan_required. | ApiError |
422 | The request is wrong or cannot be priced. error.details.param names the field. Codes: invalid_parameters, unsupported_input, reference_not_allowed, reference_not_analyzed, moderation_blocked, pricing_not_configured, max_credits_exceeded, api_key_limit_reached, reference_fetch_failed, upload_too_large, reference_library_full, invalid_webhook_url, webhook_secret_required. | ApiError |
429 | Too many requests, too many running generations or the daily credit limit of the key is reached. Retry after Retry-After seconds. Codes: rate_limit_exceeded, concurrency_limit, daily_limit_exceeded. Заголовки: Retry-After. | ApiError |
503 | Temporary problem, safe to retry with the same Idempotency-Key. Codes: upload_failed, model_unavailable, model_busy, service_unavailable, webhooks_disabled. A plain 500 internal_error is also possible. Заголовки: Retry-After. | ApiError |
Start a generation
POST /generations
Charges credits when accepted and answers 202 with the generation in its initial status. Poll GET /generations/{id} for the result. A repeat with the same Idempotency-Key and the same body returns the same generation with HTTP 200 and meta.replayed: true, without a second charge. The same key with a different body gives 409 idempotency_conflict. Optional webhook_url makes the service call you when the generation is finished (see the generation_finished webhook); it needs a signing secret created in your profile (API section), otherwise 422 webhook_secret_required. webhook_url is not part of the idempotency check: a replay keeps the address of the first request.
Параметры
| Имя | Где | Тип | Обяз. | Описание |
|---|---|---|---|---|
Idempotency-Key | header | string | да | Unique string for one logical request (for example a UUID). Without it the request is rejected with 422 invalid_parameters before any charge. The key is remembered for 24 hours. min length 1, max length 255 |
Тело запроса · application/json
Тип: GenerationInput
Ответы
| Код | Описание | Тип |
|---|---|---|
200 | Replay of an earlier request with the same Idempotency-Key. | GenerationStarted |
202 | Accepted. | GenerationStarted |
401 | No key, a wrong key, a revoked or expired key. Code unauthenticated. Заголовки: WWW-Authenticate. | ApiError |
402 | Not enough credits (insufficient_credits) or, for REST, not enough API balance (insufficient_api_balance). | ApiError |
403 | The account or the key cannot use the API. Codes: account_blocked, account_pending_deletion, api_access_required, api_not_enabled, rest_not_included, api_key_suspended, team_not_supported, plan_required. | ApiError |
404 | Unknown model or an object that is not yours. Codes: unknown_model, not_found. | ApiError |
409 | Codes: idempotency_conflict (same key, different body), idempotency_in_progress (the first request is still running, retry). | ApiError |
422 | The request is wrong or cannot be priced. error.details.param names the field. Codes: invalid_parameters, unsupported_input, reference_not_allowed, reference_not_analyzed, moderation_blocked, pricing_not_configured, max_credits_exceeded, api_key_limit_reached, reference_fetch_failed, upload_too_large, reference_library_full, invalid_webhook_url, webhook_secret_required. | ApiError |
429 | Too many requests, too many running generations or the daily credit limit of the key is reached. Retry after Retry-After seconds. Codes: rate_limit_exceeded, concurrency_limit, daily_limit_exceeded. Заголовки: Retry-After. | ApiError |
503 | Temporary problem, safe to retry with the same Idempotency-Key. Codes: upload_failed, model_unavailable, model_busy, service_unavailable, webhooks_disabled. A plain 500 internal_error is also possible. Заголовки: Retry-After. | ApiError |
Status and result of one generation
GET /generations/{id}
Параметры
| Имя | Где | Тип | Обяз. | Описание |
|---|---|---|---|---|
id | path | integer | да | min 1 |
Ответы
| Код | Описание | Тип |
|---|---|---|
200 | The generation. outputs is filled when status is done. | data: Generation |
401 | No key, a wrong key, a revoked or expired key. Code unauthenticated. Заголовки: WWW-Authenticate. | ApiError |
403 | The account or the key cannot use the API. Codes: account_blocked, account_pending_deletion, api_access_required, api_not_enabled, rest_not_included, api_key_suspended, team_not_supported, plan_required. | ApiError |
404 | Unknown model or an object that is not yours. Codes: unknown_model, not_found. | ApiError |
429 | Too many requests, too many running generations or the daily credit limit of the key is reached. Retry after Retry-After seconds. Codes: rate_limit_exceeded, concurrency_limit, daily_limit_exceeded. Заголовки: Retry-After. | ApiError |
503 | Temporary problem, safe to retry with the same Idempotency-Key. Codes: upload_failed, model_unavailable, model_busy, service_unavailable, webhooks_disabled. A plain 500 internal_error is also possible. Заголовки: Retry-After. | ApiError |
References
Upload a reference file for later generations
POST /references
Send one of: multipart field file; JSON url (public https link); JSON file_base64 with mime. The returned id goes into reference_ids of a generation. Video and audio references are accepted through multipart only.
Тело запроса · multipart/form-data
| Поле | Тип | Обяз. | Описание |
|---|---|---|---|
file | string (binary) | да |
Тело запроса · application/json
Вариант 1
| Поле | Тип | Обяз. | Описание |
|---|---|---|---|
url | string (uri) | да | max length 2048 |
Вариант 2
| Поле | Тип | Обяз. | Описание |
|---|---|---|---|
file_base64 | string | да | |
mime | string | да | one of: image/jpeg, image/png, image/webp, image/gif |
name | string | max length 255 |
Ответы
| Код | Описание | Тип |
|---|---|---|
201 | Reference stored. | data: Reference |
401 | No key, a wrong key, a revoked or expired key. Code unauthenticated. Заголовки: WWW-Authenticate. | ApiError |
403 | The account or the key cannot use the API. Codes: account_blocked, account_pending_deletion, api_access_required, api_not_enabled, rest_not_included, api_key_suspended, team_not_supported, plan_required. | ApiError |
422 | The request is wrong or cannot be priced. error.details.param names the field. Codes: invalid_parameters, unsupported_input, reference_not_allowed, reference_not_analyzed, moderation_blocked, pricing_not_configured, max_credits_exceeded, api_key_limit_reached, reference_fetch_failed, upload_too_large, reference_library_full, invalid_webhook_url, webhook_secret_required. | ApiError |
429 | Too many requests, too many running generations or the daily credit limit of the key is reached. Retry after Retry-After seconds. Codes: rate_limit_exceeded, concurrency_limit, daily_limit_exceeded. Заголовки: Retry-After. | ApiError |
503 | Temporary problem, safe to retry with the same Idempotency-Key. Codes: upload_failed, model_unavailable, model_busy, service_unavailable, webhooks_disabled. A plain 500 internal_error is also possible. Заголовки: Retry-After. | ApiError |
Схемы
Объекты, на которые ссылаются операции.
GenerationType
image · video · music · voice · 3d
ErrorCode
Public error code. retryable in the error tells if a repeat can help.
unauthenticated · account_blocked · account_pending_deletion · api_access_required · api_not_enabled · rest_not_included · api_key_suspended · team_not_supported · plan_required · invalid_parameters · unsupported_input · invalid_webhook_url · webhook_secret_required · webhooks_disabled · unknown_model · not_found · reference_not_allowed · reference_not_analyzed · moderation_blocked · pricing_not_configured · max_credits_exceeded · api_key_limit_reached · reference_fetch_failed · upload_too_large · reference_library_full · upload_failed · method_not_allowed · insufficient_credits · insufficient_api_balance · idempotency_conflict · idempotency_in_progress · rate_limit_exceeded · concurrency_limit · daily_limit_exceeded · model_unavailable · model_busy · service_unavailable · internal_error
GenerationErrorCode
Why a started generation failed (Generation.error.code).
content_rejected · reference_rejected · invalid_input · no_result · result_unavailable · temporary_error · timeout · model_busy · service_unavailable
ApiError
| Поле | Тип | Обяз. | Описание |
|---|---|---|---|
error | object | да |
Account
| Поле | Тип | Обяз. | Описание |
|---|---|---|---|
plan | string | да | Plan slug of the account. |
credits | number | да | Credit balance. |
api_balance_usd | number | REST only: API balance in US dollars. REST is paid from it, not from plan credits. | |
usd_per_credit | number | REST only: price of one credit charged from the API balance, in US dollars. | |
key | object | да |
Model
| Поле | Тип | Обяз. | Описание |
|---|---|---|---|
id | string | да | Value for model in requests. |
type | GenerationType | да | |
name | string | да | |
brand | string | null | да | |
credits_from | number | null | да | Lowest price in credits. |
available | boolean | да | |
reason | string | null | да | Why the model is not available now. |
alternatives | array of string | да | Ids of models to use instead. |
capabilities | Capabilities | да | What the model accepts. A key is absent when it does not apply to the model. |
Capabilities
What the model accepts. A key is absent when it does not apply to the model.
| Поле | Тип | Обяз. | Описание |
|---|---|---|---|
aspects | array of string | ||
default_aspect | string | null | ||
resolutions | array of string | ||
image_resolutions | array of string | ||
default_resolution | string | null | ||
duration_options | array of number | ||
duration_min | number | null | ||
duration_max | number | null | ||
fixed_duration | number | null | ||
default_duration | number | null | ||
has_sound | boolean | ||
max_prompt_length | integer | null | ||
text_optional | boolean | ||
allow_reference_images | boolean | ||
requires_reference_image | boolean | ||
max_reference_images | integer | null | ||
supports_seed | boolean | ||
supports_negative_prompt | boolean | ||
max_negative_prompt_length | integer | null | ||
upscale_factors | array of string | ||
requires_mask | boolean | ||
voices | array of object | Voice models: voices to pass as voice_id. | |
default_voice | string | null | Voice used when voice_id is omitted. | |
speed_min | number | ||
speed_max | number |
GenerationInput
Strict body: an unknown field or a wrong type is rejected with 422 invalid_parameters, nothing is silently adjusted. Each type takes only its own fields (image: aspect, resolution, upscale_factor, reference_ids, mask_target, negative, seed; video: aspect, resolution, duration, sound, upscale_factor, video_mode, reference_ids, negative, seed; music: mode, instrumental, style, title, vocal_gender; voice: voice_id, speed). A known field that does not apply to the type or model (for example duration for music, or upscale_factor on a model without upscaling) is rejected with 422 unsupported_input, error.details.param names it. Which fields a model takes is in capabilities of GET /models/{id}.
| Поле | Тип | Обяз. | Описание |
|---|---|---|---|
type | GenerationType | да | |
model | string | да | max length 120 |
prompt | string | Maximum length is in capabilities.max_prompt_length. | |
negative | string | ||
aspect | string | max length 16 | |
aspect_ratio | string | max length 16 | |
resolution | string | max length 16 | |
duration | integer | Seconds. | |
sound | boolean | ||
upscale_factor | integer | ||
video_mode | string | max length 32 | |
reference_ids | array of integer | Ids from POST /references. max items 50 | |
mask_target | string | max length 80 | |
seed | integer | ||
mode | string | max length 32 | |
instrumental | boolean | ||
style | string | max length 1000 | |
title | string | max length 200 | |
vocal_gender | string | max length 16 | |
voice_id | string | An id from capabilities.voices of the model. Omitted: capabilities.default_voice. max length 120 | |
speed | number | ||
max_credits | number | Refuse the request if it costs more than this many credits (422 max_credits_exceeded). min 0 | |
webhook_url | string (uri) | Only for POST /generations. An https link on port 443 that is reachable from the internet (no credentials, no redirects followed). Called once when the generation becomes done or failed. Other addresses give 422 invalid_webhook_url. max length 2048 |
Applied
Parameters the service actually used.
| Поле | Тип | Обяз. | Описание |
|---|---|---|---|
model | string | да | |
aspect | string | ||
resolution | string | ||
image_quality | string | ||
duration | number | ||
sound | boolean | ||
upscale_factor | integer | ||
video_mode | string | ||
negative | string | ||
seed | integer | ||
style | string | ||
title | string | ||
vocal_gender | string | ||
instrumental | boolean | ||
voice_id | string | ||
speed | number | ||
reference_count | integer |
Estimate
| Поле | Тип | Обяз. | Описание |
|---|---|---|---|
model | string | да | |
credits | number | да | Price of the generation in credits. |
cost_usd | number | REST only: what the launch will charge from the API balance, in US dollars. | |
base_credits | number | да | |
exceeds_daily_limit | boolean | да | True when this price does not fit into what is left of the daily limit of the key. |
applied | Applied | да | Parameters the service actually used. |
Output
| Поле | Тип | Обяз. | Описание |
|---|---|---|---|
url | string (uri) | да | Link to the result file. |
kind | string | да | one of: image, video, audio, model, file |
mime | string | null | да | |
preview_url | string | null (uri) | да | |
thumb_url | string | null (uri) | да |
GenerationError
| Поле | Тип | Обяз. | Описание |
|---|---|---|---|
code | GenerationErrorCode | да | Why a started generation failed (Generation.error.code). |
message | string | да | |
retryable | boolean | да | |
retry_after_seconds | integer |
Generation
| Поле | Тип | Обяз. | Описание |
|---|---|---|---|
id | integer | да | |
type | GenerationType | да | |
model | string | null | да | |
status | string | да | Waiting and running statuses end in done or failed. Poll until one of those two. |
prompt | string | null | да | |
cost_credits | number | да | |
cost_usd | number | Present when the generation was paid from the API balance (REST). Net amount in US dollars: charged minus refunded, so it matches cost_credits after a partial delivery or a full refund. | |
refunded | boolean | да | True when the whole price was returned. |
credits_refunded | number | да | |
created_at | string | null (date-time) | да | |
finished_at | string | null (date-time) | да | |
outputs | array of Output | да | Empty until status is done. |
error | GenerationError | null | да | Set when status is failed. Failed generations are refunded. |
queue | object | да | |
partial_refund | object | null | да | Set when fewer results than ordered were delivered and the difference was returned. |
applied | Applied | да | Parameters the service actually used. |
GenerationStarted
| Поле | Тип | Обяз. | Описание |
|---|---|---|---|
data | Generation | да | |
meta | object | да |
Reference
| Поле | Тип | Обяз. | Описание |
|---|---|---|---|
id | integer | да | |
type | string | да | one of: image, video, audio |
width | integer | null | да | |
height | integer | null | да | |
duration_seconds | number | null | да | |
url | string | null (uri) | да | |
face_status | string | да | Some models do not take references with a recognisable face; pending means the check is still running. one of: not_applicable, pending, clear, face_detected |