TogetherAI

Connect Integrations to
TogetherAI

Build advanced AI agents with TogetherAI. Connect 600+ integrations, automate workflows, and deploy with ease using Metorial.

Back to TogetherAI overview

Common Errors and Troubleshooting

This guide covers common issues you might encounter when integrating Metorial with the AI SDK and how to resolve them.

Authentication Errors

"Invalid API key"

Cause: Your Metorial API key is incorrect or missing.

Solution:

// Check that your key is properly loaded
console.log('API Key exists:', !!process.env.METORIAL_API_KEY);

const metorial = new Metorial({
  apiKey: process.env.METORIAL_API_KEY!
});

Verify:

  • The key is correctly set in your .env.local file
  • You've restarted your development server after adding the key
  • There are no extra spaces or quotes around the key

"Invalid server deployment ID"

Cause: The deployment ID doesn't exist or you don't have access to it.

Solution:

  • Log in to your Metorial dashboard
  • Navigate to Server Deployments
  • Copy the correct deployment ID
  • Verify it matches what's in your code

Session Errors

"Session already closed"

Cause: Trying to use a session after the withProviderSession callback has completed.

Solution:

// ❌ Don't do this
let savedSession;
await metorial.withProviderSession(
  metorialAiSdk,
  { serverDeployments: ['dep_123'] },
  async session => {
    savedSession = session; // Don't save for later use
  }
);
savedSession.callTools(...); // This will fail

// ✅ Do this instead
await metorial.withProviderSession(
  metorialAiSdk,
  { serverDeployments: ['dep_123'] },
  async session => {
    // Do all your work inside the callback
    await session.callTools(...);
  }
);

Tool Call Errors

"Tool not found"

Cause: The AI model is trying to call a tool that isn't in your server deployment.

Solution:

  • Check your server deployment in the Metorial dashboard
  • Verify it includes the integration the tool needs
  • Update your deployment to include missing integrations

"Tool execution timeout"

Cause: A tool call is taking too long to complete.

Solution:

try {
  const result = await generateText({
    model: openai('gpt-4'),
    messages,
    tools: session.tools,
    maxToolRoundtrips: 5
  });
} catch (error) {
  if (error.message.includes('timeout')) {
    console.error('Tool execution timed out');
    // Implement retry logic or fallback
  }
}

Model Errors

"Rate limit exceeded"

Cause: You've exceeded your AI provider's rate limits.

Solution:

  • Implement exponential backoff retry logic
  • Reduce the frequency of requests
  • Upgrade your AI provider plan if needed

"Invalid model name"

Cause: The model identifier is incorrect for your AI provider.

Solution:

// For OpenAI
import { openai } from '@ai-sdk/openai';
const model = openai('gpt-4'); // Correct

// For Anthropic
import { anthropic } from '@ai-sdk/anthropic';
const model = anthropic('claude-3-opus-20240229'); // Correct

Check your AI provider's documentation for valid model names.

Network Errors

"Connection timeout"

Cause: Network connectivity issues or slow responses.

Solution:

// Implement retry logic
async function withRetry(fn, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await fn();
    } catch (error) {
      if (i === maxRetries - 1) throw error;
      await new Promise(resolve => setTimeout(resolve, 1000 * (i + 1)));
    }
  }
}

await withRetry(() => 
  metorial.withProviderSession(/* ... */)
);

Debugging Tips

  1. Enable verbose logging:
// Check tool calls during development
const result = await generateText({
  model: openai('gpt-4'),
  messages,
  tools: session.tools,
  onToolCall: (toolCall) => {
    console.log('Tool called:', toolCall);
  }
});
  1. Check network requests: Use your browser's developer tools or a tool like Postman to verify API calls

  2. Verify permissions: Ensure your API keys have the necessary permissions

  3. Check service status: Visit Metorial's status page if you suspect a service issue

Getting Help

If you're still experiencing issues:

TogetherAI on Metorial

Build powerful AI applications with TogetherAI and Metorial's comprehensive integration platform. Connect TogetherAI's diverse collection of open-source language models to over 600 integrations through our MCP-powered, open-source SDKs. Metorial makes it effortless to give your TogetherAI-based agents access to calendars, databases, communication tools, project management platforms, and hundreds of other services in just a couple of lines of Python or TypeScript code. Whether you're leveraging Llama, Mistral, or other models available through TogetherAI's platform, Metorial eliminates integration complexity so you can focus on building intelligent features. Our developer-first approach handles authentication, API management, error handling, and rate limiting automatically—no more maintaining brittle integration code or debugging OAuth flows. With Metorial's open-core model, you get the transparency and flexibility of open source with the reliability and support you need for production applications. Stop wasting engineering cycles on integration plumbing and start shipping AI-powered features that differentiate your product and delight your users. Let Metorial handle the connections while you concentrate on creating breakthrough AI experiences.

Connect anything. Anywhere.

Ready to build with Metorial?

Let's take your AI-powered applications to the next level, together.

About Metorial

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.

Star us on GitHub