Skip to main content

Getting Started with Uberduck API

This guide will help you make your first API request to Uberduck's text-to-speech service.

Prerequisites

Before you begin, you'll need:

  1. An Uberduck account
  2. An API key from your Uberduck dashboard
  3. Basic knowledge of REST APIs and your preferred programming language

Step 1: Obtain an API Key

  1. Sign in to your account at uberduck.ai
  2. Navigate to your account settings
  3. Select the API section
  4. Generate a new API key
  5. Copy your API key for use in requests

Step 2: Make Your First API Request

Let's create a simple text-to-speech request using one of Uberduck's pre-built voices.

Using cURL

curl -X POST https://api.uberduck.ai/v1/text-to-speech \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "Hello world! This is my first Uberduck API request.",
"voice": "polly_joanna",
"model": "polly_neural"
}'

Using JavaScript/Node.js

async function generateSpeech() {
const response = await fetch('https://api.uberduck.ai/v1/text-to-speech', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
text: 'Hello world! This is my first Uberduck API request.',
voice: 'polly_joanna',
model: 'polly_neural'
})
});

const data = await response.json();
console.log(`Speech generated! Audio available at: ${data.audio_url}`);

// Play the audio (in browser environments)
const audio = new Audio(data.audio_url);
audio.play();
}

generateSpeech();

Using Python

import requests

url = "https://api.uberduck.ai/v1/text-to-speech"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
payload = {
"text": "Hello world! This is my first Uberduck API request.",
"voice": "polly_joanna",
"model": "polly_neural"
}

response = requests.post(url, json=payload, headers=headers)
data = response.json()

print(f"Speech generated! Audio available at: {data['audio_url']}")

Step 3: Explore Available Voices

Now that you've created your first text-to-speech request, you might want to explore the available voices.

curl -X GET "https://api.uberduck.ai/v1/voices?limit=10" \
-H "Authorization: Bearer YOUR_API_KEY"

This will return the first 10 available voices. You can use various filter parameters to narrow down your search:

# Get English female voices
curl -X GET "https://api.uberduck.ai/v1/voices?language=english&gender=female&limit=10" \
-H "Authorization: Bearer YOUR_API_KEY"

Step 4: Explore Available Models

You can also explore the available TTS models:

curl -X GET "https://api.uberduck.ai/v1/models" \
-H "Authorization: Bearer YOUR_API_KEY"

Step 5: Customizing Your Request

For more advanced text-to-speech generation, you can customize your request with additional parameters:

// JavaScript example with extended parameters
const response = await fetch('https://api.uberduck.ai/v1/text-to-speech', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
text: 'This is a customized text-to-speech request with adjusted speed and pitch.',
voice: 'polly_joanna',
model: 'polly_neural',
extended: {
speed: 1.2,
pitch: 0.5
},
output_format: 'mp3'
})
});

Next Steps

Now that you've made your first API request, you can:

  1. Explore more voice options
  2. Learn about advanced parameters
  3. Check out best practices
  4. Integrate the API into your application

Troubleshooting

If you encounter any issues:

  • Ensure your API key is valid and correctly formatted in the Authorization header
  • Check that your request payload is valid JSON
  • Verify that the voice and model you're using are compatible
  • If you receive a rate limit error, wait before making another request
  • For persistent issues, contact support@uberduck.ai