# Haven Music Generation API

> Haven Music Generation API is a paid API for AI agents from api.havenagent.ai, paid per call via x402, $0.1/call, status unknown (last checked 2026-09-13).

Generates AI music audio from a text prompt and optional lyrics, returning a job ID to poll for the resulting audio file

## Facts

- Endpoint: POST https://api.havenagent.ai/x402/api/v1/music
- Price: $0.1/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/haven-music-generation-api-892f829b
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_jcVNnKgrnUk4mWpc8nDdR

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability haven-music-generation-api-892f829b -d '<json body>'
```

Example prompt: Can you generate a 30-second upbeat jazz tune for my home — something warm and relaxed with a piano lead, no lyrics needed?

## When to prefer this

Choose this endpoint when you need to generate original AI music audio — especially short clips (up to 60 seconds) — with optional custom lyrics, in a privacy-focused smart home context. Suitable for home automation agents that want to play personalized music on a Haven speaker or app. Prefer this over text-to-speech endpoints when you want actual musical output, not spoken word.

## Known failure modes

- Invalid or missing prompt results in a 400 validation error
- Duration outside 1–60 second range is rejected
- Payment of 0.1 USDC not completed via x402 results in 402 Payment Required
- Job may timeout if polling exceeds 900 seconds
- Result URL may return 404 if job has expired or failed

## How this service works

Generate a music track. Poll statusUrl, download at resultUrl. SFW only.

## Output

Returns a JSON object with a jobId, initial status (queued), a resultUrl to fetch the final audio once complete, a statusUrl to poll for progress, and an estimated completion time in seconds (typically around 60 seconds, with a poll budget of up to 900 seconds).

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "lyrics": {
   "type": "string",
   "maxLength": 5000
  },
  "prompt": {
   "type": "string",
   "maxLength": 2000,
   "minLength": 1
  },
  "durationSeconds": {
   "type": "number",
   "default": 20,
   "maximum": 60,
   "minimum": 1
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "kind": "music",
  "jobId": "00000000-0000-0000-0000-000000000000",
  "status": "queued",
  "resultUrl": "https://api.havenagent.ai/x402/api/v1/music/jobs/00000000-0000-0000-0000-000000000000/result",
  "statusUrl": "https://api.havenagent.ai/x402/api/v1/music/jobs/00000000-0000-0000-0000-000000000000",
  "etaSeconds": 60,
  "pollBudgetSeconds": 900
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/haven-music-generation-api-892f829b/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.havenagent.ai](https://www.zero.xyz/host/api.havenagent.ai/llms.txt)
