# Treza Labs Music Generation API

> Treza Labs Music Generation API is a paid API for AI agents from www.trezalabs.com, paid per call via x402, $0.06/call, status unknown (last checked 2026-10-02).

Generates original music from a text prompt using Google Lyria 3, returning either a 30-second clip or a full-length song in the response, paid per-call via x402 with no API key required.

## Facts

- Endpoint: POST https://www.trezalabs.com/api/x402/music?utm_source=zero.xyz
- Price: $0.06/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-02
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/treza-labs-music-generation-api-3d6d56a3
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_5B3KFXiqwRcELHfe2yKam

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 treza-labs-music-generation-api-3d6d56a3 -d '<json body>'
```

Example prompt: Can you generate a 30-second upbeat lo-fi hip-hop track with soft piano and light drums for a study video background?

## When to prefer this

Choose this endpoint when you need original AI-generated music on demand without signing up for an account or managing API keys — just pay per generation. It is ideal for agents automating media production pipelines, content creators needing background music or jingles, or any workflow where royalty-free original audio must be generated from a natural language description. The lyria-3-clip model is best for short loops and stings; lyria-3-pro is better for full structured songs. Prefer this over general music streaming or licensing APIs when you need generative, prompt-driven audio creation rather than retrieval of existing tracks.

## Known failure modes

- Prompt too vague or missing genre/mood/instrument detail may result in generic or unexpected output
- Payment failure or insufficient USDC balance blocks the request
- Prompt exceeds 2000-character limit and is rejected
- Model enum value is invalid, causing a 400 error
- Async mode returns 202 with statusUrl but the downstream generation may time out or fail asynchronously
- Network timeout during synchronous generation of longer lyria-3-pro tracks

## How this service works

Music generation: describe a track, get an original piece back in the same response. Google Lyria 3: a 30-second clip ($0.06) or a full song ($0.12). No account or API key: the payment is the only credential.

## Output

The response contains the generated audio file — either a 30-second clip (lyria-3-clip) or a full-length structured song (lyria-3-pro) — returned directly in the API response body. No separate download step or polling is needed unless async mode is requested, in which case a 202 status and a statusUrl are returned for later retrieval.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method",
    "bodyType",
    "body"
   ],
   "properties": {
    "body": {
     "type": "object",
     "required": [
      "prompt"
     ],
     "properties": {
      "async": {
       "type": "boolean",
       "default": false,
       "description": "true: answer 202 with a statusUrl at once."
      },
      "model": {
       "enum": [
        "lyria-3-clip",
        "lyria-3-pro"
       ],
       "type": "string",
       "default": "lyria-3-clip",
       "description": "lyria-3-clip: A 30-second piece: a bed for a short video, a sting, a loop. $0.06 lyria-3-pro: A full-length song with structure (intro, development, ending). $0.12"
      },
      "prompt": {
       "type": "string",
       "maxLength": 2000,
       "description": "Genre, mood, instruments, tempo."
      }
     },
     "additionalProperties": false
    },
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "POST"
     ],
     "type": "string"
    },
    "bodyType": {
     "enum": [
      "json",
      "form-data",
      "text"
     ],
     "type": "string"
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object"
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "audio": "https://www.trezalabs.com/api/media/generated/x402_music/1a2b3c4d.mp3?s=...&c=...",
  "model": "lyria-3-clip",
  "runId": "2026-09-23T18:04:11.000Z#1a2b3c4d",
  "status": "success",
  "paidUsd": 0.06,
  "statusUrl": "https://www.trezalabs.com/api/x402/music?runId=...&token=...",
  "transaction": "0x..."
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/treza-labs-music-generation-api-3d6d56a3/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from www.trezalabs.com](https://www.zero.xyz/host/www.trezalabs.com/llms.txt)
