Skip to main content

Getting Your API Key

To use the LeanMCP AI Gateway, you need an API key. This key authenticates your requests and tracks your usage.

Prerequisites

You need credits on your LeanMCP account before using the AI Gateway. Purchase credits at ship.leanmcp.com first.

Creating an API Key

1

Go to API Keys Page

2

Click Create New Key

Click the Create API Key button in the top right corner.
3

Configure Your Key

Fill in the details:
  • Name: A descriptive name (e.g., “Windsurf Development”, “Production App”)
  • Permissions: Select SDK permissions for AI Gateway access
Create API key modal
4

Copy and Save

Your API key will be displayed only once. Copy it immediately and store it securely.
API keys are shown only at creation time. If you lose it, you’ll need to create a new one.

API Key Format

LeanMCP API keys are prefixed with leanmcp_ for easy identification:
leanmcp_859fc75e29e90aaf85d3a1eb55803c902995a0b796ef3b93cdac445692be53ea

Using Your API Key

Once you have your API key, use it in place of your AI provider’s API key:
export LEANMCP_API_KEY="leanmcp_your_key_here"

Managing API Keys

View All Keys

Go to ship.leanmcp.com/api-keys to see all your API keys:
  • Creation date
  • Last used
  • Usage statistics

Delete a Key

To revoke an API key:
  1. Go to the API Keys page
  2. Find the key you want to delete
  3. Click the Delete button
  4. Confirm deletion
Deleting an API key immediately stops all requests using that key. Make sure to update your applications before deleting.

Rotate Keys

For security, we recommend rotating your API keys periodically:
  1. Create a new API key
  2. Update your applications to use the new key
  3. Verify everything works
  4. Delete the old key

Best Practices

Create separate API keys for development, staging, and production. This makes it easier to track usage and rotate keys without affecting all environments.
Use environment variables or secret management tools. Add .env files to your .gitignore.
Check the API Keys page regularly to monitor usage and detect any unusual activity.
Configure alerts in your dashboard to be notified when you’re approaching credit limits.

Next Steps

Now that you have your API key, set up the AI Gateway in your preferred tool: