Explore / Build the product / AI agents

AI agents · How Founders Use AI

How do I get an API key for OpenAI or Gemini?

Checked 17 November 2026

For Gemini, sign in to Google AI Studio and open the API Keys page: a new user gets a default project and key once they accept the terms. For OpenAI, sign in to the API platform, create a key in the dashboard and add credits under billing. Keep either key in an environment variable, never in your code.

On the AI map, 29 October 2026 Frontier modelsOpen-weight modelsDecision models

By case

  • If you want to try a model for free

    Start with a Gemini key from Google AI Studio and use the free tier.

    Gemini's free tier covers its Flash model, though Google may use free-tier data to improve its products.

    Gemini API: Per million tokens: Gemini 3.8 Flash $0.75 input, $3.75 output to 31 Dec 2026; Gemini 4 Argon $2 and $10 to 30 Nov 2026, then $4 and $20, read from ai.google.dev on 10 November 2026

  • If your product will run on OpenAI's models

    Create a project key on OpenAI's API keys page and add credits.

    OpenAI's API is paid by the token, separately from a ChatGPT subscription.

    OpenAI API: Per million tokens, input and output: GPT-6.2 Astra $8 and $40, GPT-6.2 Sol $2 and $10, GPT-6 Astra $10 and $50, GPT-6.1 Terra $1 and $5, GPT-6 Luna $0.10 and $0.50, read from developers.openai.com on 25 November 2026

  • If you already pay for ChatGPT Pro or Business

    Link your subscription to an API organisation you own to claim the monthly API credits.

    The credits arrive with each renewal and lapse at the end of the billing cycle.

  • If the key will run in a deployed app

    Create a project service account and use its key, not your own user key.

    OpenAI's guide gives a deployed app an identity separate from any one developer.

The steps5 steps

  1. Open Google AI Studio's API Keys page and accept the terms; a new user gets a default project and key.

    The official page on ai.google.dev

  2. Set the key as GEMINI_API_KEY in your environment, where Google's client libraries look for it.

    The official page on ai.google.dev

  3. For OpenAI, sign in to the platform and create an API key in the dashboard.

    The official page on developers.openai.com

  4. Export it as OPENAI_API_KEY in your terminal, then add credits under billing.

    The official page on developers.openai.com

  5. Set a monthly budget or billing alert on both before you ship anything.

The figuresEach with where it was read

  • Monthly API credits with ChatGPT Pro $100, $200 or $500 by Pro tier API credits for ChatGPT subscribers, read 17 November 2026
  • Monthly API credits with ChatGPT Business $20 a Standard seat, $100 a Premium seat API credits for ChatGPT subscribers, read 17 November 2026
  • Gemini API free tier Free tier on Gemini 3.8 Flash and 3.8 Flash TTS; Gemini 4 Argon is not on the free tier Gemini API, read 17 November 2026
  • OpenAI API prices per million tokens GPT-6.1 Terra $1 input and $5 output; GPT-6 Luna $0.10 and $0.50 OpenAI API, read 17 November 2026

Where it differs

  • India

    Both keys work from India and both bill in dollars on an international card, so a card that blocks foreign online payments has to be switched on for it first.

What goes wrong

  • Pasting the key into code that goes to GitHub or into an app's front end, where anyone can copy it.

  • Running a launch without a billing alert, so a loop or a leaked key runs up the bill overnight.

  • Using one developer's personal key for the whole team's production app.

Go deeper6 sources

  • Using Gemini API keys

    Google · Guide · 2026

    Google's steps to create a key in AI Studio, what happens for new and existing Cloud users, and how to keep it safe.

  • Gemini Developer API pricing

    Google · Tool · Nov 2026

    The free and paid tiers by model: Gemini 3.8 Flash is free on the free tier ($0.75 / $3.75 per million tokens paid until 31 December 2026); Gemini 4 Argon is paid only.

  • Developer quickstart

    OpenAI · Guide · 2026

    OpenAI's first steps: create an API key in the dashboard, export it as an environment variable and make your first call.

  • API keys and service accounts

    OpenAI · Guide · 2026

    Which kind of key to use for your own testing, a deployed app or automation, and why one developer's key should not run production.

  • API credits for ChatGPT subscribers

    OpenAI · Guide · 2026

    Pro plans include $100, $200 or $500 of API credits a month and Business seats $20 or $100, claimed by linking the subscription to an API organisation.

  • Get started with Claude

    Anthropic · Guide · 2026

    The same steps for Anthropic's API, if you want a Claude key as well.