# Stella Managed Media — Music Capabilities for text-to-music generation. Audience: AI agents. Plain text on purpose. Curl me. ## Capabilities ### `text_to_music` — generate a short music clip - Single profile (`default`); Google Lyria 3 Pro preview. - Convenience field: `prompt` becomes a single weighted prompt if `weightedPrompts` is not supplied. - Useful `input` fields: `promptLabel`, `weightedPrompts`, `musicGenerationConfig`. - `musicGenerationConfig` fields: `bpm` (55–145), `density` (0.05–0.9), `brightness` (0.1–0.8), `guidance` (2–5), `temperature` (0.6–1.4), optional `musicGenerationMode: "VOCALIZATION"`. ```bash curl -X POST "$STELLA_API/api/media/v1/generate" \ -H "Authorization: Bearer $STELLA_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "capability": "text_to_music", "prompt": "warm lo-fi keys, soft vinyl texture, gentle drums", "input": { "promptLabel": "Rainy tape", "musicGenerationConfig": { "bpm": 85, "density": 0.5, "brightness": 0.4, "guidance": 4, "temperature": 1.1 } } }' ``` For more control, pass explicit weighted prompts: ```json { "capability": "text_to_music", "input": { "promptLabel": "Neon focus", "weightedPrompts": [ { "text": "steady ambient electronica with soft arpeggios", "weight": 1 }, { "text": "harsh distorted guitars", "weight": -0.6 } ], "musicGenerationConfig": { "bpm": 104, "density": 0.45, "brightness": 0.5, "guidance": 4, "temperature": 1 } } } ``` ## Notes for agents - Music jobs return a normal media job and also materialize into `state/media/outputs/`. - The generated clip is about 30 seconds. Use `musicGenerationMode: "VOCALIZATION"` only when the user asks for sung elements; otherwise keep it instrumental. - Do not use real artist names, song titles, or copyrighted material in the prompt. ## Endpoint POST /api/media/v1/generate Content-Type: application/json Authorization: Bearer Where `` is the Stella backend base URL the desktop app is signed in against (e.g. `https://api.stella.sh`). Reuse the user's existing session token — do not invent your own credentials. ## Request body ```json { "capability": "", // required; see per-kind sections below "profile": "", // optional; defaults to the capability's preferred profile "prompt": "...", // optional convenience field; mapped to the capability's prompt key "aspectRatio": "16:9", // optional convenience field for image/video; mapped to aspect_ratio "sourceUrl": "https://...", // optional; for capabilities that take a public URL "source": "data:image/png;base64,...", // optional; for local files (preferred) "sources": { "video": "data:...", "audio": "data:..." }, // for multi-input capabilities "input": { /* provider-specific overrides, merged on top of the convenience fields */ } } ``` `source` accepts a `data:` URI string or `{ "base64": "...", "mimeType": "image/png" }`. The backend wraps the value into the right shape for the picked endpoint (e.g. `image_urls: ["data:..."]` for image edit). ## Response (202 Accepted) ```json { "jobId": "job_123", "capability": "text_to_image", "profile": "best", "status": "queued", "upstreamStatus": "IN_QUEUE", "subscription": { "query": "api.media_jobs.getByJobId", "args": { "jobId": "job_123" } } } ``` ## Watching for completion You almost never need to. The Stella desktop renderer subscribes to every succeeded media job for the signed-in user, downloads the output to `state/media/outputs/_.`, and pops it open in the Display sidebar automatically. Just submit the job and report back to the user; the asset will appear on their screen. If you do need the raw status, subscribe to Convex: `useQuery(api.media_jobs.getByJobId, { jobId })`. Status values: `queued`, `in_progress`, `processing`, `succeeded`, `failed`, `cancelled`. ## Auth failure (401) If the user is not signed in, the endpoint returns a structured 401: ```json { "error": "Sign in to Stella to use media generation.", "code": "auth_required", "action": "Ask the user to open the Stella desktop app and finish signing in (Settings → Account, or the welcome screen on first launch). Once they're signed in, retry the same request — no payload changes needed.", "docsUrl": "https://stella.sh/docs/media" } ``` When you see `code: "auth_required"`: 1. Stop the in-flight job — do not retry on a backoff. 2. Surface `action` to the user verbatim so they know what to do. 3. Once they confirm sign-in, re-run the original request with the same payload. The response also sets `WWW-Authenticate: Bearer realm="stella-media"` for non-agent HTTP clients. ## Errors All other errors return `{ "error": "human-readable message" }` with an appropriate status. Upstream provider errors (content policy, validation, rate limits) are parsed and forwarded as-is — show the message to the user.