Hi there, I've looked everywhere and haven't found anything that has really helped me.
I'm trying to connect to the completions part of the api, and I've been getting the same error: "openai.PermissionDeniedError: Error code: 403.
Below is my code script:
def chat():
from openai import OpenAI
import httpx
key = {my key}
proxies = {
"http://": "http://proxy1",
"https://": "http://proxy2"
}
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer {key}"
}
httpxClient = httpx.Client(proxies = proxies, headers = headers, timeout = None) # Add a Custom Http Client
client = OpenAI(
api_key = key,
http_client = httpxClient
)
chat = client.chat.completions.create( <-------- THE ERROR
messages=[
{"role": "user", "content": "Say this is a test"},
{"role": "system", "content": "Please write a haiku about a fridge"}
],
model="gpt-3.5-turbo"
)
print(chat.choices[0].message['content'])
I have made requests through httpx.post with "https://api.openai.com/v1/chat/completions" in a seperate module, and I get a 200 OK Response - does anybody have any ideas?