How do I get an OpenAI API key and a Gemini API key?
Short answer
At OpenAI, sign in at platform.openai.com, add prepaid credits under Billing, open API keys, click Create new secret key and choose Restricted permissions. At Google, open aistudio.google.com, go to API keys, click Create API key and then Set up billing for its project. Copy each key straight into your password manager and set a monthly spending limit at both providers.
Facts at a glance
- OpenAI
- platform.openai.com → API keys → Create new secret key
- Google Gemini
- aistudio.google.com → API keys → Create API key
- Minimal OpenAI permissions
- Restricted key: “List models” on Read, “Model capabilities” on Request, everything else None
- Minimal Gemini permissions
- Keys created in Google AI Studio since 28 May 2026 are limited to the Gemini API by default
- Billing
- Both prepaid: OpenAI credits; Google prepay of at least $5
- Spending limit
- OpenAI: hard monthly limit per project; Google: monthly spend cap per project (experimental)
- Kirat's cost
- $0.02–$0.15 per council decision in our measurements, paid to OpenAI and Google directly
Before you start
- An OpenAI account and a Google account (you can create both on the way), and a payment method for the prepaid credit at both.
- A password manager. Each key is a password that spends your money: never paste it into a chat, a document, code you share or a screenshot.
- For Kirat you need both keys, with billing switched on. Kirat sends its calls straight to OpenAI and Google under your accounts; we never see the keys.
OpenAI: create the key
- Sign in or create an account at platform.openai.com. This is the developer platform; a ChatGPT subscription does not include API usage.
- Optional but tidy: create a project just for this use, so its key, usage and limit stay separate.
- Open Settings → Billing and add credits. API usage is paid in advance; when the credit is used up, calls fail until you top up. Leave automatic recharge off so nothing tops up on its own, and set the spending limit below as well.
- Open API keys (platform.openai.com/api-keys) and click Create new secret key. Give it a name such as “Kirat”, pick the project and set the permissions to Restricted (next section).
- Copy the key, which starts with
sk-, into your password manager right away. OpenAI shows it in full only once; if you lose it, delete it and create a new one.
OpenAI: minimal permissions
A restricted key can do only what you allow. For Kirat two permissions are enough: List models on Read and Model capabilities on Request. Set everything else to None. “Model capabilities” covers the endpoints for text, audio, embeddings and images, including the Responses API that Kirat uses. If a call fails with a message about missing scopes, open the key again and check that “Model capabilities” really says Request.
OpenAI: a hard spending limit
Go to Project settings → Limits, click Edit spend limit under Spend, enter a monthly amount and turn on Enforce a hard limit. Without that switch the limit only sends an alert. With it, calls fail with error 429 once the project reaches the amount, until the next month or until you raise it. Enforcement takes a moment, so actual spend can end slightly above the limit.
Google Gemini: create the key
- Open aistudio.google.com and sign in with your Google account. Accept the terms if AI Studio asks. New users get a Google Cloud project automatically.
- Go to API keys and click Create API key. Choose the project; if you already use Google Cloud, import an existing project under Projects first.
- Copy the key into your password manager.
- In the Billing Tier column, click Set up billing, choose or create a billing account and prepay at least $5. Prepaid credits expire after 12 months.
Google Gemini: permissions, spending cap and the free tier
- Permissions: keys created in Google AI Studio since 28 May 2026 are limited to the Gemini API by default. An older key marked Unrestricted: hover the label, click Add restrictions and choose Restrict to Gemini API only. A key from the Google Cloud console: under APIs & Services → Credentials, open the key, choose Restrict key under API restrictions and select only the Generative Language API.
- Spending cap: open the Spend page for the project, click Edit spend cap under Monthly spend cap and enter an amount. Google marks it as experimental, and billing data can lag about 10 minutes, so actual spend can end above the cap. When the prepaid balance reaches zero, all keys of that billing account stop working with error 402.
- Free tier: Google may use prompts and answers sent on the unpaid tier to improve its products, and human reviewers may read them. Content sent with billing switched on is not used for this. Don't send confidential data through an unpaid key.
Keep the keys safe
- One key per app or use. If one leaks, you delete that key and nothing else breaks.
- Store keys in a password manager or in the app's own secure storage, never in a file next to your code.
- Suspect a leak? Delete the key at once in the dashboard and create a new one. Then look at the usage page for calls you did not make.
Common error messages
- Invalid key (OpenAI: 401; Gemini: 400 with API_KEY_INVALID): the key was copied incompletely, has been deleted, or belongs to the other provider.
- 429: a rate limit or your own spending limit has been reached. At OpenAI the message names a spend limit or used-up credit; at Google it says RESOURCE_EXHAUSTED.
- 402 at Google: the prepaid balance is used up. Top it up under Billing.
- In Kirat,
kirat_statuschecks both keys and says which one fails, without showing the key.
The providers' own documentation
Dashboards change. If a button is named differently, the providers' pages are the reference: OpenAI spend limits, Gemini API keys and Gemini API billing. We checked every step against them on 2 November 2026.
Next step: put the keys into Kirat
The setup guide shows where the keys go for each way of using Claude: in the extension dialog of the Claude app, with /plugin configure kirat@kirat in Claude Code, or as network secrets in a Claude Code cloud environment, where nobody in a session can read them.
Sources on this site
More questions
- How do I get a second opinion from ChatGPT and Gemini inside Claude?
- What is an AI council, and when is it worth using one?
- What is LLM Council, and how can you use one inside Claude?
- Claude Code review: built-in skill, PR review, or a plugin that adds ChatGPT and Gemini?
- What does it cost to let ChatGPT, Gemini and Claude vote on a question?
- Does Kirat work in claude.ai, the Claude mobile app or Claude Code on the web?
- Claude Desktop vs Claude Code: what is the difference, and which one do you need?
- Where do my API keys and questions go when Claude asks ChatGPT and Gemini through Kirat?
- How do I install an MCP server in Claude Desktop or Claude Code?
- Kirat, llm-council or PAL MCP: which multi-model tool fits?
- How can I check an AI answer when I can't tell whether it is right?
- How reliable is ChatGPT, and when should you check its answers?
- Which AI is the best, and how do you choose one?
- Claude vs ChatGPT vs Gemini: which is better? Our test with the same 10 tasks
Terms in this answer: API key (bring your own) · Network secret