← Back to Blog

How to Run an AI Music Generation Agent with OE Runtime

Generate original music tracks from text descriptions automatically. OE Runtime connects to Suno, crafts optimised music prompts, and returns the audio URL — from a background track to a full composition, all from a YAML file.

🎵
Step 1
Design Music Prompt
Craft a detailed Suno prompt specifying genre, mood, tempo, instruments, and duration.
Step 2
Generate Track
Submit the prompt to Suno and poll for completion before retrieving the audio URL.
Step 3
Report
Return the prompt used, track title, audio URL, duration, format, and generation time.

The Agent YAML

Create a file called agent.yaml inside a music-generation/ directory:

name: Music Creator
description: Generate original music tracks from text descriptions
instructions: |
  You are a music generation agent. Create original music using the Suno connector via kie.ai.
  Music generation is asynchronous — after submitting, poll for completion before returning the result.
  Complete all steps fully before writing your report.
steps:
  - name: Design Music Prompt
    content: |
      Craft a detailed music prompt for an upbeat corporate background track.
      Specify: genre (corporate pop), mood (energetic, optimistic), tempo (120 BPM),
      instruments (acoustic guitar, light drums, piano), no vocals.
  - name: Generate Track
    content: |
      Submit the music prompt to the Suno connector.
      POST /generate with body:
      {
        "prompt": "<detailed music prompt from previous step>",
        "model": "V4_5",
        "instrumental": true,
        "customMode": false
      }
      Save the taskId from the response: data.taskId.
      Then poll GET /generate/<taskId> every 10 seconds until data.status is "complete".
      Once complete, extract and save the audio URL from the response.
  - name: Report
    content: |
      Summarize the result:
      - Prompt used for generation
      - Track title returned by Suno
      - Audio URL
      - Generation time taken
connectors:
  - connection_name: Suno
    connection_type: suno

The Config File

Create oe-config.json in the same directory:

{
  "llm": {
    "provider": "openai",
    "model": "gpt-4o",
    "apiKey": "YOUR_OPENAI_API_KEY"
  },
  "server": {
    "enabled": false,
    "port": 3333,
    "apiKey": "your-secret-api-key"
  },
  "connectors": [
    {
      "connection_name": "Suno",
      "connection_type": "suno",
      "bearerToken": "YOUR_KIE_AI_API_KEY",
      "baseUrl": "https://api.kie.ai/api/v1"
    }
  ]
}

Get your API key from kie.ai (the Suno API provider). The agent uses model V4_5 and polls the generation task until the track is complete before returning the audio URL. Music generation is asynchronous — polling typically takes 30–90 seconds.

Download OE Runtime

OE Runtime — Direct Downloads

Run the Agent

Windows

oe-runtime-win.exe music-generation/agent.yaml --config music-generation/oe-config.json

macOS

chmod +x oe-runtime-macos
oe-runtime-macos music-generation/agent.yaml --config music-generation/oe-config.json

Linux

chmod +x oe-runtime-linux
oe-runtime-linux music-generation/agent.yaml --config music-generation/oe-config.json

macOS Gatekeeper: On first run, macOS may block the binary. Go to System Settings → Privacy & Security → click "Allow Anyway" next to oe-runtime-macos.

Running as an API Server

Add --serve to start OE Runtime as an HTTP server on port 3333:

oe-runtime-win.exe --serve --config music-generation/oe-config.json

Then send a request:

curl -X POST http://localhost:3333/run \
  -H "Content-Type: application/json" \
  -d '{"yaml": "music-generation/agent.yaml", "params": {}}'

Or import the Postman collection (download above) to test all endpoints visually.

Use Cases

Build your own agents with OE Runtime

Download OE Runtime and run any AI agent locally or as a server — no cloud required.

Get OE Runtime →
Series OE Runtime Agent Guides — 21 Connectors
Series overview →