Stability AI
Stable Audio 3 Medium
stable-audio-3-medium/audio-inpainting
Stable Audio 3 Medium is an audio generation model from Stability AI, offering three tasks on HiAPI: generating audio from scratch based on a text description, with a default of 30 seconds and a maximum of 380 seconds; redoing a specified time segment within existing audio; and extending new content at the beginning or end of audio. Output supports 7 formats including MP3, WAV, and FLAC, and supports fixed random seeds for reproducing results, making it suitable for scenarios such as short video soundtracks, game and ambient audio, podcast packaging, and sound effect drafts.
Try stable-audio-3-medium/audio-inpainting
Input
Showcases
View all showcasesOutput
Pricing
stable-audio-3-medium/audio-inpainting $0.0632 per audio
Positioning Overview
Stable Audio 3 Medium's local inpainting capability regenerates a specified time range within existing audio. Submit the source audio, start and end seconds, and a description; the model rewrites only the masked interval while keeping the rest unchanged, returning one complete new audio file. It is suited to fixing a misplayed phrase, replacing the timbre of a section, or adjusting details without re-recording.
Key Highlights
- Change only the specified interval — use mask_start_seconds and mask_end_seconds to define the start and end seconds; content outside the interval stays untouched and the output length remains the same.
- The prompt describes only the part to change — prompt just needs to explain what the masked interval should become; no need to restate the structure of the whole piece.
- Works with negative prompts — negative_prompt describes sounds to avoid, such as harsh cymbals or excessive reverb.
- Reproducible, easy-to-compare results — with seed and interval fixed, adjust only one parameter at a time to hear exactly what that change contributes.
Capability Description
- Defining the inpainting interval: mask_start_seconds and mask_end_seconds are in seconds; the end time must be later than the start time and must not exceed the source audio duration. For example, with 8 seconds of source audio, a start of 2 and an end of 4 rewrites seconds 2 through 4.
- Source audio and description: audio_url takes an audio address the service can read; prompt describes the new content, and is more reliable when written in the order "instrument and timbre, performance content, mood and dynamics, recording texture".
- Guidance strength and avoidance: guidance_scale defaults to 1; higher values follow the prompt more strictly and only take effect on base (non-distilled) checkpoints; negative_prompt defaults to an empty string.
- Sampling steps: num_inference_steps defaults to 8 and can be set from 1 to 100; distilled checkpoints already perform well at the default, and you can compare different step counts using the same audio and interval.
- Output and bitrate: output_format supports mp3, wav, flac, ogg, opus, m4a, and aac, defaulting to mp3; bitrate defaults to 192k and accepts 320k, with no effect on wav or flac.
Use Cases
- Replace the timbre of a section — directly state the target timbre and the object being replaced, e.g. "replace the drum kit in this section with hand percussion while keeping the original tempo and groove".
- Fix recording flaws — when a phrase is played wrong or noise creeps in, rewrite only that interval instead of re-recording the whole take.
- Add ambient sound locally — layer rain, crowd noise, or other ambience onto a specified segment while keeping the rest intact.
- A/B prompt comparison — with seed and interval fixed, test two descriptions separately and compare which better matches expectations.
Limitations and Selection Advice
audio_url, prompt, mask_start_seconds, and mask_end_seconds are all required; the end time must be later than the start time and must not exceed the source audio duration, with a maximum of 380 seconds. prompt is limited to 5000 characters. Where possible, align boundaries with the end of a phrase or a breath rather than cutting mid-note; if the seam still sounds abrupt, extend both ends of the interval slightly and try again. To extend the beginning or end of audio, use "audio continuation"; if you have no source audio, use "text-to-audio".
What's new
View changelog →- New model stable-audio-3-medium text-to-audio model now available
- New model stable-audio-3-medium/audio-inpainting is now available
- New model New model available: stable-audio-3-medium/audio-outpainting
Frequently asked questions
View all FAQs →-
How long an audio clip can be generated at once?
duration controls the length, ranging from 1 to 380 seconds (about 6 minutes 20 seconds), with a default of 30 seconds. For longer works, it is recommended to generate them segment by segment, then use audio continuation to connect the segments.
-
What is the maximum length of a prompt?
The prompt is required, and the platform's input limit per request is 5000 characters. Clearly specifying the instruments, rhythm, mood, and use case is more likely to produce the expected result than piling on adjectives; when the prompt is very short, you can enable enable_prompt_expansion to let the model expand it first.
-
How should prompts be organized when generating music?
Write in the order of "instruments and timbre, rhythm and groove, emotion and dynamics, scene and texture", and state whether vocals are wanted. Put unwanted elements in negative_prompt, for example noise, distortion, abrupt silence.
-
How can I repair only a segment of the audio?
Use mask_start_seconds and mask_end_seconds to specify the start and end times in seconds. The end time must be later than the start time and cannot exceed the duration of the source audio. For example, in an 8-second audio clip, setting the start point to 2 and the end point to 4 will repair seconds 2 through 4.
Create a generation task
https://api.hiapi.ai/v1/tasks Headers
AuthorizationstringRequiredAccount API key. Required on every request. Example: Bearer YOUR_HIAPI_API_KEY. Get your API key
Content-TypestringOptionalThe request body is always parsed as JSON; when sent, only application/json (optionally with charset) is accepted — any other value returns 415. Example: application/json.
Idempotency-KeystringOptionalIdempotency key, up to 255 bytes. Retries with the same key from the same account create the task only once; replays return the original taskId.
On network timeouts or client retries, the same key creates the task only once — no double charges (scope: the API key's account). Use a business-unique identifier as the key (e.g. "order-42"); replays return the original taskId, and keys expire 24 hours after the first request. See the Unified Async API overview for the full scenario matrix.
Body
modelstringRequiredCurrent fixed value: stable-audio-3-medium/audio-inpainting
routestringOptionalCurrent fixed value: default
inputobjectRequired
Business parameters for stable-audio-3-medium/audio-inpainting and route default — see the parameter table below.
seedintegerOptionalRandom seed used to reproduce the same generation result; if omitted, a random seed is used.
promptstringRequiredminLength 1maxLength 5000pattern \SText description used to guide the regenerated content of the masked region.
bitratestringOptionalDefault: "192k"Audio bitrate for compressed output formats (such as mp3, aac, opus), which must be a string like '192k' or '320k'; ignored for lossless formats (wav, flac). Default is 192k.
audio_urlstringRequiredminLength 1Source audio; only the masked region within it will be regenerated.
output_formatstringOptionalDefault: "mp3"Container format of the generated audio output. Default is mp3.
mp3wavflacoggopusm4aaacguidance_scalenumberOptionalDefault: 1min 0max 25Classifier-free guidance (CFG) scale factor; higher values follow the prompt more strictly. Only takes effect on base (non-distilled) checkpoints. Default is 1.
negative_promptstringOptionalDefault: ""Text describing features to avoid in the output. Default is an empty string.
mask_end_secondsnumberRequiredmin 0max 380End time of the inpainting interval, in seconds. Must be later than the start time and must not exceed the source audio duration. For example, with a start of 2 and an end of 4, seconds 2 through 4 are inpainted.
mask_start_secondsnumberRequiredmin 0max 380Start time (in seconds) of the region to be regenerated.
num_inference_stepsintegerOptionalDefault: 8min 1max 100Number of sampling steps; post-trained (distilled) checkpoints work well at the default value of 8, and increasing it further yields little benefit. Default is 8.
enable_prompt_expansionbooleanOptionalDefault: falseWhether to use an LLM to expand the prompt for more detailed, higher-quality results. Default is false.
callbackobjectOptional
Terminal-state notification config. When omitted, no callback is delivered — poll the task yourself. See the callback note below.
Provide callback.url when creating a task and HiAPI POSTs to your service once the task reaches a terminal state — no polling needed. The callback payload mirrors the task detail structure; signature verification, delivery retries and idempotency are documented on the Unified Async API overview page.
urlstringRequiredRequired when callback is present. A POST is sent to this URL once the task reaches a terminal state; must be a valid http(s) URL.
whenstringOptionalDefault: "final"Only final is supported today — notified on both success and fail.
finalstoragestringOptionalDefault: "temp"Artifact storage tier: temp (default, retained about 7 days) or persistent (long-term, billed by size). Insufficient balance or exceeding the storage cap silently downgrades to temp; the effective tier is shown in the task detail response.
temppersistentRequest examples
# Submit an async task; returns a taskId immediately (no waiting for generation)
curl -X POST "https://api.hiapi.ai/v1/tasks" \
-H "Authorization: Bearer $HIAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "stable-audio-3-medium/audio-inpainting",
"input": {
"prompt": "…",
"bitrate": "192k",
"audio_url": "…",
"output_format": "mp3",
"guidance_scale": 1,
"negative_prompt": "",
"mask_end_seconds": 0,
"mask_start_seconds": 0,
"num_inference_steps": 8,
"enable_prompt_expansion": false
}
}' const res = await fetch("https://api.hiapi.ai/v1/tasks", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.HIAPI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "stable-audio-3-medium/audio-inpainting",
input: {
"prompt": "…",
"bitrate": "192k",
"audio_url": "…",
"output_format": "mp3",
"guidance_scale": 1,
"negative_prompt": "",
"mask_end_seconds": 0,
"mask_start_seconds": 0,
"num_inference_steps": 8,
"enable_prompt_expansion": false
}
}),
});
const task = await res.json();
// { code: 200, message: "success", data: { taskId } } import os, requests
res = requests.post(
"https://api.hiapi.ai/v1/tasks",
headers={"Authorization": f"Bearer {os.environ['HIAPI_API_KEY']}"},
json={
"model": "stable-audio-3-medium/audio-inpainting",
"input": {
"prompt": "…",
"bitrate": "192k",
"audio_url": "…",
"output_format": "mp3",
"guidance_scale": 1,
"negative_prompt": "",
"mask_end_seconds": 0,
"mask_start_seconds": 0,
"num_inference_steps": 8,
"enable_prompt_expansion": False
}
},
)
print(res.json()) # { code, message, data: { taskId } } 200 OK
{
"code": 200,
"message": "success",
"data": {
"taskId": "tk-hiapi-01HZTQ8BX2N3GM3YFK4Z9D7VQR"
}
} 400 Bad Request
{
"code": 400,
"message": "invalid request",
"data": null,
"error_code": "INVALID_REQUEST"
} Get task detail
https://api.hiapi.ai/v1/tasks/:id Response fields
taskIdstringRequiredTask ID, always prefixed with tk-hiapi-.
modelstringRequiredResolved full model name. Tasks submitted with the route parameter return base@route (e.g. gpt-image-2/text-to-image@ext); otherwise identical to the name passed at creation.
routestringOptionalPresent only when the task was submitted with an explicit route parameter; echoes the submitted value.
statusstringRequiredTask status.
queued Queued, not started yet.
handling Being processed.
archiving Processing finished, artifacts being prepared.
success Terminal: completed, artifacts available (output returned).
fail Terminal: failed (error returned).
After submission, check status: success and fail are terminal, everything else is non-terminal. Poll every 1–3 seconds until terminal. On success, download artifacts from output[].url and transfer them before expireAt; pass storage: "persistent" at creation time when long-term retention is needed.
creatednumberRequiredTask creation time (Unix seconds).
completednumberRequiredUnix seconds when the task reached a terminal state; fixed to 0 while not terminal.
outputarrayOptional
Present only when status == success. Artifact list — always an array; a single task may return multiple types at once (e.g. video + first_frame).
Array [ object ]
Array items
urlstringRequiredArtifact URL, directly downloadable.
typestringRequiredCurrent possible values: video, image, audio, first_frame, last_frame, thumbnail; more may be added later.
expireAtnumberRequiredUnix seconds until which the artifact remains accessible; download or transfer before it expires.
errorobjectOptional
Present only when status == fail.
codestringRequiredBusiness error code.
messagestringRequiredError description.
Response examples
Success
{
"code": 200,
"message": "success",
"data": {
"taskId": "tk-hiapi-01HZTQ8BX2N3GM3YFK4Z9D7VQR",
"model": "happyhorse-1-0",
"status": "success",
"created": 1777282033,
"completed": 1777282099,
"output": [
{
"url": "https://cdn.hiapi.ai/tasks/.../video.mp4",
"type": "video",
"expireAt": 1777886899
}
]
}
} Processing (non-terminal)
{
"code": 200,
"message": "success",
"data": {
"taskId": "tk-hiapi-...",
"model": "happyhorse-1-0",
"status": "archiving",
"created": 1777282033,
"completed": 0
}
} Failed
{
"code": 200,
"message": "success",
"data": {
"taskId": "tk-hiapi-...",
"model": "happyhorse-1-0",
"status": "fail",
"created": 1777282033,
"completed": 1777282099,
"error": {
"code": "TASK_FAILED",
"message": "task failed"
}
}
} Articles
View all articles →-
Tutorial
Stable Audio 3 Medium Audio Inpainting in Practice: 5 High-Value Use Cases for Developers and Key Implementation Points
From material repair to batch production: integrating audio inpainting capability into real business workflows
-
Guide
Stable Audio 3 Medium Audio Inpainting Getting Started Guide: Capabilities, Pricing, and Best Practices
-
Comparison
How to Choose a Stable Audio 3 Medium Audio Inpainting Model: Side-by-Side Comparison and Integration Recommendations
Related Models
View all models →Same Type
-
MiniMax Music 1.5 MiniMax $0.070 /song -
ElevenLabs ElevenLabs $0.125 /1,000 characters -
Mureka 9.5 Mureka $0.322 per request -
MiniMax Music 2.6 MiniMax $0.210 /song -
Mirelo SFX 2.0 Mirelo AI $0.021 /second -
Lyria 3.5 Google $0.090 /song -
MiniMax Music 3 MiniMax $0.0026 /second -
ElevenLabs Sound Effects ElevenLabs $0.0029 /second -
Qwen Audio 3.0 TTS Alibaba $0.030 /1,000 characters -
Lyria 3 Pro Google $0.140 /song
