Skip to main content
POST
/
v1
/
ai-voice-generator
Python
from magic_hour import Client
from os import getenv

client = Client(token=getenv("API_TOKEN"))
res = client.v1.ai_voice_generator.generate(
    style={"prompt": "Hello, how are you?", "voice_name": "Elon Musk"},
    name="Voice Generator audio",
    wait_for_completion=True,
    download_outputs=True,
    download_directory="outputs"
)
{
  "id": "cuid-example",
  "credits_charged": 1
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <api_key>, where <api_key> is your API key. To get your API key, go to Developer Hub and click "Create new API Key".

Body

application/json

Body

style
object
required

The content used to generate speech.

Example:
{
"prompt": "Hello, how are you?",
"voice_name": "Elon Musk"
}
name
string
default:Voice Generator - dateTime

Give your audio a custom name for easy identification.

Example:

"My Voice Generator audio"

Response

Success

Success

id
string
required

Unique ID of the audio. Use it with the Get audio Project API to fetch status and downloads.

Example:

"cuid-example"

credits_charged
integer
required

The amount of credits deducted from your account to generate the audio. We charge credits right when the request is made.

If an error occurred while generating the audio, credits will be refunded and this field will be updated to include the refund.

Example:

1