What it is

Compass AI is your LLM’s gateway to DeFi. It translates natural language into structured, ready-to-use DeFi actions—whether that means executing a leveraged trade or checking a wallet’s P&L.

Built on top of Compass Labs’ API, it supports both execution and monitoring, and works with any LLM supported by Langchain.

Why teams are integrating it

  • One line of code to make your AI DeFi-native
  • Works with all LLMs supported by LangChain
  • Supports execution (swapping, lending, LPing, yield) + real-time monitoring (check balances, visualize portfolio, etc)
  • Fully non-custodial—your users sign every tx
  • Supports major protocols: Aave, Uniswap, Aerodrome, and more

Ways to Integrate

Compass AI is now natively integrated with LangChain. View the Compass Tool in LangChain Docs

1

Install the langchain package

pip install -qU langchain-compass

Environment Setup

To run these examples, ensure LangChain has access to an LLM service. For instance, if you’re using GPT-4o, create a .env file containing:

# .env file
OPENAI_API_KEY=<your_openai_api_key_here>Import and instantiate the toolkit
2

Import and instantiate the toolkit

from langchain_compass.toolkits import LangchainCompassToolkit

toolkit = LangchainCompassToolkit(compass_api_key=None)
3

Pass the tools to your agent with toolkit.get_tools()

View available tools:

tools = toolkit.get_tools()
for tool in tools:
    print(tool.name)
# Expected output:

aave_supply
aave_borrow
aave_repay
aave_withdraw
aave_asset_price_get
aave_liquidity_change_get
aave_user_position_summary_get
...

What does it mean to serve the AI as an API endpoint?

What:

  • You can access Compass AI programmatically via a dedicated interface, similar to calling OpenAI’s API.
  • Developers send REST requests (with natural language) to Compass AI’s API and receive structured, machine-friendly responses (e.g., unsigned transactions, regular AI message text).

Why:

  • It enables simple integration into your own services, letting you provide its functionality for your users.

How:

  • Use a cURL command (as you would for any REST API). For example:
curl "https://compass-ai-n8s3.onrender.com/chat" \
    -H "Content-Type: application/json" \
    -d '{
        "thread_id": "d3bb66e8-1bbe-4de9-a3db-73d7b3275935",
        "message": "please tell me my USDC balance on arbitrum: my wallet is: 0x7Fd9DBad4d8B8F97BEdAC3662A0129a5774AdA8E"
    }'