Skip to content

Методы

Справочник 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

Ответы

КодОписаниеТип
200Account of the key owner.data: Account
401No key, a wrong key, a revoked or expired key. Code unauthenticated. Заголовки: WWW-Authenticate.ApiError
403The 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
429Too 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
503Temporary 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

Параметры

ИмяГдеТипОбяз.Описание
typequeryGenerationTypeReturn models of one type only.

Ответы

КодОписаниеТип
200List of models.data: array of Model
401No key, a wrong key, a revoked or expired key. Code unauthenticated. Заголовки: WWW-Authenticate.ApiError
403The 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
422The 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
429Too 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
503Temporary 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}

Параметры

ИмяГдеТипОбяз.Описание
idpathstringдаModel id from GET /models.

Ответы

КодОписаниеТип
200The model.data: Model
401No key, a wrong key, a revoked or expired key. Code unauthenticated. Заголовки: WWW-Authenticate.ApiError
403The 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
404Unknown model or an object that is not yours. Codes: unknown_model, not_found.ApiError
429Too 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
503Temporary 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

Ответы

КодОписаниеТип
200Price in credits.data: Estimate
401No key, a wrong key, a revoked or expired key. Code unauthenticated. Заголовки: WWW-Authenticate.ApiError
403The 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
404Unknown model or an object that is not yours. Codes: unknown_model, not_found.ApiError
422The 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
429Too 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
503Temporary 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

Параметры

ИмяГдеТипОбяз.Описание
typequeryGenerationType
limitqueryintegerPage size. The default is 20, the maximum is set by the service. min 1
beforequeryintegerReturn generations with an id below this one. Use meta.next_before of the previous page. min 1

Ответы

КодОписаниеТип
200A page of generations.data: array of Generation
401No key, a wrong key, a revoked or expired key. Code unauthenticated. Заголовки: WWW-Authenticate.ApiError
403The 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
422The 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
429Too 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
503Temporary 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-Keyheaderstringда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

Ответы

КодОписаниеТип
200Replay of an earlier request with the same Idempotency-Key.GenerationStarted
202Accepted.GenerationStarted
401No key, a wrong key, a revoked or expired key. Code unauthenticated. Заголовки: WWW-Authenticate.ApiError
402Not enough credits (insufficient_credits) or, for REST, not enough API balance (insufficient_api_balance).ApiError
403The 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
404Unknown model or an object that is not yours. Codes: unknown_model, not_found.ApiError
409Codes: idempotency_conflict (same key, different body), idempotency_in_progress (the first request is still running, retry).ApiError
422The 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
429Too 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
503Temporary 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}

Параметры

ИмяГдеТипОбяз.Описание
idpathintegerдаmin 1

Ответы

КодОписаниеТип
200The generation. outputs is filled when status is done.data: Generation
401No key, a wrong key, a revoked or expired key. Code unauthenticated. Заголовки: WWW-Authenticate.ApiError
403The 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
404Unknown model or an object that is not yours. Codes: unknown_model, not_found.ApiError
429Too 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
503Temporary 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

ПолеТипОбяз.Описание
filestring (binary)да

Тело запроса · application/json

Вариант 1

ПолеТипОбяз.Описание
urlstring (uri)даmax length 2048

Вариант 2

ПолеТипОбяз.Описание
file_base64stringда
mimestringдаone of: image/jpeg, image/png, image/webp, image/gif
namestringmax length 255

Ответы

КодОписаниеТип
201Reference stored.data: Reference
401No key, a wrong key, a revoked or expired key. Code unauthenticated. Заголовки: WWW-Authenticate.ApiError
403The 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
422The 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
429Too 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
503Temporary 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 ​

ПолеТипОбяз.Описание
errorobjectда

Account ​

ПолеТипОбяз.Описание
planstringдаPlan slug of the account.
creditsnumberдаCredit balance.
api_balance_usdnumberREST only: API balance in US dollars. REST is paid from it, not from plan credits.
usd_per_creditnumberREST only: price of one credit charged from the API balance, in US dollars.
keyobjectда

Model ​

ПолеТипОбяз.Описание
idstringдаValue for model in requests.
typeGenerationTypeда
namestringда
brandstring | nullда
credits_fromnumber | nullдаLowest price in credits.
availablebooleanда
reasonstring | nullдаWhy the model is not available now.
alternativesarray of stringдаIds of models to use instead.
capabilitiesCapabilitiesда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.

ПолеТипОбяз.Описание
aspectsarray of string
default_aspectstring | null
resolutionsarray of string
image_resolutionsarray of string
default_resolutionstring | null
duration_optionsarray of number
duration_minnumber | null
duration_maxnumber | null
fixed_durationnumber | null
default_durationnumber | null
has_soundboolean
max_prompt_lengthinteger | null
text_optionalboolean
allow_reference_imagesboolean
requires_reference_imageboolean
max_reference_imagesinteger | null
supports_seedboolean
supports_negative_promptboolean
max_negative_prompt_lengthinteger | null
upscale_factorsarray of string
requires_maskboolean
voicesarray of objectVoice models: voices to pass as voice_id.
default_voicestring | nullVoice used when voice_id is omitted.
speed_minnumber
speed_maxnumber

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}.

ПолеТипОбяз.Описание
typeGenerationTypeда
modelstringдаmax length 120
promptstringMaximum length is in capabilities.max_prompt_length.
negativestring
aspectstringmax length 16
aspect_ratiostringmax length 16
resolutionstringmax length 16
durationintegerSeconds.
soundboolean
upscale_factorinteger
video_modestringmax length 32
reference_idsarray of integerIds from POST /references. max items 50
mask_targetstringmax length 80
seedinteger
modestringmax length 32
instrumentalboolean
stylestringmax length 1000
titlestringmax length 200
vocal_genderstringmax length 16
voice_idstringAn id from capabilities.voices of the model. Omitted: capabilities.default_voice. max length 120
speednumber
max_creditsnumberRefuse the request if it costs more than this many credits (422 max_credits_exceeded). min 0
webhook_urlstring (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.

ПолеТипОбяз.Описание
modelstringда
aspectstring
resolutionstring
image_qualitystring
durationnumber
soundboolean
upscale_factorinteger
video_modestring
negativestring
seedinteger
stylestring
titlestring
vocal_genderstring
instrumentalboolean
voice_idstring
speednumber
reference_countinteger

Estimate ​

ПолеТипОбяз.Описание
modelstringда
creditsnumberдаPrice of the generation in credits.
cost_usdnumberREST only: what the launch will charge from the API balance, in US dollars.
base_creditsnumberда
exceeds_daily_limitbooleanдаTrue when this price does not fit into what is left of the daily limit of the key.
appliedAppliedдаParameters the service actually used.

Output ​

ПолеТипОбяз.Описание
urlstring (uri)даLink to the result file.
kindstringдаone of: image, video, audio, model, file
mimestring | nullда
preview_urlstring | null (uri)да
thumb_urlstring | null (uri)да

GenerationError ​

ПолеТипОбяз.Описание
codeGenerationErrorCodeдаWhy a started generation failed (Generation.error.code).
messagestringда
retryablebooleanда
retry_after_secondsinteger

Generation ​

ПолеТипОбяз.Описание
idintegerда
typeGenerationTypeда
modelstring | nullда
statusstringдаWaiting and running statuses end in done or failed. Poll until one of those two.
promptstring | nullда
cost_creditsnumberда
cost_usdnumberPresent 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.
refundedbooleanдаTrue when the whole price was returned.
credits_refundednumberда
created_atstring | null (date-time)да
finished_atstring | null (date-time)да
outputsarray of OutputдаEmpty until status is done.
errorGenerationError | nullдаSet when status is failed. Failed generations are refunded.
queueobjectда
partial_refundobject | nullдаSet when fewer results than ordered were delivered and the difference was returned.
appliedAppliedдаParameters the service actually used.

GenerationStarted ​

ПолеТипОбяз.Описание
dataGenerationда
metaobjectда

Reference ​

ПолеТипОбяз.Описание
idintegerда
typestringдаone of: image, video, audio
widthinteger | nullда
heightinteger | nullда
duration_secondsnumber | nullда
urlstring | null (uri)да
face_statusstringда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