openai-python icon indicating copy to clipboard operation
openai-python copied to clipboard

Pass api params into prepare_request

Open tanpinxi opened this issue 1 year ago • 0 comments

Fix for issue https://github.com/openai/openai-python/issues/303

Originally, the Audio endpoint does not pass the api_key into the request

import openai
key = ...
with open("sample.wav", "rb") as audio_file:
    transcript = openai.Audio.transcribe("whisper-1", audio_file, api_key=key)

# openai.error.AuthenticationError: No API key provided. 

This fixes the error by passing the api_key param, as well as other api-related params, into the _prepare_request method.

import openai
key = ...
with open("sample.wav", "rb") as audio_file:
    transcript = openai.Audio.transcribe("whisper-1", audio_file, api_key=key)

# <OpenAIObject>

tanpinxi avatar Mar 19 '23 07:03 tanpinxi