API Keys

How to Get a Free LLM API Key: Step-by-Step for Every Major Provider

Acquiring an API key for Large Language Models does not require enterprise approvals or credit card verification. Follow these step-by-step walkthroughs to get active, working credentials for Google, Groq, GitHub, and OpenRouter in under two minutes.

Interactive AI Model Explorer

Want to calculate your exact parameters and operational expenses? Run the calculations locally inside your browser.

Launch AI Model Explorer

1. Getting a Google AI Studio API Key (Gemini 2.0)

Google AI Studio provides instant access to Gemini 2.0 Flash with 1M context:

1. Navigate to aistudio.google.com in your browser. 2. Sign in with any standard personal or Google Workspace account. 3. Click the blue Get API Key button in the top left sidebar navigation. 4. Select Create API key in new project (or attach to an existing Google Cloud project). 5. Copy the generated key (starts with AIzaSy...) immediately and store it in your environment file.

bash
# .env.local
GEMINI_API_KEY="AIzaSyYourGeneratedSecretKeyHere"

2. Getting a Groq Cloud API Key (Llama 3.3 70B & DeepSeek)

Groq provides access to the fastest inference endpoints on the web:

1. Visit console.groq.com. 2. Click Sign In with GitHub or Sign In with Google. 3. In the left navigation bar, click API Keys. 4. Click Create API Key, enter a descriptive name (e.g. Dev-Agent-Testing), and click Submit. 5. Copy the secret key (starts with gsk_...). Note that it is only displayed once.

bash
# .env.local
GROQ_API_KEY="gsk_YourSecretGroqKeyHere"

3. Using GitHub Models via Personal Access Token

If you have an active GitHub account, you already have access to GPT-4o, Claude 3.5 Sonnet, and o3-mini:

1. Navigate to github.com/settings/tokens (Fine-grained tokens or classic PAT). 2. Generate a new token with basic Models read permissions. 3. Set your endpoint URL to https://models.inference.ai.azure.com and pass your GitHub PAT as the Bearer token. 4. Access sandbox prototyping models with zero financial exposure.

4. Best Practices for API Key Security

Never commit your raw API keys to public repositories:

  • Always use .gitignore: Ensure .env, .env.local, and *.pem files are listed in your repository root.
  • Rotate keys regularly: If a key is accidentally pushed to GitHub, revoke it immediately in the provider console.
  • Use client-side proxies: Never call LLM APIs directly from client-side React/Vue code where keys can be inspected via browser network tabs. Route requests through Next.js server actions or backend API handlers.

Frequently Asked Questions

How many API keys can I create for free?

Most providers allow you to create between 5 and 20 separate API keys per account for project separation and rate limit isolation.

Do free API keys expire?

Google and Groq keys do not expire unless manually revoked or dormant for over 12 months without API calls.

Can I use one API key across multiple applications?

Yes, but creating separate keys per project is recommended so you can isolate revoke credentials without breaking multiple applications.