Use @llm.register_function() to make any Python function callable by the LLM:
from vision_agents.plugins import openaillm = openai.LLM(model="gpt-5.4")@llm.register_function(description="Get current weather for a location")async def get_weather(location: str) -> dict: return {"location": location, "temperature": "22°C", "condition": "Sunny"}@llm.register_function(description="Calculate the sum of two numbers")async def calculate_sum(a: int, b: int) -> int: return a + b
Only async functions can be registered. Passing a synchronous function to @register_function() raises a ValueError.
The LLM automatically calls these functions when relevant:
response = await llm.simple_response("What's the weather in London?")# Calls get_weather("London") and incorporates result
@llm.register_function( name="check_permissions", description="Check if a user has specific permissions")async def verify_user_access(user_id: str, permission: str) -> bool: return True
All LLM plugins support multiple tool-calling rounds. If the model needs to call more tools after seeing results, you can configure the maximum number of rounds (default 3):
# OpenAI Responses APIllm = openai.LLM(model="gpt-5.4", max_tool_rounds=5)# ChatCompletions, Gemini, xAI, OpenRouter, and other pluginsllm = gemini.LLM(model="gemini-3-flash-preview", tools_max_rounds=5)