The XpanderClient is the main entry point for the xpander SDK. It provides methods for managing agents and utility functions for working with LLM responses.

Initialization

from xpander_sdk import XpanderClient

client = XpanderClient(
    api_key="your-xpander-api-key",
    base_url="https://inbound.xpander.ai",  # Optional, defaults to production
    organization_id="your-org-id",  # Optional, needed for multi-organization and local run
    should_reset_cache=False  # Optional
)

# For running Xpander locally:
# client = XpanderClient(
#     api_key="my-agent-controller-api-key", 
#     base_url="http://localhost:9991", 
#     organization_id="your-org-id"
# )

Parameters

ParameterTypeRequiredDescription
api_key / apiKeystringYesYour xpander API key
base_url / baseUrlstringNoAPI endpoint URL, defaults to production URL (https://inbound.xpander.ai). Set to http://localhost:9991 for local runs
organization_id / organizationIdstringNoOrganization ID, needed for multi-organization and local run
should_reset_cache / shouldResetCachebooleanNoWhether to reset the cache when creating the client

Properties

agents

The agents property provides access to agent management methods.

Agent Management Methods

agents.get()

Retrieves an agent by ID.

agent = client.agents.get(agent_id="agent-id-123")

Parameters

ParameterTypeRequiredDescription
agent_id / agentIdstringYesID of the agent to retrieve

Returns

Returns an Agent object.

agents.list()

Lists all available agents.

agents = client.agents.list()

Returns

Returns an array of Agent objects.

agents.create()

Creates a new agent.

agent = client.agents.create(
    name="New Agent",
    description="Description of the agent",
    agent_type="regular",
    instructions="Your instructions for the agent"
)

Parameters

ParameterTypeRequiredDescription
namestringYesName of the agent
descriptionstringNoDescription of the agent
agent_type / agentTypestringYesType of agent: “regular” or “agentic_interface”
instructionsstringNoInstructions for the agent

Returns

Returns the newly created Agent object.

Enums

LLMProvider

Enumeration of supported LLM providers:

enum LLMProvider {
  OPEN_AI = "openai",
  ANTHROPIC = "anthropic",
  GENERIC = "generic",
  BEDROCK_CLAUDE = "bedrock_claude",
  VERTEX_AI = "vertex_ai",
  CLAUDE_3_OPUS = "claude-3-opus-20240229",
  CLAUDE_3_SONNET = "claude-3-sonnet-20240229",
  CLAUDE_3_HAIKU = "claude-3-haiku-20240307",
  FRIENDLI_AI = "friendli_ai",
  GEMINI_OPEN_AI = "gemini_openai",
  NVIDIA_NIM = "nvidia_nim",
  OLLAMA = "ollama"
}

Complete Usage Example

from xpander_sdk import XpanderClient, LLMProvider
import os

# Initialize the client
client = XpanderClient(api_key=os.environ["XPANDER_API_KEY"])

# Create a new agent
agent = client.agents.create(
    name="Research Assistant",
    description="Agent that helps with research tasks",
    agent_type="regular",
    instructions="You are a helpful research assistant."
)

# Get an existing agent
agent = client.agents.get(agent_id=agent.id)

# List all agents
all_agents = client.agents.list()