Back to Homepage

ChatGPT Laravel API Package for Laravel

1 min read


ChatGPT Laravel API Package for Laravel

The ChatGPT Laravel API Package Generator package for Laravel generates smart API mocks in Laravel using ChatGPT prompts:

use YellowDigital\LaravelChatgptMockApi\Facades\ChatGPTMockApi;
Route::get("/mock-response", function() {  
  return ChatGPTMockApi::generate(prompt: "European countries and their national food",        
  keys: ["id","name","food","food_description",],count: 3,);

Which would generate the following JSON response:

"id": 1,        
"name": "Italy",        
"food": "Pizza",        
"food_description": "A delicious round dough topped with tomato sauce, cheese and a variety of toppings."    
 "id": 2,       
 "name": "France",        
 "food": "Croissants",        
 "food_description": "A flaky, buttery pastry that is commonly eaten for breakfast or as a snack."    
  "id": 3,        
  "name": "Spain",        
  "food": "Paella",        
  "food_description": "A rice dish that originated in Valencia and is typically made with saffron, chicken, and shellfish."    

To avoid hitting API limits (and perhaps improving performance on subsequent requests), by default, this package caches generated responses.

At the time of writing, this package also offers a few other features, like disabling the aforementioned cache and configuring the ChatGPT Model used with the prompt.

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Follow @LaravelSage on X → Follow @LaravelSage on Facebook →
Aniket Singh

Aniket Singh

View All Articles

Full-stack developer with a knack for Merging creativity with technical expertise for standout solutions.

Related Articles

data_forget Helper for Laravel

data_forget Helper for Laravel

Since Laravel version 10.15, there is a new utility function called data_forget that allows you to remove keys from an array or object using a "dot" notation.

Laravel Tenant Application with Tenancy

Laravel Tenant Application with Tenancy

You can make your Laravel app multi-tenant using the Tenancy for Laravel Tenant package. This tenancy package lets you make any Laravel application multi-tenant without rewriting it.

Top Laravel Packages for Building Powerful Applications

Top Laravel Packages for Building Powerful Applications

Are you ready to take your Laravel skills to the next level and build extraordinary applications? Look no further! In this blog post, we will unveil a treasure trove of top packages that will revolutionize your development process.

Subscribe for 20+ new Laravel tutorials every week

You can unsubscribe at any time. You'll also get -20% off my courses!

© 2024


Laravel Sage

   |    Privacy Policy