#Getting NotFoundError for the OpenAI Text-to-Speech API

2 messages · Page 1 of 1 (latest)

hollow musk
#

I am trying to implement the OpenAI API's text-to-speech feature in my project. Below is the code I used:


client = OpenAI(
  base_url="https://openrouter.ai/api/v1",
  api_key="my-api-key",
)

response = client.audio.speech.create(
  model="tts-1",
  voice="alloy",
  input="Today is a wonderful day"
)```

However, when I run this, I encounter a NotFoundError specifically at the point where client.audio.speech.create is called. The error message suggests that the endpoint or resource could not be found. 

NotFoundError Traceback (most recent call last)
<ipython-input-2-f30a0a54b81a> in <cell line: 1>()
----> 1 response = client.audio.speech.create(
2 model="tts-1",
3 voice="alloy",
4 input="Today is a wonderful day"
5 )

3 frames
/usr/local/lib/python3.10/dist-packages/openai/_base_client.py in _request(self, cast_to, options, remaining_retries, stream, stream_cls)
1010
1011 log.debug("Re-raising status error")
-> 1012 raise self._make_status_error_from_response(err.response) from None
1013
1014 return self._process_response(


Any help is much appreciated. Thank you
molten trail
#

hey @hollow musk.
As far as I know, OpenRouter does not currently host OpenAI's (or any) Text-to-speech models.

You wouldn't be able to do this unless OpenRouter adds this in the future.

You can just use OpenAI's API instead for now.

Good luck!