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

Environment Variables and Security

Learn how to securely manage your Metorial and AI SDK credentials in your applications.

Never Hardcode API Keys

Never put API keys directly in your code:

// ❌ NEVER DO THIS
const metorial = new Metorial({
  apiKey: 'met_abc123xyz'
});

Instead, use environment variables:

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

Setting Up Environment Variables

Create a .env.local file in your project root:

# Metorial Configuration
METORIAL_API_KEY=your-metorial-api-key
METORIAL_DEPLOYMENT_ID=your-deployment-id

# AI Provider (example for OpenAI)
OPENAI_API_KEY=your-openai-api-key

Important: Add .env.local to your .gitignore:

# .gitignore
.env.local
.env*.local

Using Environment Variables

Access them in your code:

import { Metorial } from 'metorial';

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

await metorial.withProviderSession(
  metorialAiSdk,
  { serverDeployments: [process.env.METORIAL_DEPLOYMENT_ID!] },
  async session => {
    // Your code here
  }
);

Production Deployment

Vercel

  1. Go to your project settings
  2. Navigate to "Environment Variables"
  3. Add your keys with appropriate scopes (Production, Preview, Development)

Other Platforms

Consult your platform's documentation for managing environment variables:

  • Netlify: Site settings > Environment variables
  • Railway: Project settings > Variables
  • AWS: Use AWS Secrets Manager or Parameter Store
  • Docker: Pass via -e flag or docker-compose.yml

Security Best Practices

  1. Rotate keys regularly: Generate new API keys every few months
  2. Use separate keys per environment: Different keys for dev, staging, and production
  3. Limit key permissions: Only grant necessary access
  4. Monitor usage: Check your Metorial dashboard for unusual activity
  5. Never log keys: Avoid logging environment variables
  6. Server-side only: Never expose API keys to client-side code

Client-Side vs Server-Side

Metorial API keys should only be used server-side:

// ✅ Server-side (Next.js API Route)
export async function POST(req: Request) {
  const metorial = new Metorial({
    apiKey: process.env.METORIAL_API_KEY! // Safe - runs on server
  });
  // ...
}

// ❌ Client-side (React Component)
function MyComponent() {
  const metorial = new Metorial({
    apiKey: process.env.NEXT_PUBLIC_METORIAL_API_KEY // NEVER DO THIS
  });
  // ...
}

Revoking Compromised Keys

If you suspect a key has been compromised:

  1. Immediately revoke it in your Metorial dashboard
  2. Generate a new key
  3. Update your environment variables
  4. Redeploy your application
  5. Review recent API usage for suspicious activity

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