-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
- Python version: 3.9.8
- Operating System: Debian
- aiohttp version: ^3.8.0
Description
Trying to connect to openai sse streams by posting JSON. Authorization Bearer is required. HTTP Error 400 keeps happening with the code below. If I move the headers into the options dict, I get a 401 but I don't think that's the right way. My API key works with the openai module. It should work here.
Ref: https://beta.openai.com/docs/developer-quickstart/making-requests
What I Did
openai_key = ""
async with sse_client.EventSource(
'https://api.openai.com/v1/engines/davinci/completions',
{
'method': 'post'
},
json={
'prompt': "Peper piper picked a peck of",
'engine': 'davinci',
'max_tokens': 50,
'stream': True
},
headers={
'Authorization': f'Bearer {openai_key}'
}
) as event_source:
try:
async for event in event_source:
print(event)
except ConnectionError:
passReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels