Decorators API Reference
@llm_function
LLMFunction callable instance. await fn(...) returns the parsed typed result; fn.stream(...) yields ReactOutput.
For multimodal input, keep the normal Python-function style: explicitly type image parameters as ImgUrl, ImgPath, or lists/unions containing those types. ImgUrl accepts http(s) URLs and data: URLs; ImgPath is encoded as an image data URL at the provider boundary.
Parameters
Special Call-Time Parameters
Example
@llm_chat
LLMChat callable instance. Calling it yields AsyncGenerator[ReactOutput, None] and gives SelfRef a stable agent identity.
For multimodal chat input, prefer a single explicit message: UserChatMessage argument. UserChatMessage is OpenAI Chat Completions-compatible and can contain text and image_url content parts.
Parameters
Special Call-Time Parameters
History Parameter
The function must have a parameter namedhistory or chat_history (type: list | None). The framework uses it to carry conversation state.
Example
Multimodal Chat Example
@tool
Parameters
Requirements
- Decorated function must be
async def - Docstring should include
Args,Returns, andBest Practicessections - Parameter types become the tool’s JSON schema