Typed commands. Predictable outputs. Minimal tools.
Python for logic.
Python for logic.
English for intelligence.
Declare typed functions, call any LLM, and get dependable results — without a framework.
Install:
pip install alloy-ai
MIT-friendly, docs-first, minimal runtime.
examples/basic_usage.py
from alloy import command, ask
@command(output=float)
def extract_price(text: str) -> str:
return f"Extract the price (number only) from: {text}"
print(extract_price("This item costs $49.99.")) # -> 49.99
print(ask("Say hi")) # -> Hi!
Key benefits
Typed by default
Return types enforced with provider schema or guardrails; clear, actionable errors.
One API, any model
OpenAI, Anthropic, Gemini, Ollama — switch with a model string or env var.
Small API surface
Just @command
, ask
, and @tool
. Plain Python; no framework bloat.