#how to use text-davinci-300 with aiohttp

5 messages · Page 1 of 1 (latest)

royal flame
#

I'm trying integrate the api into my discord bot although nothing ive tried works. Any pointers or tips for this?

viral sage
#

I gotchu!

#

One moment

#
payload = {
                "model": model
                "prompt": prompt,
                "temperature": temperature,
                "top_p": top_p,
                "max_tokens": max_tokens,
                "presence_penalty": 0,
                "frequency_penalty": 0,
                "best_of": 1,
            }
            headers = {
                "Authorization": f"Bearer {self.openai_key}"
            }
            async with session.post(
                "https://api.openai.com/v1/completions", json=payload, headers=headers
            ) as resp:
                response = await resp.json()
                await self.valid_text_request(response)
                print(f"Response -> {response}")

                return response
#

Here's how you can use aiohttp to make a request to davinci-003