Skip to main content
What you’ll build
  • Tool functions for portfolio lookup, token search and transaction history
  • A working agent on the OpenAI SDK that answers wallet questions
  • Patterns for connecting Zerion data to any AI framework
Time
~15 minutes
You need
  • A Zerion API key
  • 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

Write one function per tool your agent can call. Each maps to one endpoint: wallet portfolio, wallet positions, fungible assets search and wallet transactions.
2

Wire up the agent with tool definitions

Describe each tool in a schema so the LLM knows which functions exist and what parameters they take.
3

Run the agent loop

Send the user message, run any tools the LLM asks for, feed the results back, and repeat until it answers.
4

Full working example

Save as agent.mjs and run it 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 through 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, with no API key needed.