openai-python
openai-python copied to clipboard
Pass api params into prepare_request
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>