A guided first run across all three interfaces. Each example is self-contained and works fully offline. Prerequisites: see Installation.
We'll use a tiny sample log throughout:
Back-off restarting failed container app in pod web-7d9f
Last State: Terminated Reason: Error Exit Code: 1
Save it as app.log.
devops-ai analyze app.logYou'll get a ranked summary, candidate root causes with confidence, read-only diagnostic commands, suggested fixes, references, and prevention tips. To get machine-readable output:
devops-ai analyze app.log --json | jq .root_causesExplain an error by name without any input file:
devops-ai explain CrashLoopBackOffValidate a manifest (read-only):
devops-ai validate deploy.yamlSee the full CLI guide.
from devops_ai_toolkit import AnalysisEngine
engine = AnalysisEngine()
# From a file
result = engine.analyze_file("app.log")
print(result.summary)
print("Top confidence:", result.confidence_percent, "%")
for cause in result.root_causes:
print(f"- [{cause.confidence_percent}%] {cause.title}")
for cmd in result.diagnostic_commands:
print(f" $ {cmd.command}")
# From a raw string
text_result = engine.analyze_text("ImagePullBackOff")
print(text_result.summary)
# Explain a named error
explained = engine.explain_error("OOMKilled")
print(explained.title, "-", explained.summary)See the full SDK guide and the Output format reference.
Install the extra and start the server:
pip install 'devops-ai-toolkit[api]'
devops-ai serve --port 8000Then call it:
# Health and version
curl -s localhost:8000/health | jq
curl -s localhost:8000/version | jq
# Analyze a log
curl -s localhost:8000/analyze/log \
-H 'content-type: application/json' \
-d '{"content": "Back-off restarting failed container"}' | jq .summary
# Explain an error
curl -s localhost:8000/explain \
-H 'content-type: application/json' \
-d '{"error": "CrashLoopBackOff"}' | jq .titleInteractive docs (Swagger UI) live at http://localhost:8000/docs. See the REST API guide.
All of the above is deterministic and offline. To layer an LLM narrative on top:
export DEVOPS_AI_PROVIDER=anthropic
export ANTHROPIC_API_KEY=sk-ant-...
devops-ai analyze app.log --enrichOr in Python:
result = engine.analyze_file("app.log", enrich=True)
if result.enrichment:
print(result.enrichment.narrative)If no provider is configured, enrichment is skipped gracefully and you still get the full deterministic result (with a low-severity warning noting enrichment was unavailable). See AI providers.
- Use cases — wire it into real incident workflows
- Examples — more ready-to-run snippets
- For a hosted experience, try the AI incident assistant.