Skip to content
Diese Seite ist noch nicht in Ihrer Sprache verfügbar und wird deshalb auf Englisch angezeigt.

Upload Audio

Upload an MP3, WAV, or M4A audio file to get a public URL for generation APIs. Default file limit: 15MB.

← Gesamte Dokumentation
POST/v1/uploads/audios?retention_days=3

Note

Upload reference media and receive a public URL immediately, without polling. Retention tiers are 3, 7, 15, and 30 days. The 3-day tier is free within your account allowance; overage and longer retention require paid uploads. Check your actual free allowance and available tiers in the console.

Note

The documentation Playground does not support file uploads. Use the cURL, Python, or JavaScript examples below. The JavaScript example requires an <input type="file"> with a file selected on the page.

Anfragebeispiele

curl --request POST \
  --url 'https://api.apisea.ai/v1/uploads/audios?retention_days=3' \
  --header 'Authorization: Bearer <token>' \
  --form 'file=@/path/to/reference.mp3'

Authentication

Authorizationstringrequired

Use a valid, enabled, unexpired APISea API Key as Bearer <token>, with an account that is not suspended. The account balance must be positive. Paid uploads also require enough account balance and remaining API Key spending allowance to cover the upload. The free file allowance and the Key's spending limit are separate limits. Get a Key from API Key management.

Request parameters

retention_daysinteger

Optional: 3, 7, 15, or 30 days. An explicit value overrides the account default; when omitted, the currently effective console default applies, which is not necessarily 3 days. Only URL query parameters are accepted; a form field with this name has no effect. See the console for available tiers.

filefilerequired

Send one file, including its filename, in the file field of a multipart/form-data request. Do not substitute JSON, a base64 string, or a file URL for the file part. Other form fields are ignored; if multiple file parts are sent, only the first is processed.

Supported formats: MP3 (.mp3), WAV (.wav), M4A (.m4a)

Default maximum file size: 15MB. File size limits can be configured. The active service configuration and size-limit error message take precedence.

With cURL --form, Python files, or JavaScript FormData, let the client generate the Content-Type header with its boundary. Do not set this header manually.

File validation

The file type is detected from its content, not its extension or the MIME type supplied by the client. The content must match the endpoint; renaming a file does not convert it. A type mismatch returns HTTP 400.

Audio container or frame structure is validated. Fake headers or damaged files are rejected. OGG, FLAC, and AAC (raw ADTS streams) are unsupported.

FormatDetected MIME type
MP3 (.mp3)audio/mpeg
WAV (.wav)audio/wav
M4A (.m4a)audio/mp4

Retention and paid upload settings

Retention tierCharging ruleFree allowance
3 daysFree within the allowance. Beyond it, enable paid uploads and confirm the tier price to pay by actual file size.Uses the shared account allowance.
7 / 15 / 30 daysEvery file is charged at the selected tier, regardless of remaining free allowance.Does not consume free slots.

Open the console overview to view your allowance and current prices, enable paid uploads, confirm prices, and choose a default retention tier. Prices are shown in the console; charges depend on actual file size (1 GB = 1024³ bytes). Failed uploads are refunded. A price increase requires confirmation before using that tier again; a decrease does not.

Disabling paid uploads stops new upload charges and resets default retention to 3 days. Re-enabling requires confirmation of current prices. If a configured long-retention tier becomes unavailable, the effective default falls back to 3 days; check the console.

Warning

If your default is 7, 15, or 30 days, uploads without retention_days are charged individually even when free slots remain. Set retention_days=3 to use the 3-day rules for a specific upload. All request examples above explicitly select 3 days.

This example selects 7 days and requires paid uploads to be enabled with that tier's price confirmed:

bash
curl --request POST \
  --url 'https://api.apisea.ai/v1/uploads/audios?retention_days=7' \
  --header 'Authorization: Bearer <token>' \
  --form 'file=@/path/to/reference.mp3'

Successful response

HTTP 200 returns file metadata. url is at the JSON root, without a data wrapper or a generation task ID.

The response example shows file metadata and omits optional quota and overage objects. Their return conditions are described below.

urlstring

Public file URL. Pass it to the appropriate reference-media parameter of the target generation API. Each model still has its own format, size, count, and duration limits; a successful upload does not guarantee model compatibility.

filenamestring

Original filename.

content_typestring

MIME type detected by the server from the file content, not the client's declared value.

file_typestring

File category. This endpoint returns audio.

bytesinteger

Actual file size in bytes.

created_atinteger

Upload time as a Unix timestamp in seconds.

retention_daysinteger

Retention tier actually used for this file, in days: 3, 7, 15, or 30.

expires_atinteger

File expiration time as a Unix timestamp in seconds. Use this value to determine URL validity.

overageobject

Returned only for charged uploads: 3-day overage or any 7 / 15 / 30-day upload. charged indicates whether a charge was made; bytes is the billed file size; cost_usd is the charge in USD; price_per_gb_usd is the tier price per GB; retention_days is the billed tier. Free uploads omit this object.

quotaobject

Optional shared free-allowance information for the account. Returned for the 3-day tier; longer tiers do not consume free slots and omit this object. See below for unlimited accounts or unavailable statistics.

FieldDescription
quota.limitFree file allowance for this account within the window. Use the returned value or console; this is not the total upload limit after enabling paid uploads.
quota.usedCounted 3-day uploads within the window, including this successful upload.
quota.remainingRemaining free file slots.
quota.window_hoursWindow length in hours; defaults to 72.
quota.reset_atTime when the oldest batch leaves the window, in Unix seconds. Some slots become available then; the entire allowance does not reset at once.

Shared quota and request rate limits

Images, videos, and audio share one account free allowance. Multiple API Keys do not add allowances. The window rolls on the hour and normally counts successful 3-day uploads over approximately the past 71–72 hours. Longer tiers do not consume free slots. Invalid files, oversized files, and storage failures do not consume slots. Use the console or returned quota.limit for your allowance.

Ordinary quota-limited 3-day responses include X-Upload-Quota-Limit, X-Upload-Quota-Remaining, and X-Upload-Quota-Reset, corresponding to limit, remaining, and reset_at; Reset is in Unix seconds. Unlimited accounts receive quota: {"unlimited": true} without these headers.

Successful responses may omit quota when statistics are temporarily unavailable; longer tiers also omit it. Do not interpret its absence as zero or unlimited, or re-upload solely because it is absent.

After the 3-day free allowance is exhausted, uploads can continue with charges if paid uploads are enabled and the tier price is confirmed. Otherwise, handle 429 as described below. A separate limit of 1000 requests per Key per 60 seconds uses rate_limit_error and is independent of the free file allowance.

Error handling

Errors use a root-level error object. Inspect the HTTP status, error.type / error.code, and root-level overage fields instead of relying only on localized error.message text. Error overage differs from the successful billing object: it may contain available, enabled, needs_reconfirm, retention_days, price_per_gb_usd, optional settings_url, and reason. Enable paid uploads or reconfirm prices in the console.

HTTPField / conditionCause and action
400invalid_request_errorMissing file, non-multipart request, empty file, wrong media type, unsupported format, or damaged content. Fix the file or endpoint before retrying.
400retention_daysInvalid retention value or unavailable tier. Check the query parameter and available console tiers.
401 / 403—Invalid or disabled Key, or suspended account. Check authentication and account status.
402insufficient_user_quotaNon-positive account balance or expired Key. Add balance or use a valid Key. Free uploads still require these access conditions.
402overage.reason = overage_not_enabledA long-retention tier was selected without enabling paid uploads. Enable them and confirm prices in the console.
402overage.reason = needs_reconfirmThe long-retention price is unconfirmed or has increased. Confirm the current price before retrying.
402overage.reason = insufficient_balanceInsufficient account balance for this upload. Top up before retrying.
402overage.reason = insufficient_key_quotaThe API Key spending cap leaves insufficient allowance. Increase the Key allowance before retrying.
413invalid_request_errorThe file exceeds the limit for its type. Compress or reduce it; use the current limit stated in the error message.
429rate_limit_errorToo many requests from the Key. Reduce request frequency and retry with backoff.
429overage.enabled = falseThe 3-day free allowance is exhausted and paid uploads are disabled. Enable them and confirm prices in the console, or wait for free slots according to Retry-After.
429overage.needs_reconfirm = trueThe 3-day price requires confirmation. Reconfirm it in the console before retrying.
429error.type = rate_limit_exceededFree allowance exhausted. If overage is absent, follow error.message; paid uploads may be unavailable. To wait for free slots, retry after the seconds in Retry-After.
500server_errorFailed to write the file to storage. Retry later.
503server_errorToo many concurrent video/audio uploads, or temporarily unavailable storage. Retry later.
503Retry-AfterBilling or account allowance lookup is temporarily unavailable. Retry after the seconds specified by the header; this failed attempt is not charged.

Using URLs and retaining files

The 72-hour free-allowance window is separate from file retention. Files expire according to the selected tier; use the returned expires_at for the actual expiration time. Expired URLs return 404. Keep original files and do not assume URLs are permanent.

For large upload volumes, consider your own object storage (OSS). If the model accepts public file URLs, use your own storage URLs directly to reduce repeated uploads and storage costs.

Other upload endpoints

Antworten

{
  "url": "https://cdn.example/uploads/reference.mp3",
  "filename": "reference.mp3",
  "content_type": "audio/mpeg",
  "file_type": "audio",
  "bytes": 235680,
  "created_at": 1793836800,
  "retention_days": 3,
  "expires_at": 1794182400
}

Einen Fehler in dieser Dokumentation gefunden? Schreiben Sie an support@apisea.ai.