Skip to main content

Overview

NanoGPT supports AI music generation through the same OpenAI-compatible Text-to-Speech endpoint. When you specify a music model, the input field is treated as a music prompt (not text to speak) and the API returns an audio file.

Endpoint

Choosing A Music Model

Music model availability changes over time. Discover available audio models via GET https://nano-gpt.com/api/v1/audio-models (see Audio Models) and select a model intended for music generation.

Request Format

If you are using an OpenAI client that enforces the OpenAI TTS schema (for example the official OpenAI SDK), you may need to include a voice field. For music models, voice is ignored, so it can be any string (many examples use "alloy").

Parameters

Response

The response is an audio file (typically MP3). The Content-Type header indicates the format.
The response body is raw audio bytes.

Examples

Tips

  • Be descriptive: include genre, instruments, tempo (BPM), mood, and style.
  • Duration: generation duration varies by model. Most models produce ~10-30 seconds by default; duration may be influenced by the prompt.
  • Cost/quality vary by model. If cost predictability matters, prefer models with flat per-generation pricing (when available).