The Helicone MCP tools will be automatically available in Claude Desktop.
import { query } from '@anthropic-ai/claude-agent-sdk';// Make a query with Helicone MCPconst result = await query({ prompt: 'Use the use_ai_gateway tool to ask GPT-4o: "What is Helicone?"', options: { mcpServers: { helicone: { command: 'npx', args: ['@helicone/mcp'], env: { HELICONE_API_KEY: process.env.HELICONE_API_KEY } } }, // Explicitly allow Helicone MCP tools (recommended for production) allowedTools: [ 'mcp__helicone__use_ai_gateway', 'mcp__helicone__query_requests', 'mcp__helicone__query_sessions' ] }});// Extract the responsefor await (const message of result.sdkMessages) { if (message.type === 'result' && message.result) { console.log('Response:', message.result); }}
4
Test the Integration
import { query } from '@anthropic-ai/claude-agent-sdk';const result = await query({ prompt: 'Use the use_ai_gateway tool to generate a creative story about AI using gpt-4o with temperature 0.8', options: { mcpServers: { helicone: { command: 'npx', args: ['@helicone/mcp'], env: { HELICONE_API_KEY: process.env.HELICONE_API_KEY } } }, allowedTools: ['mcp__helicone__use_ai_gateway'] }});// Get the responsefor await (const message of result.sdkMessages) { if (message.type === 'result' && message.result) { console.log(message.result); }}
The agent will automatically use the use_ai_gateway tool to make the request through Helicone AI Gateway.
import { query } from '@anthropic-ai/claude-agent-sdk';const sessionId = `comparison-${Date.now()}`;const result = await query({ prompt: `Compare responses from multiple models on: "Explain quantum computing in simple terms"1. Use GPT-4o-mini (fast, cost-effective)2. Use Claude Sonnet (high quality)3. Use GPT-4o (balanced)Use sessionId: "${sessionId}" for all requests so I can compare them later.`, options: { mcpServers: { helicone: { command: 'npx', args: ['@helicone/mcp'], env: { HELICONE_API_KEY: process.env.HELICONE_API_KEY } } }, allowedTools: ['mcp__helicone__use_ai_gateway'] }});// Get comparison resultsfor await (const message of result.sdkMessages) { if (message.type === 'result') { console.log('Comparison:', message.result); }}
import { query } from '@anthropic-ai/claude-agent-sdk';const result = await query({ prompt: `Perform a task and then analyze your own performance:1. Use the use_ai_gateway tool to generate a haiku about AI2. Then use query_requests to check how much the request cost3. Use query_sessions to see your recent activity4. Provide a summary of your performance and costs`, options: { mcpServers: { helicone: { command: 'npx', args: ['@helicone/mcp'], env: { HELICONE_API_KEY: process.env.HELICONE_API_KEY } } }, allowedTools: [ 'mcp__helicone__use_ai_gateway', 'mcp__helicone__query_requests', 'mcp__helicone__query_sessions' ] }});// Get self-analysisfor await (const message of result.sdkMessages) { if (message.type === 'result') { console.log('Self-Analysis:', message.result); }}