Observed since 20 Oct, 18:29 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
AI Agent Kit for 1inch - Connect any LLM to 1inch DeFi protocols
Connect any LLM to 1inch DeFi protocols
The 1inch Agent Kit allows you to interact with 1inch's DeFi protocols using natural language, powered by OpenAI's GPT models. Get quotes, execute swaps, check gas prices, perform RPC calls, and monitor protocol health through simple chat interactions.
npm install 1inch-agent-kit
import { OneInchAgentKit } from '1inch-agent-kit';
// Create agent instance
const agent = new OneInchAgentKit({
openaiApiKey: process.env.OPENAI_API_KEY,
oneinchApiKey: process.env.ONEINCH_API_KEY,
});
// Get a quote
const response = await agent.chat('Get me a quote for swapping 1 ETH to USDC on Ethereum');
console.log(response.content);
Set your API keys as environment variables:
export OPENAI_API_KEY="your-openai-api-key"
export ONEINCH_API_KEY="your-1inch-api-key"
Or pass them directly to the agent:
const agent = new OneInchAgentKit({
openaiApiKey: 'your-openai-api-key',
oneinchApiKey: 'your-1inch-api-key',
openaiModel: 'gpt-4o-mini', // Optional: default model
});
const response = await agent.chat('Get me a quote for swapping 1 ETH to USDC on Ethereum with 1% slippage');
console.log(response.content);
const response = await agent.chat('Create a swap transaction for 0.1 ETH to USDC on Ethereum. My wallet is 0x1234...');
console.log(response.content);
const response = await agent.chat('Get me the current gas prices for Ethereum mainnet');
console.log(response.content);
const response = await agent.chat('Get the latest block number on Ethereum mainnet');
console.log(response.content);
const response = await agent.chat('Check the health status of the 1inch API');
console.log(response.content);
const response = await agent.chat(`
Get me a quote for swapping 1000 USDC to ETH on Polygon with 0.5% slippage.
Use complexity level 4 and split into 5 parts for better rates.
Also show me the current gas prices and latest block number for both chains.
`);
console.log(response.content);
You can also use the functions directly without the LLM agent:
import { getQuote, swap, healthCheck, gasAPI, rpcAPI } from '1inch-agent-kit';
// Get quote directly
const quote = await getQuote({
chainId: 1,
src: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeEe", // ETH
dst: "0xA0b86a33E6441b8C4C8C8C8C8C8C8C8C8C8C8C8C8", // USDC
amount: "1000000000000000000", // 1 ETH
slippage: 1.0
});
// Execute swap
const swapTx = await swap({
chainId: 1,
src: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeEe",
dst: "0xA0b86a33E6441b8C4C8C8C8C8C8C8C8C8C8C8C8C8",
amount: "1000000000000000000",
from: "0x1234567890123456789012345678901234567890",
slippage: 1.0
});
// Get gas prices
const gasPrices = await gasAPI({ chain: 1 });
// Perform RPC call
const blockNumber = await rpcAPI({
chainId: 1,
method: 'eth_blockNumber'
});
// Check health
const health = await healthCheck({ chainId: 1 });
The 1inch Agent Kit follows a modular architecture:
src/
├── core/ # Core agent functionality
│ ├── llmAgent.ts # OpenAI integration
│ ├── registry.ts # Function registry
│ └── types.ts # TypeScript types
├── functions/ # 1inch API functions
│ ├── getQuote/ # Quote functionality
│ ├── swap/ # Swap functionality
│ ├── gasAPI/ # Gas price functionality
│ ├── rpcAPI/ # RPC functionality
│ └── healthCheck/# Health check functionality
└── utils/ # Utilities
├── fetcher.ts # HTTP client
└── logger.ts # Logging
Run the examples to test the functionality:
# Run quote example
npm run example:quote
# Run swap example
npm run example:swap
# Run gas price example
npm run example:gas
# Run RPC example
npm run example:rpc
# Run health check example
npm run example:health
The main class for interacting with 1inch protocols.
new OneInchAgentKit(config?: AgentKitConfig)
chat(prompt: string): Promise<AgentResponse> - Send a natural language promptgetAvailableFunctions(): Promise<string[]> - Get list of available functionshasFunction(name: string): Promise<boolean> - Check if function is availablegetFunctionDefinitions(): Promise<FunctionDefinition[]> - Get function definitionsinterface AgentResponse {
content: string;
functionCalls?: Array<{
name: string;
arguments: Record<string, unknown>;
result?: unknown;
}>;
}
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by the 1inch Agent Kit team
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 1.0.67 | 3 Aug 2025 | 17 | |
| 1.0.66 | 3 Aug 2025 | 17 | |
| 1.0.65 | 3 Aug 2025 | 17 | |
| 1.0.64 | 3 Aug 2025 | 17 | |
| 1.0.63 | 3 Aug 2025 | 17 | |
| 1.0.62 | 3 Aug 2025 | 17 | |
| 1.0.61 | 3 Aug 2025 | 17 | |
| 1.0.60 | 3 Aug 2025 | 17 | |
| 1.0.59 | 3 Aug 2025 | 17 | |
| 1.0.58 | 3 Aug 2025 | 17 | |
| 1.0.57 | 3 Aug 2025 | 17 | |
| 1.0.56 | 3 Aug 2025 | 17 | |
| 1.0.55 | 3 Aug 2025 | 17 | |
| 1.0.54 | 3 Aug 2025 | 17 | |
| 1.0.53 | 3 Aug 2025 | 17 | |
| 1.0.52 | 3 Aug 2025 | 13 | |
| 1.0.51 | 3 Aug 2025 | 13 | |
| 1.0.50 | 3 Aug 2025 | 13 | |
| 1.0.49 | 3 Aug 2025 | 13 | |
| 1.0.48 | 3 Aug 2025 | 13 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 18:29 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:1669da08e9326add99bae7213203439495f49367682dc5f7be12f47a7f5a4919