Class: Llm
Methods
generate()
Generate text from an LLM. Parameters:
Returns:
LlmResponse
Raises: LlmError on generation failure
Example:
generate_object()
Generate structured output conforming to a JSON Schema. Parameters:
Returns:
LlmResponse with .object populated
Raises: LlmError on generation failure
Example:
Model Resolution
Resolution order (first match wins):- Fully qualified per-call -
model="anthropic:claude-sonnet-4-6"used directly - Bare per-call + decorator default -
model="claude-sonnet-4-6"+@agent(llm={"provider": "anthropic"})resolved to full identifier - Decorator default only -
@agent(llm={"provider": "anthropic", "model": "claude-sonnet-4-6"})used when no model specified - Error - No model specified and no decorator default
LlmResponse
Error Handling
Provider Options
Pass provider-specific configuration:thinking- Enable extended reasoning with{"type": "enabled", "budgetTokens": <int>}
systemPrompt- Either{"type": "preset", "preset": "..."}or{"type": "custom", "content": "..."}effort-"low","medium","high"fallbackModel- Model to use if primary failsrepo- Repository to clone and work in
Message Format
system, user, assistant
Limitations
- No streaming responses - Full response returned at once; streaming is not yet supported
- 5MB implicit limit - Via platform constraints on response size
Why Host-Managed?
Agents run as native Python processes. You canpip install additional packages into the agent environment. Host-provided LLM calls are still preferred for credential management, rate limiting, provider routing, and audit logging.
See Also
How to Call LLMs
Task-oriented guide
AgentContext
Parent context object

