Message Boards Message Boards

0
|
146 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Status code 422 when using HTTPRequest on Elevenlabs.io site

Posted 17 days ago

I am trying to recreate this curl command using HTTP Request:

curl --request POST \
  --url 'https://api.elevenlabs.io/v1/text-to-speech/21m00Tcm4TlvDq8ikWAM?output_format=mp3_22050_32' \
  --header 'Content-Type: application/json' \
  --header 'xi-api-key: API code goes here' \
  --data '{
  "text": "this is the text",
  "model_id": "eleven_multilingual_v2",
  "voice_settings": {
    "stability": 0.5,
    "similarity_boost": 0.8,
    "style": 0,
    "use_speaker_boost": true
  }
}'

curl returns the file correctly. However, this code results in a 422 response from the server. I can't see what I am doing wrong. Can anyone offer suggestions?

xiAPIKey = "key goes in here";
data = {
   "text" -> "hello world, this is generated via the api",
   "model_id" -> "eleven_multilingual_v2",
   "voice_settings" -> {
     "stability" -> "0.5",
     "similarity_boost" -> "0.8",
     "style" -> "0.0",
     "user_speaker_boost" -> "true"
     }

   };


result = 
  HTTPRequest[
   "https://api.elevenlabs.io/v1/text-to-speech/21m00Tcm4TlvDq8ikWAM?output_format=mp3_22050_32",
   <|"Method" -> "POST",
    "Headers" -> {
      "Content-Type" -> "application/json",
      "xi-api-key" -> xiAPIKey
      },
    "Body" -> data
    |>];
POSTED BY: Andrew Burnett
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract