Skip to main content

xpander-sdk

Project description

Xpander SDK

Xpander Open Source SDK empowers developers to build intelligent and reliable AI Agents capable of managing complex, multi-step tasks across diverse systems and platforms. The SDK simplifies challenges like function calling, schema definition, graph enforcement, and prompt group management.

With support for leading LLM providers such as OpenAI, Amazon Bedrock, and NVIDIA NIM, the Xpander SDK seamlessly integrates into your existing systems.

ai-agents-with-xpander

📦 Installation

Choose your preferred package manager:

npm

npm install xpander-sdk

pip

pip install xpander-sdk

🚀 Getting Started

Prerequisites

  1. Visit app.xpander.ai
  2. Retrieve your Agent Key from the Agent Settings page
  3. Install the SDK and make sure you have Node.js installed (required as the SDK runs as a Node.js app under the hood)

Quick Start Examples

TypeScript
import { XpanderClient } from 'xpander-sdk';
import * as dotenv from 'dotenv';

dotenv.config();

const xpanderAPIKey = process.env.XPANDER_API_KEY || '';
const xpanderAgentID = process.env.XPANDER_AGENT_ID || '';

const xpanderClient = new XpanderClient({ apiKey: xpanderAPIKey });
const agent = await xpanderClient.agents.get(xpanderAgentID);

// Get available tools for the agent
const tools = await agent.getTools();

// This is a placeholder for AI to analyze the tools and decide which to invoke
// You would typically send these tools to your AI provider (e.g., OpenAI, Anthropic)
// The AI will return a structured response indicating which tools to call
const llmResponse = await yourAIProvider.chat.completions.create({
  messages: [userMessage],
  tools: tools // The tools are formatted for the AI to understand
  // ... other AI configuration
});

// Parse LLM response automatically into tool calls
const toolsToRun = XpanderClient.extractToolCalls(llmResponse);

// Execute multiple tool calls at once
const results = await agent.runTools(toolsToRun);
JavaScript
const { XpanderClient } = require('xpander-sdk');
require('dotenv').config();

const xpanderAPIKey = process.env.XPANDER_API_KEY || '';
const xpanderAgentID = process.env.XPANDER_AGENT_ID || '';

const xpanderClient = new XpanderClient({ apiKey: xpanderAPIKey });
const agent = await xpanderClient.agents.get(xpanderAgentID);

// Get available tools for the agent
const tools = await agent.getTools();

// This is a placeholder for AI to analyze the tools and decide which to invoke
// You would typically send these tools to your AI provider (e.g., OpenAI, Anthropic)
// The AI will return a structured response indicating which tools to call
const llmResponse = await yourAIProvider.chat.completions.create({
  messages: [userMessage],
  tools: tools // The tools are formatted for the AI to understand
  // ... other AI configuration
});

// Parse LLM response automatically into tool calls
const toolsToRun = XpanderClient.extractToolCalls(llmResponse);

// Execute multiple tool calls at once
const results = await agent.runTools(toolsToRun);
Python
from xpander_sdk import XpanderClient
from dotenv import load_dotenv
import os

load_dotenv()

xpanderAPIKey = os.environ.get("XPANDER_API_KEY", "")
xpanderAgentID = os.environ.get("XPANDER_AGENT_ID", "")

xpander_client = XpanderClient(api_key=xpanderAPIKey)
agent = xpander_client.agents.get(agent_id=xpanderAgentID)

# Get available tools for the agent
tools = agent.get_tools()

# This is a placeholder for AI to analyze the tools and decide which to invoke
# You would typically send these tools to your AI provider (e.g., OpenAI, Anthropic)
# The AI will return a structured response indicating which tools to call
llm_response = your_ai_provider.chat.completions.create(
    messages=[user_message],
    tools=tools  # The tools are formatted for the AI to understand
    # ... other AI configuration
)

# Parse LLM response automatically into tool calls
tools_to_run = XpanderClient.extract_tool_calls(llm_response=llm_response.model_dump())

# Execute multiple tool calls at once
results = agent.run_tools(tools_to_run)
C#
using Xpander.Sdk;
using DotEnv.Net;

new DotEnvLoader().Load();

var xpanderAPIKey = Environment.GetEnvironmentVariable("XPANDER_API_KEY") ?? "";
var xpanderAgentID = Environment.GetEnvironmentVariable("XPANDER_AGENT_ID") ?? "";

var xpanderClient = new XpanderClient(xpanderAPIKey);
var agent = await xpanderClient.Agents.GetAsync(xpanderAgentID);

// Get available tools for the agent
var tools = await agent.GetToolsAsync();

// This is a placeholder for AI to analyze the tools and decide which to invoke
// You would typically send these tools to your AI provider (e.g., OpenAI, Anthropic)
// The AI will return a structured response indicating which tools to call
var llmResponse = await yourAIProvider.chat.completions.create({
  messages: [userMessage],
  tools: tools // The tools are formatted for the AI to understand
  // ... other AI configuration
});

// Parse LLM response automatically into tool calls
var toolsToRun = XpanderClient.ExtractToolCalls(llmResponse);

// Execute multiple tool calls at once
var results = await agent.RunToolsAsync(toolsToRun);

📚 Documentation

For comprehensive documentation, tutorials, and API references, visit:

⚙️ Technical Note

The library is compiled using Projen and runs as a Node.js application under the hood. Ensure you have Node.js installed for optimal performance.

🤝 Contributing

We welcome contributions to improve the SDK. Please see our CONTRIBUTING.md for guidelines on how to submit improvements and bug fixes.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xpander_sdk-1.44.2.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xpander_sdk-1.44.2-py3-none-any.whl (1.7 MB view details)

Uploaded Python 3

File details

Details for the file xpander_sdk-1.44.2.tar.gz.

File metadata

  • Download URL: xpander_sdk-1.44.2.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for xpander_sdk-1.44.2.tar.gz
Algorithm Hash digest
SHA256 9d9d426e378bb094057a0d2ddbac92a627fe4e0ed40900449ff3d9b3d95eb232
MD5 b843f1c233ad7e1080f82ae45dd266bb
BLAKE2b-256 39cb5c7c56cd5d5fc7375a2fd6c7d3dbea88f9218b8a5a6a04f6e254deb618da

See more details on using hashes here.

File details

Details for the file xpander_sdk-1.44.2-py3-none-any.whl.

File metadata

  • Download URL: xpander_sdk-1.44.2-py3-none-any.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for xpander_sdk-1.44.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0b8bf1da35a9ed6b187ca7b39492e674a0bc7aea4233c45b1805c67f4a245c78
MD5 9ac5d6531b1a4aad44c9f4d0cc02f078
BLAKE2b-256 87d926d88f9e16164b8ffc523d022ed18a8fdd653ef2514921fda9f2585a7a56

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page