🤖 Ask questions to OpenAI API using the CLI.
Requires PHP 8.1+
In your terminal execute:
git clone https://github.com/tal7aouy/open-ai-cli
cd open-ai-cli
cp .env.example .env
composer install
Edit your .env
file:
OPEN_AI_API_KEY='Your-Open-AI-Secret-Api-Key-Goes-Here'
Create an account on OpenAI to get your API KEY.
Chat to OpenAI from CLI with this command:
php openai chat
Allow multiline with this command:
php openai chat --multiline
Get help and more info:
php openai --help
Check command version:
php openai --version
I'm using the alias:
chat
equivalent to:php openai chat
.
- openai-php/client: Supercharged community PHP API client that allows you to interact with the Open AI API.
- symfony/console: The console component eases the creation of beautiful and testable command line interfaces.
- vlucas/phpdotenv: Loads environment variables from
.env
togetenv()
,$_ENV
and$_SERVER
automagically.
When you create your account on OpenAI, you can get some free credits (like 18 USD on credits -at the time of writing this-). You can set your prefered payment method (Credit Card for instance).
https://openai.com/api/pricing/
https://platform.openai.com/tokenizer
https://platform.openai.com/account/usage
https://platform.openai.com/docs/quickstart/adjust-your-settings
https://platform.openai.com/docs/models/finding-the-right-model
📄 The MIT License (MIT). Please see License File for more information.
❤️ You can support this project inviting me a coffee ☕ 😋 or giving a star to this repo ⭐ 😊.
🥳 Now go and ask interesting questions to OpenAI API from the CLI 💻 🤖.