i try to use the following python script to connect blender to chatgpt between Api but the error that the console show me is:
The model `gpt-4` does not exist or you do not have access to it.
Here is the code:
import bpy
import openai
def send_prompt_to_chatgpt(prompt):
api_key = 'KEY' # Inserisci qui la tua chiave API
client = openai.OpenAI(api_key=api_key)
try:
completion = client.chat.completions.create(
model="gpt-4", # Specifica il modello che vuoi utilizzare
messages=[
{"role": "system", "content": "You are an AI trained by OpenAI."},
{"role": "user", "content": prompt}
]
)
# Estrai il contenuto del messaggio generato dal modello
generated_message = completion.choices[0].message.content
print("ChatGPT Response:", generated_message) # Stampa la risposta nel log di Blender
except Exception as e:
print("Error:", str(e)) # Stampa l'errore se qualcosa va storto
# Esempio di utilizzo
send_prompt_to_chatgpt("Inserisci qui la tua domanda.")
many thanks in advance