How do I…?

How do I get my own Gemini API key, and connect Spark?

Want to use Gemini in your own code, or with Spark, the study buddy on this site? By the end, you will have your own key from Google AI Studio, know how to keep it safe, and have Spark answering your first question.

Read~5 min
Watch3:31 video
Steps3 + 4, each on screen
Published20 Oct 2026

Prefer to watch? This post goes with the video (3:31). Open it on YouTube.

Why you need a key

Any program that asks Google's Gemini a question needs a key: your own code, an app, or Spark, the study buddy on this site. So why a key at all? Let's try to understand.

Say you join a library. The books are there for everyone, but to borrow one, you show your own card. The card says who is borrowing, and how many books that person may take.

Gemini works the same way. Each question you send uses a little of Google's computing, and your key tells Google that the question is yours.

Google also sets how much each key may ask, per minute and per day. Those limits change from time to time, so check them in AI Studio.

That card is what we call an API key. First, get your key. Then, if you are learning with us, give it to Spark.

Get your Gemini API key

It takes three steps, all in Google AI Studio.

1

Create the key

Open Google AI Studio → API keys and sign in with your Google account. Then click Create API key.

Give your key a name you will recognise, such as Learn AI by Building. Keep the Default Gemini Project, or create a project of your own, as in the recording. Then click Create key.

The waits are cut out: the typing, and the spinners.
2

Copy the key

The key appears in API key details. Click Copy key, or the copy icon beside it, and paste the key wherever you need it.

This key was deleted at the end of the recording. When you do this, it is the one moment your key shows in full, so make sure nobody else can see your screen.
3

Delete a key, when you are done with it

Come back here when you stop using a key, or when someone else may have seen it. On the API keys page, open the ⋮ menu on the key's row, click Delete key, then Delete.

The wait while Google deletes the key is cut out.

Deleting cannot be undone, and anything using that key stops working. To carry on, make a new key and use the new one instead.

AI Studio will not let you create a key?

Check that you are 18 or older, and that your Google account has your age verified. Also check that you are in a country where the Gemini API works.

Keep your key safe

Your key is like a password: whoever has it can ask Gemini as you, and use up your limits.

  • Never share it, not in a chat, an email, a screenshot or a comment.
  • Paste it only where you trust the page. On this site, that is Spark, and nowhere else.
  • If it may have leaked, delete it (step 3 above), and make a new one.

How programs use a key safely, and why it never goes into shared code, comes later in the series.

That is your key. If you came for the key alone, you are done; to use it on this site, read on.

Use your key with Spark

Every lesson on this site has Spark, our study buddy, and Spark thinks with Gemini using your own key. You give it the key once. It stays in this browser, and it goes only to Google, together with your question.

1

Open Spark

Open any lesson, for example Chapter 0, and press the round ✦ Spark button at the bottom right.

2

Paste your key

Paste the key into Your Gemini API key, where it shows only as dots. Then press Save key & start. If you came in through ⚙ settings, the button says Save settings instead.

Chrome may offer Save password? when you paste the key. Choose Never, because the key is not a password for this site.

3

Ask a question

Type into Ask about this unit and press the arrow. Start simple, with Hello Spark.

4

See the answer

Spark answers from the page you are on. Then ask it something real.

Try one of these in SparkSummarise this page in three sentences. Explain the highlighted line as if I am new to coding. Give me one question to test what I learned here.
The waits are cut out: the typing, and the spinners.
On a shared computer

Clear the key before you leave. Open Spark's ⚙ settings, empty the key box, and press Save settings.

When Spark goes wrong

Read the message first, because Spark tells you what Google said. Here is what each message means, and what to do.

  • "That API key was rejected by Google — let's re-enter it." Part of the key was missed, a space came along, or the key was deleted. Copy it again with Copy key, and paste it again.
  • "The quota for your key is used up for now — wait a minute and try again." You asked more than your key may ask in a minute. Wait, and ask again; AI Studio's Rate Limit page shows your limits.
  • A message from Google about your location or region. The Gemini API does not work in your country yet. The list of countries is in the references.
  • Spark says nothing at all. Check your internet connection, reload the page, and try once more.

Still stuck? Use Gemini chat at gemini.google.com for now, and come back to Spark later.

References

Where each rule on this page comes from. Checked on 20 Oct 2026.

  1. Google — Gemini API: Using API keys. Where keys are created (AI Studio, API keys page), and the advice to treat a key like a password. link
  2. Google — Gemini API Additional Terms of Service. You must be 18 or older, and use the API from an available region. link
  3. Google — Gemini API: Available regions. The countries where Google AI Studio and the Gemini API work (India is one), and why access can be blocked. link
  4. Google — Gemini API: Rate limits. How much a key can ask, per minute and per day; the limits change, so check here. link
  5. Google — Gemini API: Troubleshooting. What to do when a key is rejected, blocked or reported as leaked: make a new one. link