OpenAI
AgentiPy provides seamless integration with OpenAI's function calling capabilities, allowing you to create AI agents that can interact with the Solana blockchain. This integration enables developers to build sophisticated AI-driven blockchain applications with natural language interfaces.
🚀 Quick Start
import asyncio
from agentipy.agent import SolanaAgentKit
from agents import Agent, Runner, function_tool
from agentipy.tools.get_balance import BalanceFetcher
from rich.console import Console
from rich.panel import Panel
from rich.prompt import Prompt
from solders.pubkey import Pubkey
import os
# Initialize Rich console
console = Console()
# Initialize Solana agent
solana_agent = SolanaAgentKit(
private_key=os.getenv("PRIVATE_KEY"),
rpc_url="https://api.mainnet-beta.solana.com"
)
# Create function tools
@function_tool
async def check_sol_balance() -> str:
"""Get the SOL balance for the current wallet."""
balance = await BalanceFetcher.get_balance(solana_agent)
return f"SOL balance: {balance} SOL"
# Initialize OpenAI agent
agent = Agent(
name="Solana Assistant",
instructions="You are a Solana blockchain assistant that can check balances.",
tools=[check_sol_balance],
)
# Run the agent
result = await Runner.run(agent, input="Check my SOL balance")
🛠️ Key Components
1. Function Tools
Function tools are the building blocks of your AI agent's capabilities. They are decorated with @function_tool
and define the actions your agent can perform.
Last updated