How to Get and Use Your Fish Audio API Key

Written by

in

Unlocking Natural Voices: How to Get and Use Your Fish Audio API Key

Artificial intelligence has transformed how we interact with sound, making computer-generated voices virtually indistinguishable from human speech. Fish Audio stands out in this space by offering advanced text-to-speech (TTS), speech-to-text transcription, and custom voice cloning capabilities.

Whether you are building an interactive AI agent, localizing content, or developing a custom application, you will need a Fish Audio API key to programmatically access these audio generation pipelines. This guide walks you through generating your key, securing it, and making your very first request.


Step 1: Generating Your Fish Audio API Key

Getting an API key takes only a minute. Follow these quick steps to set one up:

  1. Create an Account: Head over to the Fish Audio Signup Page, create your account, and complete any required email verification.
  2. Navigate to the API Keys Section: Once logged in, go directly to the Fish Audio API Keys Dashboard.
  3. Create a New Key: Click the Create New Key button. Give it a clear, descriptive name (such as development-app or production-server) and optionally configure an expiration date if you want the key to automatically rotate.
  4. Copy and Store Safely: Immediately copy your generated API key. For security reasons, platforms typically will not show the full key again once you leave the page.

Security Warning: Never hardcode your API key directly into source code repositories or share it publicly. If a key is compromised, revoke it immediately from your dashboard and generate a fresh one.


Step 2: Configuring Your Environment

To keep your credentials secure, the official Fish Audio SDKs and integration examples automatically look for your key as an environment variable named FISH_API_KEY.

Set it in your terminal session or development environment like this:

export FISH_API_KEY="your_api_key_here"

Using environment variables allows you to cleanly separate your development keys from your production keys without modifying your core codebase.


Step 3: Making Your First Request

With your API key configured, you are ready to generate audio. You can interact with Fish Audio via standard HTTP requests or by using their official Python library.

Option A: Using Python

If you are using Python, install the official package and generate your first audio file with just a few lines of code:

from fishaudio import FishAudio
from fishaudio.utils import save

# Automatically reads FISH_API_KEY from your environment variables
client = FishAudio() 

# Convert text to speech
audio = client.tts.convert(text="Hello from Fish Audio!")
save(audio, "hello.mp3")

Option B: Using cURL (HTTP API)

If you prefer a direct REST API call, you can execute a POST request to the TTS endpoint:

curl --request POST https://api.fish.audio/v1/tts 
  --header "Authorization: Bearer $FISH_API_KEY" 
  --header "Content-Type: application/json" 
  --header "model: s2-pro" 
  --data '{ "text": "Hello from Fish Audio!", "format": "mp3" }' 
  --output hello.mp3

Where to Go From Here

Once you have verified your API key and successfully generated your first audio file, you can explore more advanced features offered by the platform:

  • Voice Cloning: Train and build custom voices using your own audio samples.
  • Streaming & Prosody Control: Fine-tune speech speed, volume, and latency parameters for real-time applications.
  • Speech-to-Text: Transcribe audio efficiently with embedded timestamps.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *