skip to Main Content

I am testing a script to convert audio to text. However, while calling the API I am getting an error.

Here is the path I am using

  'https://api.openai.com/v1/audio/transcriptions?engine=whisper-1';

And the error I am getting is

"error": {
        "message": "you must provide a model parameter",
        "type": "invalid_request_error",
        "param": null,
        "code": null
    }

I have tried model=whisper-1 and model=davinci-002, both of them are raising the same error. Is there anything that I am missing?

2

Answers


  1. Take a look at the official OpenAI documentation.

    Screenshot

    If you want to use the Whisper API, note the following:

    1. Correct API endpoint: https://api.openai.com/v1/audio/transcriptions
    2. There are two required parameters:
      • file
      • model

    Try this:

    fetch('https://api.openai.com/v1/audio/transcriptions', {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer sk-xxxxxxxxxxxxxxxxxxxx',
        'Content-Type': 'multipart/form-data',
      },
      body: {
        file: 'YOUR_AUDIO_FILE.mp3',
        model: 'whisper-1',
      }
    });
    
    Login or Signup to reply.
  2. You should use 'https://api.openai.com/v1/audio/transcriptions' as the url.
    And the model is assigned in the request body:

    fetch('https://api.openai.com/v1/audio/transcriptions', {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer <Your token>'
      },
      body: {
        model: 'whisper-1',
        file: <Your audio file>,
      }
    });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search