Build advanced AI agents with AI SDK. Connect 600+ integrations, automate workflows, and deploy with ease using Metorial.
Learn how to handle errors and debug issues when using Metorial with the AI SDK.
Error: "Authentication failed" or "Invalid API key"
Solution: Check that your Metorial API key is correct and properly set:
// Make sure the key is loaded
console.log('API Key:', process.env.METORIAL_API_KEY ? 'Set' : 'Missing');
let metorial = new Metorial({
apiKey: process.env.METORIAL_API_KEY
});
Error: "Server deployment not found" or "Invalid deployment ID"
Solution: Verify your deployment ID in the Metorial dashboard and ensure it's correctly passed:
metorial.withProviderSession(
metorialAiSdk,
{
serverDeployments: ['correct-deployment-id']
},
async session => {
// ...
}
);
Error: Task doesn't complete or stops unexpectedly
Solution: Increase maxSteps
for complex tasks:
let result = await generateText({
model: openai('gpt-4o'),
prompt: 'Complex multi-step task',
maxSteps: 20, // Increased from default
tools: session.tools
});
Always wrap your code in try-catch blocks:
metorial.withProviderSession(
metorialAiSdk,
{ serverDeployments: ['your-deployment'] },
async session => {
try {
let result = await generateText({
model: openai('gpt-4o'),
prompt: 'Your prompt',
maxSteps: 10,
tools: session.tools
});
console.log('Success:', result.text);
} catch (error) {
console.error('Error during generation:', error);
// Handle specific error types
if (error.message.includes('API key')) {
console.error('Check your API keys');
} else if (error.message.includes('rate limit')) {
console.error('Rate limit exceeded, try again later');
}
}
}
);
Check what tools are being called:
let result = await generateText({
model: openai('gpt-4o'),
prompt: 'Your prompt',
maxSteps: 10,
tools: session.tools
});
// Inspect the steps taken
if (result.steps) {
console.log('Steps taken:', result.steps.length);
result.steps.forEach((step, i) => {
console.log(`Step ${i + 1}:`, step);
});
}
Verify that tools are loaded correctly:
metorial.withProviderSession(
metorialAiSdk,
{ serverDeployments: ['your-deployment'] },
async session => {
console.log('Available tools:', Object.keys(session.tools));
// Continue with your logic
}
);
Start with simple queries to verify the setup:
// Simple test that shouldn't need tools
let test1 = await generateText({
model: openai('gpt-4o'),
prompt: 'Say hello',
maxSteps: 1,
tools: session.tools
});
console.log('Basic test:', test1.text);
// Test that requires one tool call
let test2 = await generateText({
model: openai('gpt-4o'),
prompt: 'What time is it?',
maxSteps: 3,
tools: session.tools
});
console.log('Tool test:', test2.text);
If you're hitting rate limits:
maxSteps
or batch requestsIf you're still experiencing issues:
Connect Vercel AI SDK to Metorial and unlock instant access to over 600 integrations for your AI-powered applications. Our open-source, MCP-powered platform makes it effortless to add tools, APIs, and services to your AI SDK projects without writing complex integration code. With Metorial's TypeScript SDK, you can integrate calendars, databases, communication tools, and hundreds of other services in just a couple of lines of code. Whether you're building chatbots, AI assistants, or intelligent workflows with Vercel's AI SDK, Metorial eliminates integration headaches so you can focus on creating exceptional user experiences. Our developer-friendly approach means less time wrestling with authentication, API documentation, and maintenance—and more time innovating. Join developers who are shipping AI applications faster by letting Metorial handle the integration layer while you concentrate on what makes your app unique.
Let's take your AI-powered applications to the next level, together.
Metorial provides developers with instant access to 600+ MCP servers for building AI agents that can interact with real-world tools and services. Built on MCP, Metorial simplifies agent tool integration by offering pre-configured connections to popular platforms like Google Drive, Slack, GitHub, Notion, and hundreds of other APIs. Our platform supports all major AI agent frameworks—including LangChain, AutoGen, CrewAI, and LangGraph—enabling developers to add tool calling capabilities to their agents in just a few lines of code. By eliminating the need for custom integration code, Metorial helps AI developers move from prototype to production faster while maintaining security and reliability. Whether you're building autonomous research agents, customer service bots, or workflow automation tools, Metorial's MCP server library provides the integrations you need to connect your agents to the real world.