Api playground davinci 003 python

bonjour j’ai fait ce code en python pour utiliser l’api de playground de openai, mais j’ai une erreur pourriez vous m’aider svp.

hello i made this code in python to use the playground api from openai, but i have an error could you please help me.

please don’t use my api keys

code :
import requests

Définition de la clé API

api_key = “■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■EP9rXtiJ”

Définition de l’URL pour la requête API

url = “https://api.openai.com/v1/engines/playground/run

Paramètres de la requête API

payload = {
“engine”: “text-davinci-003”,
“prompt”: “What is the capital of France?”,
“max_tokens”: 100,
“temperature”: 0.5,

Ajout de la clé API aux en-têtes de la requête

headers = {
“Content-Type”: “application/json”,
“Authorization”: "Bearer " + api_key

Exécution de la requête API

response = requests.post(url, json=payload, headers=headers)

Affichage de la réponse


“error”: {
“message”: “That model does not exist”,
“type”: “invalid_request_error”,
“param”: null,
“code”: null

Have you checked out the Docs?


no but i the code was make by ChatGPT

1 Like

ChatGPT makes things up. It tends to use old information, and this is an old endpoint

Most of the code will still work - but you need to look at the completion endpoint in the documentation @PaulBellow pointed you to

1 Like