> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://devmurf.crisp.help/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Make sure you have a Murf account. Murf API is currently open only to select customers who have opted-in by contacting our customer support team. If haven't done it already, you can do it by

Articles on: [API](/en/category/api-szk3rj/)

  
  

## Making a request

  
  
To make a request, you have to know the path and the HTTP method of the request that you want to make, then prepend the base URL of the Murf REST API,

` https://api.murf.ai`

, to the path to generate the full URL.  
  
For example, the "List Voices" operation uses the

` GET`

method and the

` /speech/voices`

path, and the full URL will be

` https://api.murf.ai/v1/speech/voices`

.  
  
This is how it would look like if you were to use

` curl`

to send the request:  
  

``` curl --request GET \ --header "token: _your_token_here_" \ --url "https://api.murf.ai/v1/speech/voices"```

  
  
The above request won't work on its own. The API calls to Murf have to be authenticated and sometimes even need to have some request body in them. Read on to learn how to authenticate and customize your requests.  
  

## Authenticating

  
  
All requests to Murf need to be authenticated. If you would like to use Murf API, opt-in by [https://go.crisp.chat/chat/embed/?website_id=68e2a70b-8159-4961-ac0a-f91ea2c50ef3"]([emailto:support@murf.ai](<a href=) target="_blank" rel="noopener noreferrer" role="link" class="csh-markdown csh-markdown-link csh-markdown-link-text">contacting our support) and our team will guide you on how to generate your own

` api-key`

.  
  
You'll now need to pass this

` api-key`

as a header to the` /v1/auth/token` endpoint to generate an auth token.  
  

###### Request token endpoint

  

` /v1/auth/token`

  
  
The generated auth token has to be passed as a header for all other requests to Murf.  
  
Auth tokens have an expiration time of 30 minutes; before they expire, you can generate another auth token using the same endpoint.  
  

###### Sample Request

  

``` curl --request GET \ --header "api-key: _your_api_key_here_" \ --url "https://api.murf.ai/v1/auth/token"```

  
  

## Listing Voices

  
  
Murf lets you generate voiceovers in 32 voices. Before you can generate a voiceover with murf, you need to decide on which voice will be used to generate the voiceover.  
  

###### List voices endpoint

  

` /v1/speech/voices`

  
  
The above endpoint will give you a list of all the voices available to you for voice generation. The response will look something like this:  
  

###### ListVoices response

  
  

``` [ { "voiceId": "en-UK-hazel", "displayName": "Hazel (F)", "locale": "en-UK", "displayLanguage": "English", "accent": "UK", "description": "Young Adult", "gender": "Female", "planType": "BASIC" } ]```

  
  

###### Sample Request

  

``` curl --request GET \ --header "token: _your_token_here_" \ --url "https://api.murf.ai/v1/speech/voices"```

  
  
You can use the data from this endpoint as a reference on what voices to use, or you can[ take inspiration from Murf's landing page]([https://murf.ai/text-to-speech#high-quality-voices-section](https://murf.ai/text-to-speech#high-quality-voices-section)) and create a visual voice selector for your customers.  
  

## Generating Speech

  
  
Alright, now on to the fun stuff. By now you have the auth token and have decided on which voice to use to generate your voiceover. You can now use the` /v1/speech/generate` endpoint to convert your text into speech.  
  

###### Generate Speech Endpoint

  

` /v1/speech/generate`

  
  
The text you want to generate, the voice you want to use, the format of the output file, and other customizable properties have to be sent in the request body. [Check here](https://murf.ai/api/docs/api-reference/generate-speech) to see the full list of customizable properties.  
  

###### Request body

  

``` { "text": "Hello there!", "voiceId": "en-UK-hazel", "format": "WAV", "channelType": "MONO", "sampleRate": "_24K" }```

  
  
For the

` text`

key in the request body, there is a character limit of 1000 characters per request. Up to 5 requests can be made to Murf API in parallel.  
  

###### Sample Request

  

``` curl --request POST "https://api.murf.ai/v1/speech/generate" \ --header "token: _your_token_here_" \ --header "Content-Type: application/json" \ --data-raw '{ "text": "Testing voice api!", "voiceId": "en-US-nate", "format": "WAV", "channelType": "MONO", "sampleRate": "_24K" }'```

  
  
Now you'll get a response that looks something like this:  
  

###### Synthesize speech response

  

``` { "audioFile": "url_to_file", "audioLengthInSeconds": 0, "wordDurations": [ { "word": "string", "startMs": 0, "endMs": 0 } ] }```

  
  
The audio generated can be used through the URL provided at the

` audioFile`

property.  
  
Alternatively, you can use the [Synthesize Speech with API Key](https://murf.ai/api/docs/api-reference/generate-with-key) endpoint to create a voiceover directly with the

` api-key`

instead of generating and using the auth token.  
  

## Next Steps

  
  
In this article, we discussed how you can get your auth token and generate an AI voiceover. There's more in store. You can customize API parameters to change the pitch, speed, and even add custom pronunciations. To learn more about this, check the Synthesize Speech section of the API Reference.

Updated on: 16/05/2023