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:  (skip - not needed for local models)

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. 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.0.tar.gz (17.7 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.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: opsai-0.1.0.tar.gz
  • Upload date:
  • Size: 17.7 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.0.tar.gz
Algorithm Hash digest
SHA256 6cd34c784bd1cd6efdd1ce5eff00f54293dcdde053b639541c0275387cc91f41
MD5 479cadb030157dd8f608bf31349f76ac
BLAKE2b-256 43994e2b4aa0d92e29833bc19f210dd44d8a431f5fc129cba2594422c1c9ca4f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: opsai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 64abf37f089d890e9f4d314f6f127bbc21caf7b86bd8b812d6b942fbc7e98046
MD5 0f667cd44e241e77ca65c7d92c4c5e4a
BLAKE2b-256 47938ffb2d515e5a49006b4a2b5cb319138ac88a1898dbed927675a9f522086f

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