alloy (top-level package)¶
Usage¶
from alloy import ask, command, tool, configure
configure(model="gpt-5-mini", temperature=0.2)
@command
def summarize(text: str) -> str:
return f"Summarize in one sentence: {text}"
print(ask("Say hi succinctly."))
print(summarize("Alloy lets you write typed AI functions in Python."))
See also
- Guide → Core Concepts: guide/core-concepts.md
- API → Ask: api/ask.md
- API → Command: api/command.md
- API → Tools: api/tool.md
alloy ¶
Alloy public API.
Python for logic. English for intelligence.
This is an initial scaffold of the v1.0 surface area.
CommandError ¶
Bases: AlloyError
Raised when a command fails to produce a valid result.
ToolError ¶
Bases: AlloyError
Raised when a tool contract fails or a tool invocation errors.
ConfigurationError ¶
Bases: AlloyError
Raised when required configuration or provider backends are missing.
ToolLoopLimitExceeded ¶
Bases: CommandError
Raised when the tool-call turn limit is exceeded without a final answer.
Carries additional context for better developer experience.
configure ¶
configure(**kwargs)
Set global defaults for Alloy execution.
Example
configure(model="gpt-5-mini", temperature=0.7)