Skip to main content
What you’ll build:
  • Tool functions for portfolio lookup, token search, and transaction history
  • A working agent using the OpenAI SDK that answers wallet questions
  • Patterns for connecting Zerion data to any AI framework
Time: ~15 minutes

Prerequisites

  • A Zerion API key (get one here)
  • Node.js 18+
  • An OpenAI API key (for the agent example; you can adapt it to any LLM)

Steps

1

Define the Zerion tool functions

Create reusable functions that your agent can call. Each function maps to a Zerion API endpoint: wallet portfolio, wallet positions, fungible assets search, and wallet transactions.
2

Wire up the agent with tool definitions

Define the tools schema so the LLM knows what functions are available and what parameters they accept.
3

Run the agent loop

Process user messages, call tools when the LLM requests them, and return the results.
4

Full working example

Save as agent.mjs and run with node agent.mjs:

Adapting to other frameworks

The tool functions work with any AI framework. Here’s how to connect them: Anthropic Claude (tool_use)
LangChain
Vercel AI SDK

Next steps

  • Connect via MCP to give AI tools access to the full Zerion docs and API spec
  • Add PnL tracking tools for cost basis and gain/loss analysis
  • Use webhooks to push new transactions to your agent in real time
  • Explore x402 for per-request stablecoin payments (no API keys needed)