OpenAI integration¶
Here you can find how we use OpenAI model for the application.
Info
Available from 2.2.0+ release.
Functionality with the AI model¶
Open AI chat gpt model gpt-4o-mini
is the default model that we use it the API.
For the purpose of his task is working ok and is the lowest cost model from OpenAI.
- We use it to scrape a recipe from external url.
- We use it to generate an recipes from ingredients and after this we scrape the recipes from the available url online.
Edge cases¶
There a case where the model fails and we return empty response with status code 204
from the endpoint that are responsible for generating or scraping the recipes.
Endpoint which work with the OpenAI¶
Scrape recipes¶
POST /api/recipe/scrape
Payload¶
Headers¶
name | type | data type | description |
---|---|---|---|
Authorization |
required |
Access Token |
Token obtained from login endpoint |
Responses¶
http code | content-type | response |
---|---|---|
200 |
application/json |
{recipe.Recipe object} |
401 |
application/json |
{"detail":"Authentication credentials were not provided."} |
Example cURL¶
Generate recipes¶
POST /api/recipe/generate
Payload¶
Headers¶
name | type | data type | description |
---|---|---|---|
Authorization |
required |
Access Token |
Token obtained from login endpoint |
Responses¶
http code | content-type | response |
---|---|---|
200 |
application/json |
[GenerateRecipeResultSerializer objects] |
204 |
application/json |
{Empty response if there a openai empty response} |
401 |
application/json |
{"detail":"Authentication credentials were not provided."} |
Example cURL¶
Requirements¶
To use this functionality you must have a valid API_KEY from OpenAI