OpenAI

Connect hi-shell to OpenAI to use GPT models for shell command generation. GPT models provide excellent command generation quality with broad knowledge of shell commands across platforms.

Prerequisites

Setup

1. Get an API Key

  1. Sign up at platform.openai.com
  2. Go to API Keys
  3. Create a new secret key
  4. Copy the key (starts with sk-)

2. Configure hi-shell

hi-shell --init
# Select "Cloud" → "OpenAI"
# Paste your API key
# Choose a model (e.g., "gpt-4o-mini")

Manual Configuration

Edit ~/.config/hi-shell/config.toml:

llm_provider = "Cloud"
cloud_provider = "OpenAI"
cloud_model = "gpt-4o-mini"
api_key = "sk-your-api-key-here"

Available Models

ModelBest ForRelative Cost
gpt-4o-miniFast, affordable, good qualityLow
gpt-4oBest quality responsesMedium
gpt-4.1-miniLatest fast modelLow
gpt-4.1Latest flagship modelMedium

We recommend gpt-4o-mini as the default — it’s fast, affordable, and generates excellent shell commands.

Configuration Options

OptionDescription
cloud_modelModel identifier
api_keyYour OpenAI API key

Pricing

OpenAI charges per token. For hi-shell usage:

  • Each command typically uses ~200-500 tokens
  • gpt-4o-mini: ~$0.0002 per command
  • gpt-4o: ~$0.001 per command

Very affordable for typical daily usage. Check openai.com/pricing for current rates.

Troubleshooting

“Invalid API key” Error

  • Verify your key at platform.openai.com/api-keys
  • Ensure you’re using an API key, not a ChatGPT Plus subscription
  • Check for extra whitespace

“Insufficient quota”

  • Add billing details in OpenAI platform settings
  • Check your usage limits

Organization Errors

If you’re part of multiple organizations, make sure you’re using the correct API key for the intended organization.