Skip to content

tal7aouy/open-ai-cli

Repository files navigation

ChatGPT Cli

🤖 Ask questions to OpenAI API using the CLI.

alt text


GETTING STARTED:

Requires PHP 8.1+

Clone repository with git and install dependencies:

In your terminal execute:

git clone https://github.com/tal7aouy/open-ai-cli
cd open-ai-cli
cp .env.example .env
composer install

Configure your OpenAI API KEY:

Edit your .env file:

OPEN_AI_API_KEY='Your-Open-AI-Secret-Api-Key-Goes-Here'

Get your API KEY from OpenAI:

Create an account on OpenAI to get your API KEY.

USAGE:

Chat to OpenAI from CLI with this command:

php openai chat

OPTIONS:

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.

DEPENDENCIES:

  • 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 to getenv(), $_ENV and $_SERVER automagically.

CONFIGURE YOUR OPEN AI ACCOUNT:

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).


HELPFUL EXTERNAL LINKS:

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

LICENSE:

📄 The MIT License (MIT). Please see License File for more information.

WOULD YOU LIKE TO SUPPORT THIS PROJECT?

❤️ You can support this project inviting me a coffee ☕ 😋 or giving a star to this repo ⭐ 😊.

ko-fi

THAT'S IT!

🥳 Now go and ask interesting questions to OpenAI API from the CLI 💻 🤖.