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
    Details
      Use `kubectl rollout history deployment/my-app` to list all
      revisions, then `undo --to-revision=<n>` to pick a specific one.

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.2.tar.gz (21.4 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.2-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: opsai-0.1.2.tar.gz
  • Upload date:
  • Size: 21.4 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.2.tar.gz
Algorithm Hash digest
SHA256 9a5547b815adde072ed1e27c64409c2234af06cf6db3b02fbb874654e121d815
MD5 19f43cae9cc61514cfaaa6d982940bdb
BLAKE2b-256 1139326a01a93211b14619ba87cbffb5021a7fe0c2b91475c7d9cb1a94b79b7c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: opsai-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 16.4 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3807195f02b64ca1b7bc2bac52e5914f5b80adb8ad0164dc2a21ad6a79cc4130
MD5 1a692c0bddb66d1db5ff41c8b90b8edf
BLAKE2b-256 1ed8355bb1061ef7103a41761b66b55c3e6f7e87447e7fe246f22a636e869f95

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