Skip to main content

thirdweb-ai

PyPI version Python Versions License: Apache 2.0

Overview

thirdweb-ai enables developers to build smarter onchain AI agents by giving them access to thirdweb's powerful web3 tools. This library seamlessly integrates with popular AI agent frameworks, allowing you to enhance your AI agents with blockchain capabilities.

With thirdweb-ai, your AI agents can:

  • Deploy and interact with smart contracts
  • Manage wallets and transactions
  • Retrieve on-chain data
  • Store and retrieve data on decentralized storage (IPFS)
  • Access thirdweb's suite of web3 services

Installation

Install the core package:

pip install thirdweb-ai[all]

Install with framework-specific adapters

thirdweb-ai supports integration with several popular AI agent frameworks. You can install the package with specific extras to enable these integrations:

# Install with all adapters
pip install "thirdweb-ai[all]"

# Install with specific adapters
pip install "thirdweb-ai[openai]"  # For OpenAI Assistants
pip install "thirdweb-ai[langchain]"  # For LangChain
pip install "thirdweb-ai[autogen]"  # For AutoGen
pip install "thirdweb-ai[llama-index]"  # For LlamaIndex
pip install "thirdweb-ai[goat]"  # For GOAT
pip install "thirdweb-ai[agentkit]"  # For Coinbase AgentKit
pip install "thirdweb-ai[mcp]"  # For MCP
pip install "thirdweb-ai[smolagents]"  # For SmoLAgents
pip install "thirdweb-ai[pydantic-ai]"  # For Pydantic AI

Usage

thirdweb-ai provides a set of tools that can be integrated with various AI agent frameworks. Here's a basic example:

from thirdweb_ai import Engine, EngineCloud, Insight, Nebula, Storage, Tool

# Initialize thirdweb services
insight = Insight(secret_key=...)
nebula = Nebula(secret_key=...)
engine = Engine(secret_key=...)
engine_cloud = EngineCloud(secret_key=..., vault_access_token=...)  # vault_access_token required for server wallet operations
storage = Storage(secret_key=...)

# Get available tools
tools = [
    # Add the tools you need
    # e.g., contract deployment, wallet management, transaction tools, etc.
    *insight.get_tools(),
    *nebula.get_tools(),
    *engine.get_tools(),
    *engine_cloud.get_tools(),  # Use EngineCloud for cloud-based engine operations
    *storage.get_tools(),
    # Or pick an individual tool from the services
]

Available Services

thirdweb-ai provides several core services:

  • Engine: Deploy contracts, manage wallets, execute transactions, and interact with smart contracts
  • EngineCloud: Cloud-based engine operations for creating server wallets (with KMS integration), executing contract calls, and querying transaction history
  • Insight: Query blockchain data, retrieve transactions, events, token balances, and contract metadata
  • Nebula: Advanced onchain analytics and data processing
  • Storage: Store and retrieve data using IPFS and other decentralized storage solutions

Framework Integration

thirdweb-ai can be easily integrated with various AI agent frameworks. Below are a few examples of how to integrate with some of the supported frameworks:

LangChain

from thirdweb_ai import Tool
from thirdweb_ai.adapters.langchain import get_langchain_tools

# Initialize your thirdweb tools
tools = [...]  # List of thirdweb tools

# Convert to LangChain tools
langchain_tools = get_langchain_tools(tools)

# Use in your LangChain agent
agent = create_tool_calling_agent(tools=langchain_tools, ...)

OpenAI Agents

from thirdweb_ai import Tool
from thirdweb_ai.adapters.openai import get_openai_tools

# Initialize your thirdweb tools
tools = [...]  # List of thirdweb tools

# Convert to OpenAI tools
openai_tools = get_openai_tools(tools)

# Use in your OpenAI Agents
agent = Agent("thirdweb assistant", tools=openai_tools, ...)

AutoGen

from thirdweb_ai import Tool
from thirdweb_ai.adapters.autogen import get_autogen_tools

# Initialize your thirdweb tools
tools = [...]  # List of thirdweb tools

# Convert to AutoGen tools
autogen_tools = get_autogen_tools(tools)

# Use in your AutoGen agent

More Examples

More examples are available in the examples directory that can be found here

Custom Integration

If you're using a framework that isn't directly supported, you can still use thirdweb-ai by creating a custom adapter. The core Tool class follows a standard interface that can be adapted to most frameworks:

from thirdweb_ai import Tool

def adapt_to_my_framework(tools: list[Tool]):
    # Convert thirdweb tools to your framework's format
    return [
        {
            "name": tool.name,
            "description": tool.description,
            "parameters": tool.args_schema(),
            "execute": lambda **kwargs: tool.run_json(kwargs)
        }
        for tool in tools
    ]

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Development and Testing

Setting up development environment

# Clone the repository
git clone https://github.com/thirdweb-dev/ai.git
cd ai/python/thirdweb-ai

# Install dependencies with UV
uv sync

Running tests

We use pytest for testing. You can run the tests with:

# Run all tests
uv run pytest

# Run tests with verbose output
uv run pytest -v

# Run specific test file
uv run pytest tests/common/test_utils.py

# Run tests with coverage report
uv run pytest --cov=thirdweb_ai

# Run tests and generate HTML coverage report
uv run pytest --cov=thirdweb_ai --cov-report=html

Linting and Type Checking

# Run the ruff linter
uv run ruff check .

# Run type checking with pyright
uv run pyright

Metadata

Release files for thirdweb-ai 0.1.24

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for thirdweb-ai 0.1.24
File Size Uploaded Provenance Actions
thirdweb_ai-0.1.24.tar.gz 26.9 kB Without provenance Details for thirdweb_ai-0.1.24.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for thirdweb-ai 0.1.24
File Interpreter ABI Platform Actions
thirdweb_ai-0.1.24-py3-none-any.whl Python 3 none any Details for thirdweb_ai-0.1.24-py3-none-any.whl

Total release size: 62.5 kB

Release files / thirdweb_ai-0.1.24.tar.gz

Download URL thirdweb_ai-0.1.24.tar.gz
Size 26.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a25c348a9a0c0a5e01ee9dd1fd9bc7b533ce8e3d25d301c5d688e4259492d055
BLAKE2b-256 checksum
How to use checksums
7a19906b4fde5c1a9c24596e87400c4ef0672be934badce95bb6aae82f15764c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / thirdweb_ai-0.1.24-py3-none-any.whl

Download URL thirdweb_ai-0.1.24-py3-none-any.whl
Size 35.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
717fa393c22cf042ce012f63abc2f9bb66f28d1f2b72fa7e88f304022f4408b6
BLAKE2b-256 checksum
How to use checksums
ff31b9d8112ba9e6bfe30c256eea5e46c335ae87a491de8b951820c5f7de9d85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Security for thirdweb-ai 0.1.24

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page