repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources15d ago| #1 | # Using DeFi Agents with OpenRouter |
| #2 | |
| #3 | DeFi Agents is a framework for building AI-powered DeFi agents. Use it with OpenRouter to access any AI model for your autonomous trading and DeFi strategies. |
| #4 | |
| #5 | ## What is OpenRouter? |
| #6 | |
| #7 | [OpenRouter](https://openrouter.ai) provides unified access to 200+ AI models through a single API. |
| #8 | |
| #9 | ## Setup |
| #10 | |
| #11 | ### 1. Get Your OpenRouter API Key |
| #12 | |
| #13 | 1. Sign up at [openrouter.ai](https://openrouter.ai) |
| #14 | 2. Generate an API key at [openrouter.ai/settings/keys](https://openrouter.ai/settings/keys) |
| #15 | |
| #16 | ### 2. Configure Your Agent |
| #17 | |
| #18 | ```typescript |
| #19 | import { DeFiAgent } from '@nirholas/defi-agents'; |
| #20 | import OpenAI from 'openai'; |
| #21 | |
| #22 | const openrouter = new OpenAI({ |
| #23 | apiKey: process.env.OPENROUTER_API_KEY, |
| #24 | baseURL: 'https://openrouter.ai/api/v1', |
| #25 | }); |
| #26 | |
| #27 | const agent = new DeFiAgent({ |
| #28 | llm: openrouter, |
| #29 | model: 'anthropic/claude-sonnet-4', |
| #30 | // ... other config |
| #31 | }); |
| #32 | ``` |
| #33 | |
| #34 | ### 3. Run Your Agent |
| #35 | |
| #36 | ```typescript |
| #37 | await agent.analyze('Should I provide liquidity to ETH/USDC on Uniswap?'); |
| #38 | ``` |
| #39 | |
| #40 | ## Use Cases |
| #41 | |
| #42 | | Agent Type | Description | |
| #43 | |------------|-------------| |
| #44 | | **Trading Agent** | AI-driven trading decisions | |
| #45 | | **Yield Optimizer** | Find and optimize yield farming | |
| #46 | | **Risk Analyzer** | Assess DeFi protocol risks | |
| #47 | | **Portfolio Manager** | Manage multi-chain portfolios | |
| #48 | |
| #49 | ## Why OpenRouter for DeFi Agents? |
| #50 | |
| #51 | - **Model Flexibility** - Switch between models based on task complexity |
| #52 | - **Cost Control** - Use cheaper models for routine tasks |
| #53 | - **Redundancy** - Automatic failover between providers |
| #54 | - **No Vendor Lock-in** - Works with 200+ models |
| #55 | |
| #56 | ## Recommended Models |
| #57 | |
| #58 | | Task | Recommended Model | |
| #59 | |------|-------------------| |
| #60 | | Complex analysis | `anthropic/claude-sonnet-4` | |
| #61 | | Quick decisions | `meta-llama/llama-3-70b-instruct` | |
| #62 | | Cost-sensitive | `mistralai/mixtral-8x7b-instruct` | |
| #63 | |
| #64 | ## Resources |
| #65 | |
| #66 | - [GitHub](https://github.com/nirholas/defi-agents) |
| #67 | - [OpenRouter Docs](https://openrouter.ai/docs) |
| #68 | |
| #69 | |
| #70 |