Skip to main content

opsai

AI terminal command helper. Ask in plain English, get the exact command — no long explanations, no chatter.

$ opsai 'roll back the last deployment in kubernetes'
  > kubectl rollout undo deployment/my-app
    Reverts the deployment to its previous revision

Forgot that one kubectl, docker, git or systemd incantation? Working with Kubernetes, EKS, or plain shell and can't recall the flag? Just ask opsai in plain English and copy the answer straight into your terminal.

Best use case: fully local with Ollama

opsai shines as a 100% local, private, offline-friendly setup using Ollama with a tiny model. A small 0.5B model is perfect for this — command completion is a simple task, so the small model answers fast on CPU with no GPU, and your queries never leave your machine.

ollama pull qwen2.5:0.5b
opsai --base-url http://localhost:11434/v1 --model qwen2.5:0.5b 'get the pods in the kube-system namespace'

Want it as the default? Save it once:

opsai --config
# Base URL: http://localhost:11434/v1
# Model:    qwen2.5:0.5b
# API key:  (not asked - local servers need no key)

Bigger local models (7B+) give even better answers on capable hardware — the interface is identical.

Install

pip install opsai

Works with any OpenAI-compatible API

OpenAI, Groq, Ollama, LM Studio — anything speaking the /v1/chat/completions protocol:

Provider Base URL Example model
Ollama (local, recommended) http://localhost:11434/v1 qwen2.5:0.5b
OpenAI https://api.openai.com/v1 gpt-4o-mini
Groq https://api.groq.com/openai/v1 llama-3.3-70b-versatile
LM Studio (local) http://localhost:1234/v1 any loaded model

Usage

opsai 'reboot into bios'              # one-shot
opsai --chat                          # interactive session with memory
opsai --model gpt-4o-mini 'list pods' # per-invocation override
opsai 'kubectl restart deployment'    # k8s, git, docker, anything

More examples

You ask You get
opsai 'restart the nginx deployment in kubernetes' kubectl rollout restart deployment/nginx
opsai 'roll back the last deployment' kubectl rollout undo deployment/my-app
opsai 'see all pods in every namespace' kubectl get pods --all-namespaces
opsai 'ssh into a pod for debugging' kubectl exec -it pod/my-pod -- /bin/sh
opsai 'port forward a pod to my localhost 8080' kubectl port-forward pod/my-pod 8080:80
opsai 'restart the eks node group' aws eks update-nodegroup-config --cluster-name my-cluster --nodegroup-name my-ng --scaling-config minSize=1,maxSize=1,desiredSize=1
opsai 'recreate a docker container from scratch' docker-compose up -d --force-recreate
opsai 'undo the last git commit but keep the changes' git reset --soft HEAD~1
opsai 'find what changed in the last commit' git show --stat HEAD
opsai 'restart the ssh service' sudo systemctl restart ssh

Only your question is sent to the model — the table above is what the answer looks like. Always review the command before running it.

Per-invocation overrides: --base-url, --model, --api-key. Persistent (non-secret) settings live in ~/.config/opsai/config.json. Precedence: --flag > env var > config file > defaults.

API keys (when not using local models)

opsai --config stores your key in the OS keyring (GNOME Keyring / KWallet / Keychain / Credential Manager) — never written to disk. Local servers (Ollama/LM Studio) need no API key at all — opsai detects a localhost base URL and skips the key requirement. No keyring backend? Use the environment:

export OPSAI_API_KEY="your-key"      # or OPENAI_API_KEY
export OPSAI_BASE_URL="https://api.groq.com/openai/v1"   # optional
export OPSAI_MODEL="llama-3.3-70b-versatile"             # optional

Security

  • Never executes anything. opsai only displays commands; there is no code path that runs them.
  • Sends only your query plus a fixed system prompt — no shell history, no environment, no telemetry.
  • API key lives in the OS keyring or an env var. Never logged, redacted from all error output, never sent on HTTP redirects.
  • HTTPS only (except localhost for local model servers).
  • Danger flagging: rm -rf, sudo, mkfs, dd, curl | sh, etc. are printed with a warning banner.
  • Terminal escape sanitization: model output is scrubbed of ANSI/control characters before display.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opsai-0.1.1.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opsai-0.1.1-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file opsai-0.1.1.tar.gz.

File metadata

  • Download URL: opsai-0.1.1.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for opsai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 961265db444061ecf7103f683ffffac0922a4a78b5d24d9d90a028ad791be759
MD5 cb48fdf27ec6606d9f575adc6e99136e
BLAKE2b-256 474d22b32df2ad3003b70ebe8a0262b8b13c454fad3c69a92d6bdc543bf761cd

See more details on using hashes here.

File details

Details for the file opsai-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: opsai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for opsai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a84916ad46e7f26c53fee03b81a4acd506265b36fec84beb2fee843ecfcab0e4
MD5 b39985cd9730ba77215cf3f3f1874635
BLAKE2b-256 907decffc8bdcd8f5e5238e4dd96f80dfa4e8a648ec19e6eb9585cc4326d7953

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page