sleeper371's picture
Make negative_prompt/hf_token optional in API schema; document usage
74dbcf3 verified
|
Raw History Blame Contribute Delete
2.34 kB
---
title: Stable Audio 3 Medium API
emoji: 🎡
colorFrom: indigo
colorTo: purple
sdk: gradio
sdk_version: 6.14.0
app_file: app.py
pinned: false
license: other
short_description: Music generation API proxying stable-audio-3-medium.
models:
- stabilityai/stable-audio-3-medium
---
# Stable Audio 3 Medium β€” Music API
A thin, stable API wrapper around
[`stabilityai/stable-audio-3`](https://huggingface.co/spaces/stabilityai/stable-audio-3),
pinned to the **Medium β€” general audio** variant
([`stabilityai/stable-audio-3-medium`](https://huggingface.co/stabilityai/stable-audio-3-medium)).
This Space uses no GPU of its own β€” it forwards to the upstream ZeroGPU Space and
exposes a single keyword-addressable endpoint, `/generate`, so callers don't have
to track upstream's positional, UI-derived signature.
## Endpoint
`POST /generate` β†’ `(wav_filepath, status_string)`
| param | type | default | notes |
|---|---|---|---|
| `prompt` | str | β€” | required |
| `duration` | float | 60 | seconds, 1–380 |
| `steps` | float | 8 | diffusion steps |
| `cfg_scale` | float | 1.0 | |
| `sampler_type` | str | `pingpong` | `pingpong`, `euler`, `rk4`, `dpmpp` |
| `seed` | int | 0 | 0 = random |
| `negative_prompt` | str | `""` | routes via upstream `/infer_advanced` when set |
| `hf_token` | str | β€” | **required**; your own HF token (a read token suffices) |
## Usage
```python
from gradio_client import Client
client = Client("sleeper371/stable-audio-3-medium-api")
wav_path, status = client.predict(
prompt="Warm analog house groove, deep sub bass, shuffled hats 122 BPM",
duration=30,
hf_token="hf_...", # your token β€” your quota
api_name="/generate",
)
print(status, wav_path)
```
## Configuration
This Space stores **no credentials**. Each caller passes their own `hf_token`,
which is forwarded to upstream so ZeroGPU quota is charged to that caller β€” never
to the Space owner. Tokens are never logged or persisted.
| variable | purpose |
|---|---|
| `UPSTREAM_SPACE` | Override the upstream Space id. Defaults to `stabilityai/stable-audio-3`. |
| `JOB_TIMEOUT` | Wall-clock budget per upstream job, including queue wait. Defaults to `900` seconds. |
| `HTTPX_TIMEOUT` | HTTP timeout, which bounds the *download* of the result WAV (~67 MB at the 380s maximum). Defaults to `600` seconds. |