Skip to main content

Getting Started with AI Gateway

Follow these steps to start routing your AI requests through the LeanMCP AI Gateway.
Already have a LeanMCP account? Skip straight to Step 3: Generate an API Key.

Prerequisites

You need credits on your LeanMCP account to use the AI Gateway. Credits are used to cover the cost of AI provider requests plus a small gateway fee.

Step 1: Create an Account

  1. Go to leanmcp.com
  2. Sign up with your email or GitHub account
  3. Complete the onboarding process
Sign up for LeanMCP

Step 2: Purchase Credits

  1. Navigate to Settings > Billing in your dashboard
  2. Select a credit package or set up auto-recharge
  3. Complete the payment
Credits are used at approximately the same rate as direct API calls, plus a small fee for gateway services (logging, security scanning, etc.).

Step 3: Generate an API Key

  1. Go to Settings > API Keys
  2. Click Create New API Key
  3. Give your key a descriptive name (e.g., “Windsurf Development”)
  4. Copy and save your API key securely
Your API key is shown only once. Store it securely - you’ll need it to authenticate requests.

Step 4: Configure Your Application

Replace your AI provider’s base URL and API key with the gateway endpoint:
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://aigateway.leanmcp.com/v1/openai',
  apiKey: 'your-leanmcp-api-key',
});

Step 5: Verify It’s Working

Make a test request and check your dashboard:
const response = await client.chat.completions.create({
  model: 'gpt-5.2',
  messages: [{ role: 'user', content: 'Hello!' }],
});

console.log(response.choices[0].message.content);
  1. Open app.leanmcp.com/observability
  2. You should see your test request appear within a few seconds
AI Gateway Logs
Saw your request in the logs? You’re connected.Open app.leanmcp.com/observability to start monitoring.

What’s Next?

View Request Logs

See all your AI requests and responses

Set Up Security Rules

Block sensitive data and malicious requests

Track Token Usage

Monitor costs and optimize spending

Full Integration Guide

Code examples for all providers

Ready? Open your Observability Dashboard →

View your first logged AI request at app.leanmcp.com/observability