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

Metadata

Release files for opsai 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opsai 0.1.2
File Size Uploaded Provenance
opsai-0.1.2.tar.gz 21.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for opsai 0.1.2
File Interpreter ABI Platform
opsai-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 37.8 kB

Release files / opsai-0.1.2.tar.gz

Download URL opsai-0.1.2.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9a5547b815adde072ed1e27c64409c2234af06cf6db3b02fbb874654e121d815
BLAKE2b-256 checksum
How to use checksums
1139326a01a93211b14619ba87cbffb5021a7fe0c2b91475c7d9cb1a94b79b7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / opsai-0.1.2-py3-none-any.whl

Download URL opsai-0.1.2-py3-none-any.whl
Size 16.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3807195f02b64ca1b7bc2bac52e5914f5b80adb8ad0164dc2a21ad6a79cc4130
BLAKE2b-256 checksum
How to use checksums
1ed8355bb1061ef7103a41761b66b55c3e6f7e87447e7fe246f22a636e869f95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for opsai 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page