Features
OpenAI API
OpenAI API integration for Laravel
Larafast provides a simple way to integrate OpenAI API with Laravel.
Installation
- Create an account on OpenAI
- Create your API key from the dashboard from API Keys
- Add your API key to your
.env
file asOPENAI_KEY=your-api-key
That’s it, your project is ready to use OpenAI API.
Usage
To use OpenAI API completion, you can use the instance of OpenAIService
.
To create images using OpenAI API, you can use:
You can adjust the number of generating images and the size in the OpenAIService@image method.
To create an audio from text using OpenAI API, you can use:
The text-to-speech will return the audio content instead of the URL as for the image. You can save the audio content to a file or return it as a response.
For more information, you can check the OpenAI API documentation to add new features to your service or adjust existing ones.