OpenAI `gpt-4o-mini` Model「default」
Let the AI generate your git commit message subject (short description)

Have A Try
You can have a try without setup your token to local in any of your projects
Quick experience interaction. API Key: https://platform.openai.com/account/api-keys
sh
CZ_OPENAI_API_KEY="sk-xxxxx" npx czg aiCZ_OPENAI_API_KEY="sk-xxxxx" npx czg aish
CZ_OPENAI_API_KEY="sk-xxxxx" bunx czg aiCZ_OPENAI_API_KEY="sk-xxxxx" bunx czg aiSetup OpenAI token
- https://platform.openai.com/account/api-keys
Login and create your API secret key, which usually starts withsk- - Run command
npx czg --api-key=<API secret key>and input your key to setup your token save to local
sh
npx czg --api-key=sk-xxxxxnpx czg --api-key=sk-xxxxxsh
bunx czg --api-key=sk-xxxxxbunx czg --api-key=sk-xxxxxsh
czg --api-key=sk-xxxxxczg --api-key=sk-xxxxxSetup GitHub Models
- Join the GitHub Models waitlist
- Get GitHub personal access tokens
- Choose the model you want to use from the Models Marketplace and get the model name (click the Get started button to view information)
- Run the command to configuresh
npx czg --api-key="ghp_xxxxxx" --api-endpoint="https://models.inference.ai.azure.com" --api-model="gpt-4o-mini"npx czg --api-key="ghp_xxxxxx" --api-endpoint="https://models.inference.ai.azure.com" --api-model="gpt-4o-mini"
Setup Ollama
- Install Ollama and start the service
- Choose and pull the modelsh
# Using gemma2 model as an example ollama pull gemma2 # Confirm if the model is successfully pulled ollama ls# Using gemma2 model as an example ollama pull gemma2 # Confirm if the model is successfully pulled ollama ls - Run the command to configuresh
npx czg --api-key=" " --api-endpoint="http://localhost:11434/v1" --api-model="gemma2"npx czg --api-key=" " --api-endpoint="http://localhost:11434/v1" --api-model="gemma2"
As global usage
sh
npm install -g czgnpm install -g czgsh
brew install czgbrew install czgsh
# setup your token `czg --api-key=sk-xxxxx`
# Run the following command in any of your projects after setup OpenAI token
czg ai
# Return multiple subjects, and choose the suitable answer
git czg ai -N=5# setup your token `czg --api-key=sk-xxxxx`
# Run the following command in any of your projects after setup OpenAI token
czg ai
# Return multiple subjects, and choose the suitable answer
git czg ai -N=5As a dev dependency usage
sh
npm install -D czgnpm install -D czgsh
yarn add -D czgyarn add -D czgsh
pnpm install -D czgpnpm install -D czg- Add script in
package.json - Try run
npm cz ai|yarn cz ai|pnpm cz aiafter setup token
json
{
"scripts": {
"cz": "czg"
}
}{
"scripts": {
"cz": "czg"
}
}npx usage
- Run the following command in any of your projects after setup OpenAI token
sh
npx czg ainpx czg aish
bunx czg aibunx czg aiReturn multiple subjects, and choose the suitable answer
sh
npx czg ai -N=5npx czg ai -N=5sh
bunx czg ai -N=5bunx czg ai -N=5Commitizen CLI + cz-git usage
If you are currently using Commitizen CLI with the cz-git adapter:
There are three ways to configure the OpenAI API Key:
- Run
czgto configure it:npx czg --api-key=sk-xxxxx - Pass it as an environment variable and start:
CZ_OPENAI_API_KEY="sk-xxxxx" czai=1 cz - Configure it in an environment variable in your rc file: Add
export CZ_OPENAI_API_KEY="sk-xxxxx"to.zshrcor.bashrc.
There are two ways to turn on AI mode:
- Pass
czai=1as an environment variable and start:czai=1 cz - Enable AI mode in the configuration file:
useAI: true
Configure
- If you configure
useAIto true, and you want to switch to normal mode not AI prompt mode in this session- czg CLI:
czg --no-ai - Commitizen CLI + cz-git:
no_czai=1 cz
- czg CLI:
- If you want to customize the prompt words sent to OpenAI (like support i18n), you can use aiQuestionCB option
- The AI configure options information see : Options - AI Related
- About project or global support configure file information see: Configure Template
How it works
- Run git diff to obtain difference code information, combine prompt task, send them to OpenAI API -
/chat/completions, Return the subjects information generated by AI. - 💡 Inspired by aicommits and modified part of the code
cz-git