
SDK Function Calling
API reference for the xpander AI SDK function calling capabilities
XpanderClient
The main client class for interacting with the xpander platform. This class provides access to all SDK functionality including agent management, tool execution, and utility methods.
Properties
agents
The agent management interface. Provides methods for creating, retrieving, and managing agents.
Methods
extract_tool_calls(llm_response: dict, llm_provider: LLMProvider = LLMProvider.OPENAI) -> List[ToolCall]
Extracts tool calls from LLM responses. Handles different LLM provider formats and converts them to standardized ToolCall objects.
retrieve_pending_local_tool_calls(tool_calls: List[ToolCall]) -> List[ToolCall]
Filters a list of tool calls to return only pending local tool calls that need to be executed.
Agent
Class representing an AI agent with function calling capabilities. Agents can access tools, execute them, and maintain conversation memory.
Properties
memory
The agent’s memory interface for managing conversation state and tool call results.
graph
The agent’s graph interface for managing execution flows.
Methods
get_tools(llm_provider: LLMProvider = LLMProvider.OPENAI) -> List[dict]
Returns the tools available to the agent in LLM-compatible format.
run_tools(tool_calls: List[ToolCall]) -> List[ToolCallResult]
Executes a list of tool calls and returns their results.
run_tool(tool_call: ToolCall) -> ToolCallResult
Executes a single tool call. Useful for sequential processing or individual error handling.
add_local_tools(tools: List[dict]) -> None
Adds local function tools to the agent.
Data Classes
ToolCall
Represents a function call request from an LLM.
ToolCallResult
Represents the result of a tool call execution.
GraphItem
Represents a node in the agent’s execution graph.
GraphEdge
Represents a connection between graph nodes.
Enums
LLMProvider
Supported LLM providers for function calling.
ToolCallType
Types of tool calls supported by the SDK.
Error Handling
The SDK uses standard Python exceptions for different error scenarios:
Rate Limiting
The SDK includes built-in rate limiting handling with exponential backoff: