Unable to receive answers from my AI Chatbot in a gradio interface

I’m trying to build a chatbot with the GPT3,5 turbo Model and I want to test the chatbot in a gradio web interface before incorporating it on my website.
When I run the program it effectively gives me the URL to the web page used to run the chatbot. Pasting it on my browser, it opens the chatbot’s web page. I ask a question to the bot but the answer is not generated when I submit the message. Instead, gradio shows an error message back. So I created a chatbot with who I can’t comunicate.
I share the code. If you can, I ask you to test it and to give me suggestions to make it work.
Thank you in advance.
import gradio as gr
import requests
import json

def process_input(textin):
url = ‘https://api.openai.com/v1/chat/completions
apikey = ‘■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■8obmhjxf’
headers = {
‘Content-Type’: ‘application/json’,
‘Authorization’: 'Bearer ’ + apikey
data = {
‘model’: ‘gpt-3.5-turbo’,
‘messages’: [
{‘role’: ‘system’, ‘content’: ‘You are Amelia, the official chatbot of KNGTech.’},
{‘role’: ‘user’, ‘content’: ‘What is the formula of acetic acid?’},
{‘role’: ‘assistant’, ‘content’: ‘The formula of acetic acid is CH3COOH’},
{‘role’: ‘user’, ‘content’: textin}
‘temperature’: 0.3,
‘max_tokens’: 2000
response = requests.post(url, headers=headers, data=json.dumps(data))
if response.ok:
json_data = json.loads(response.text)
chatbot_response = json_data[‘choices’][0][‘text’]
return chatbot_response

iface = gr.Interface(fn=process_input, inputs=“text”, outputs=“text”)

I am having the same error after I type an input in and hit enter. Anyone solve this?

like this?