How to create an OpenRouter API key to use in Ozeki AI Gateway

This guide demonstrates how to create an OpenRouter API key and configure it in Ozeki AI Gateway. You'll learn how to access the OpenRouter platform, generate a new API key with usage limits, and set up OpenRouter as a provider in your gateway. By following these steps, you can connect your Ozeki AI Gateway to multiple AI models through OpenRouter's unified interface.

What is OpenRouter?

OpenRouter is a unified API gateway that provides access to multiple large language models through a single, standardized interface. Instead of managing separate API keys and integrations for different AI providers, OpenRouter allows you to access models from OpenAI, Anthropic, Google, Meta, and many others through one consistent API. When configured with Ozeki AI Gateway, OpenRouter gives your users access to a wide variety of AI models through a single provider connection.

How to create OpenRouter API Key (Quick Steps)

  1. Navigate to OpenRouter website
  2. Log in using your email and password
  3. Create a new API key
  4. Configure key name and limits
  5. Set expiration date (optional)
  6. Generate and copy the key
  7. Open Providers page in Ozeki AI Gateway
  8. Add new provider
  9. Enter OpenRouter provider details
  10. Create provider

How to Create OpenRouter API Key (Video tutorial)

In this video tutorial, you will learn how to create an OpenRouter API key and configure it in Ozeki AI Gateway step-by-step. The video covers accessing the OpenRouter platform, generating a new API key, and setting up OpenRouter as a provider in your gateway.

Step 0 - Install Ozeki AI Gateway

Before configuring OpenRouter as a provider, you need to have Ozeki AI Gateway installed and running on your system. If you haven't installed Ozeki AI Gateway yet, follow our Installation on Linux Guide to complete the initial setup.

Step 1 - Navigate to OpenRouter website

Navigate to the OpenRouter website. This is the main portal where you can access the OpenRouter dashboard, view available models, and manage your API keys (Figure 1).

Navigate to OpenRouter website
Figure 1 - Navigate to OpenRouter website

Step 2 - Click Get API Key

Locate and click the "Get API Key" button. This will direct you to either the login page or the API key management dashboard if you're already logged in. If you don't have an account yet, you'll be prompted to create one (Figure 2).

Click Get API Key
Figure 2 - Click Get API Key

Step 3 - Login using email

On the login page, enter your registered email address in the provided field. If you don't have an OpenRouter account yet, click "Sign Up" to create one first (Figure 3).

Login using email
Figure 3 - Login using email

Step 4 - Enter your password

Enter your password in the field and click the "Continue" button to proceed (Figure 4).

Enter your password
Figure 4 - Enter your password

Step 5 - Click Create API Key

Once logged in, you'll be taken to the OpenRouter dashboard. Navigate to the API Keys section and Click the "Create API Key" button to open the configuration dialog (Figure 5).

Click Create API Key
Figure 5 - Click Create API Key

Step 6 - Choose API key name

In the API key creation dialog, enter a descriptive name for your API key. Choose a name that helps you identify the purpose or project for this key, such as "Ozeki AI Gateway". Using descriptive names makes it easier to manage multiple keys and track usage across different projects (Figure 6).

Choose API key name
Figure 6 - Choose API key name

Step 7 - Optionally set credit and reset limit

OpenRouter allows you to set spending limits on your API keys to prevent unexpected charges. In this step, you can optionally configure credit limits that restrict how much the key can spend. You can also set reset periods (daily, weekly, or monthly) that automatically renew your spending limits (Figure 7).

Optionally set credit and reset limit
Figure 7 - Optionally set credit and reset limit

Step 8 - Set expiration

Configure an expiration date for your API key if necessary. You can choose to have the key expire after a specific amount of time or set it to never expire (Figure 8).

Set expiration
Figure 8 - Set expiration

Step 9 - Click Create

After configuring all the settings, click the "Create" button to generate your new API key. OpenRouter will process your request and create a unique API key with the specified parameters (Figure 9).

Click Create
Figure 9 - Click Create

Step 10 - View API key

Your new API key is now displayed on the screen. This is a long alphanumeric string that typically starts with "sk-or-" followed by a unique identifier (Figure 10).

API key
Figure 10 - API key

Step 11 - Copy your API key

Click the "Copy" button to copy the API key to your clipboard (Figure 11).

The API key is shown only once for security reasons. Make sure to copy and securely store the key before closing this window.

Copy your API key
Figure 11 - Copy your API key

Step 12 - Close API key window after copy

After successfully copying your API key, you can close the API key display window (Figure 12). Once closed, you will not be able to view the full key again through the OpenRouter interface. If you lose your key, you'll need to create a new one.

Close API key window after copy
Figure 12 - Close API key window after copy

Step 13 - API key created

Your API key has been successfully created and is now active. You can see it listed in your API Keys dashboard along with its name, usage statistics, and configured limits. The key will remain active until it expires or you manually revoke it (Figure 13).

API key created
Figure 13 - API key created

Step 14 - Open Providers page in Ozeki AI Gateway

Open the Ozeki AI Gateway web interface and navigate to the Providers page. This is where you'll configure OpenRouter as a new provider using the API key you just created (Figure 14).

Open Providers page
Figure 14 - Open Providers page in Ozeki AI Gateway

Step 15 - Click add new provider

Click the "New" button to begin the provider creation process. This opens a form where you'll enter the connection details for OpenRouter (Figure 15).

Click add new provider
Figure 15 - Click add new provider button

Step 16 - Enter OpenRouter provider details

Fill in the provider configuration form with OpenRouter's details. Enter "OpenRouter" as the provider name, select "OpenAI compatible" as the provider type, specify the API endpoint URL, and paste the API key you copied earlier. Select the preferred model from the dropdown list, then click "Create" to save the configuration (Figure 16).

https://openrouter.ai/api/v1

Enter OpenRouter provider details
Figure 16 - Enter OpenRouter provider details and create

Step 17 - Provider created

After clicking "Create", the OpenRouter provider is added to Ozeki AI Gateway. The provider now appears in the providers list, confirming that your gateway can route requests to OpenRouter's services. You can now create routes that allow users to access multiple AI models through OpenRouter (Figure 17).

Provider created
Figure 17 - OpenRouter provider created successfully

Final thoughts

You have successfully created an OpenRouter API key and configured it as a provider in Ozeki AI Gateway. Your gateway can now communicate with OpenRouter's services and access multiple AI models from different providers through a single unified interface. This setup allows you to manage access to dozens of AI models for multiple users and applications from a single point, making it easy to experiment with different models and optimize for performance and cost.

More information