---
title: "How to Get Your OpenRouter API Key"
description: "This guide walks you through how to get your OpenRouter API key in just a few minutes. You’ll learn how to create an account, add credits, generate your key, store it securely, and also how to run a quick test to confirm everything is working."
author: "Saurabh Rai"
published: "2025-09-30T14:01+01:00"
updated: "2025-10-02T12:59:54.774Z"
url: "https://www.apideck.com/blog/how-to-get-your-openrouter-api-key"
tags: ["AI", "Guides & Tutorials"]
---

# How to Get Your OpenRouter API Key

![How to Get Your OpenRouter API Key 1](//images.ctfassets.net/d6o5ai4eeewt/6MublOfr3jx2X33CQBrmib/88a75ea715554bc9ae8fde6c267b5798/Screenshot_2025-10-01_at_03.07.39_2x.png)

OpenRouter is an API gateway that gives you access to multiple AI models (OpenAI, Anthropic, Google, Meta, and more) through a single API. Instead of managing separate API keys for each provider, you pay OpenRouter and route requests to whichever model you need. It’s popular for developers who want model flexibility without maintaining multiple integrations.

Getting an API key takes about 2 minutes.

## Step 1: Create Your Account
Go to [openrouter.ai](https://openrouter.ai/) and sign up. You can use Google, GitHub, or email authentication.

## Step 2: Add Credits
OpenRouter uses a prepaid credit system. Go to the [Credits page](https://openrouter.ai/credits) and add funds to your account. Minimum is usually $5. You’ll need credits before you can use the API.

## Step 3: Generate an API Key

![How to Get Your OpenRouter API Key 2](//images.ctfassets.net/d6o5ai4eeewt/nJYoXEj339wHWvI5K9wUo/6ab91c19b0d4c7c69efeb2d13b929e20/Screenshot_2025-10-01_at_03.08.48_2x.png)

1. Navigate to [openrouter.ai/keys](https://openrouter.ai/keys)
2. Click “Create Key”
3. Give it a name (optional, but useful if you create multiple keys)
4. **Copy the key immediately** — you won’t see it again

## Step 4: Store Your Key Securely

![How to Get Your OpenRouter API Key 3](//images.ctfassets.net/d6o5ai4eeewt/4g92JBX1YeE3qToM77Joqw/1e43ee9d029610e2526584f22c8ddd83/Screenshot_2025-10-01_at_03.08.19_2x.png)

Use environment variables, not hardcoded keys.
**For terminal/command line:**
```

bash
export OPENROUTER_API_KEY=your-api-key-here

```

**For applications (.env file):**
```

OPENROUTER_API_KEY=your-api-key-here
Add .env to .gitignore.

```

## Quick Test
OpenRouter uses OpenAI-compatible endpoints, so you can test with:

```

bash
curl https://openrouter.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "meta-llama/llama-3.1-8b-instruct:free",
    "messages": [{"role": "user", "content": "Hello"}]
  }'

```