Status Code 400 python

Hi there,
i try to build a GUI for phyton.
The first goal is just a working GUI, where i can ask sth and get the answer. Maybe too basic, idk
Im reyll new to this.

My code so far


import tkinter as tk
import requests
import os
import openai

openai.api_key = "■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■deXXXX"

class GUI:
    def __init__(self, master):
        self.master = master
        master.title("OpenAI Chatbot")

        self.question_label = tk.Label(master, text="Frage:")
        self.question_label.pack()

        self.question_entry = tk.Entry(master)
        self.question_entry.pack()

        self.ask_button = tk.Button(master, text="Ask", command=self.ask)
        self.ask_button.pack()

        self.close_button = tk.Button(master, text="Close", command=self.close)
        self.close_button.pack()

        self.answer_label = tk.Label(master, text="Antwort:")
        self.answer_label.pack()

        self.answer_text = tk.Text(master, height=10, width=30)
        self.answer_text.pack()

    def ask(self):
        question = self.question_entry.get()

        response = requests.post("https://api.openai.com/v1/engines/davinci/jobs",
                                 headers={"Authorization": f"Bearer {openai.api_key}"},
                                 json={
                                        "model": "text-davinci-003",
                                        "prompt": question,
                                        "temperature": 0,
                                        "max_tokens": 1024,
                                        "top_p": 1,
                                        "frequency_penalty": 0,
                                        "presence_penalty": 0,
                                        "stop": ["\n"]
})

        if response.status_code == 200:
            response_json = response.json()
            if "choices" in response_json:
                answer = response_json["choices"][0]["text"]
                self.answer_text.delete(1.0, tk.END)
                self.answer_text.insert(tk.END, answer)
            else:
                self.answer_text.delete(1.0, tk.END)
                self.answer_text.insert(tk.END, "Keine gültige Antwort von der API erhalten")
        else:
            self.answer_text.delete(1.0, tk.END)
            self.answer_text.insert(tk.END, f"Fehler bei der API-Anfrage. Statuscode: {response.status_code}")

    def close(self):
        self.master.quit()

root = tk.Tk()
app = GUI(root)
root.mainloop()

The results are acceptable for me so far.
But it doesnt matter what i ask there is always this Answer

Oh mmh, idk if picture will be displayed, so it says basically Error API Statuscode: 400

I already tried the curl command to check my sk and that was ok
curl https://api.openai.com/v1/completions
-H ‘Content-Type: application/json’
-H ‘Authorization: Bearer YOUR_API_KEY’
-d ‘{
“model”: “text-davinci-003”,
“prompt”: “Say this is a test”,
“max_tokens”: 7,
“temperature”: 0
}’

Does anybody have an idea what i am doing wrong?

Thanks in advance
Sanny