API Keys Explained: How to Set Up AI Providers Securely

A clear guide to understanding API keys, setting them up for AI services, and keeping them secure.

API Keys Demystified: What They Are and Why You Need Them

If you've tried to use an AI tool beyond the basic free tier, you've probably encountered the term "API key." For many people, this is where enthusiasm meets confusion. What is it? Where do you get one? Is it safe? How much will it cost?

This guide answers all of those questions in plain language, walks you through setup for every major AI provider, and covers the security practices that protect your account and wallet.

What Is an API Key, Exactly?

An API key is a unique string of characters — something like sk-proj-abc123def456ghi789... — that acts as your identity when software communicates with an AI service.

Think of it this way: when you visit chatgpt.com and log in with your email and password, OpenAI knows who you are. But when a third-party application (like Cognito) wants to use OpenAI's AI on your behalf, it can't log in with your credentials. Instead, it uses your API key — a secure token that says "this request comes from an authorized user."

What an API Key Does

Authentication: Proves you have a valid account with the provider. Without a valid key, requests are rejected.

Billing: Every AI request costs the provider computing resources. The API key links requests to your billing account, so you only pay for what you use.

Rate Limiting: Providers impose limits (requests per minute, tokens per day) to prevent abuse and ensure fair access. Your API key tracks your usage against these limits.

Access Control: Different keys can have different permissions. You might create a read-only key for one application and a full-access key for another.

API Key vs. Subscription

This is a common source of confusion:

| | ChatGPT Plus Subscription | API Key | |---|:---:|:---:| | What it is | Monthly subscription ($20/mo) | Pay-per-use access | | Used for | chatgpt.com website | Third-party apps and tools | | Billing | Flat monthly fee | Per-token usage | | Typical cost | $20/month fixed | $1-10/month for most users | | Accessed via | Browser login | API key string | | Separate account? | Uses your regular account | Same account, but separate billing |

Important: A ChatGPT Plus subscription does not give you API access. You need to separately add billing to your API account at platform.openai.com.

Getting API Keys: Step-by-Step for Every Major Provider

OpenAI (GPT-4o, GPT-4, GPT-3.5)

Go to platform.openai.com (not chatgpt.com — they're different) Sign up or sign in with your OpenAI account Navigate to Settings → Billing and add a payment method Set a monthly spending limit (strongly recommended — start with $10) Go to API Keys in the left sidebar Click "Create new secret key" Give it a descriptive name (e.g., "Cognito Browser Extension") Copy the key immediately — you won't be able to see it again Store it securely (password manager recommended)

Pricing (2026 estimates): GPT-4o: ~$2.50 per 1M input tokens, ~$10 per 1M output tokens GPT-4o Mini: ~$0.15 per 1M input tokens, ~$0.60 per 1M output tokens GPT-3.5 Turbo: ~$0.50 per 1M input tokens, ~$1.50 per 1M output tokens

In plain English: A typical conversation costs $0.001-$0.01. Most casual users spend $1-5 per month.

Anthropic (Claude Opus, Sonnet, Haiku)

Go to console.anthropic.com Create an account or sign in Navigate to Billing and add a payment method Set a spending limit Go to API Keys Click "Create Key" Name it and copy it immediately

Pricing (2026 estimates): Claude Opus: ~$15 per 1M input, ~$75 per 1M output (premium model) Claude Sonnet: ~$3 per 1M input, ~$15 per 1M output (best value) Claude Haiku: ~$0.25 per 1M input, ~$1.25 per 1M output (budget-friendly)

Google (Gemini Pro, Flash, Ultra)

Go to aistudio.google.com Sign in with your Google account Click "Get API key" in the left sidebar Create a key in a new or existing Google Cloud project Copy the key

Pricing: Gemini offers a generous free tier. Gemini Flash is extremely cost-effective for lighter tasks.

OpenRouter (Access Multiple Providers)

OpenRouter is a meta-provider that gives you access to models from OpenAI, Anthropic, Google, Meta, and others through a single API key.

Go to openrouter.ai Create an account Add credits to your balance Copy your API key from the dashboard In Cognito, select OpenRouter as your provider

Advantage: One key, many models. Switch between GPT-4, Claude, Llama, and others without managing separate accounts.

Using API Keys with Cognito

Setting up your API key in Cognito takes about 30 seconds:

Click the Cognito extension icon in your browser Open Settings (gear icon) Select your AI Provider from the dropdown Paste your API key in the designated field Choose your preferred model Click Save

Critical security note: Your API key is stored locally in your browser — in Chrome's secure extension storage. Cognito never transmits your key to Cognito's servers. The key is used exclusively to make direct API calls from your browser to the AI provider.

Security Best Practices

API keys are credentials. Treat them with the same care as passwords.

Essential Security Rules

Never share API keys publicly: Don't post them in forums, GitHub repos, tweets, screenshots, or public documents. Automated bots scan for exposed API keys and can rack up hundreds of dollars in charges within minutes.

Set spending limits immediately: Every provider offers budget caps. Set them before using the key. Start low ($5-10/month) and increase as needed.

Use one key per application: Create a separate key for each tool you use. If one key is compromised, you can revoke it without affecting your other tools.

Monitor usage regularly: Check your provider's usage dashboard weekly. Unexpected spikes can indicate a compromised key.

Rotate keys periodically: Every 3-6 months, create a new key and delete the old one. This limits the damage window if a key is compromised without your knowledge.

Store keys in a password manager: Don't keep them in plain text files, sticky notes, or unencrypted documents. Use 1Password, Bitwarden, or similar tools.

What to Do If a Key Is Compromised

Immediately revoke/delete the key in your provider's dashboard Create a new key Check your billing for unauthorized usage Contact the provider's support if you see charges you didn't make Update the key in all applications that use it

The Free Alternative: Ollama (No API Key Required)

If you want to avoid API keys entirely — whether for privacy, cost, or simplicity — Ollama lets you run AI models locally.

Setup: Install Ollama from ollama.com Run ollama pull llama3.1 in your terminal In Cognito settings, select Ollama as your provider No API key needed — everything runs on your machine

Trade-offs: Free and completely private Requires decent hardware (8GB+ RAM for small models) Quality varies by model — local models are good but not quite GPT-4 level No internet required after initial model download

Best for: Privacy-sensitive work, offline use, avoiding recurring costs, experimentation.

Cost Optimization Strategies

Model Selection by Task

You don't need GPT-4 for everything. Match the model to the task:

| Task Complexity | Recommended Model | Approximate Cost | |----------------|------------------|:---:| | Quick questions, simple formatting | GPT-4o Mini or Haiku | ~$0.001/query | | Standard summarization and writing | Sonnet or GPT-4o | ~$0.005/query | | Complex analysis and reasoning | Opus or GPT-4 | ~$0.02/query | | Private/sensitive content | Ollama (local) | Free |

Practical Monthly Budgets

| Usage Level | Description | Estimated Monthly Cost | |-------------|------------|:---:| | Light | 10-20 queries/day, simple tasks | $1-3 | | Moderate | 30-50 queries/day, mixed tasks | $5-10 | | Heavy | 100+ queries/day, complex tasks | $15-30 | | Power user | All-day usage, long documents | $30-50 |

Cost-Saving Tips

Start conversations with context: Include relevant information upfront instead of going back and forth (fewer tokens) Use cheaper models for simple tasks: GPT-4o Mini is 20x cheaper than GPT-4 and handles most simple tasks well Use local models for experimentation: Test prompts with Ollama before sending them to paid APIs Monitor weekly: Check your usage dashboard every week to catch unexpected costs early Set alerts: Most providers let you configure email alerts at spending thresholds

Frequently Asked Questions

Q: Can someone use my API key if they get it? Yes. An API key is like a credit card number — anyone who has it can make charges to your account. This is why spending limits and key rotation are essential.

Q: Is my data safe when using an API key with Cognito? Your data goes directly from your browser to the AI provider (e.g., OpenAI's servers). Cognito never sees, stores, or routes your data through its own servers. With Ollama, data never leaves your machine at all.

Q: Do I need a different API key for each AI model? No. One API key per provider gives you access to all of that provider's models. For example, one OpenAI key works for GPT-4, GPT-4o Mini, and GPT-3.5.

Q: What happens if I hit my spending limit? API requests will fail with an error. Cognito will show you a message indicating the issue. You can increase your limit in the provider's billing dashboard.

Q: Can I use Cognito without any API key? Yes — use Ollama as your provider for completely free, local AI with no API key required.

---

Related Reading

Local AI with Ollama Privacy-First AI ChatGPT vs Claude vs Gemini

Resources

OpenAI API Documentation Anthropic API Documentation

Running AI Locally with Ollama: A Complete GuidePrompt Engineering: How to Get Better Answers from AIAI Summarization: How to Instantly Digest Any Content
Cognito AI
Cognito AI
HomeFeaturesPricingContactDocumentationBlogs
HomeFeaturesPricingContactDocumentationBlogs
  1. Home
  2. Blog
  3. API Keys Explained: How to Set Up AI Providers Securely

API Keys Explained: How to Set Up AI Providers Securely

A clear guide to understanding API keys, setting them up for AI services, and keeping them secure.

Cognito AI
Cognito Team
7 min read·Feb 2, 2026
API Keys Explained: How to Set Up AI Providers Securely

API Keys Demystified: What They Are and Why You Need Them

If you've tried to use an AI tool beyond the basic free tier, you've probably encountered the term "API key." For many people, this is where enthusiasm meets confusion. What is it? Where do you get one? Is it safe? How much will it cost?

This guide answers all of those questions in plain language, walks you through setup for every major AI provider, and covers the security practices that protect your account and wallet.

What Is an API Key, Exactly?

An API key is a unique string of characters — something like sk-proj-abc123def456ghi789... — that acts as your identity when software communicates with an AI service.

Think of it this way: when you visit chatgpt.com and log in with your email and password, OpenAI knows who you are. But when a third-party application (like Cognito) wants to use OpenAI's AI on your behalf, it can't log in with your credentials. Instead, it uses your API key — a secure token that says "this request comes from an authorized user."

What an API Key Does

Authentication: Proves you have a valid account with the provider. Without a valid key, requests are rejected.

Billing: Every AI request costs the provider computing resources. The API key links requests to your billing account, so you only pay for what you use.

Rate Limiting: Providers impose limits (requests per minute, tokens per day) to prevent abuse and ensure fair access. Your API key tracks your usage against these limits.

Access Control: Different keys can have different permissions. You might create a read-only key for one application and a full-access key for another.

API Key vs. Subscription

This is a common source of confusion:

ChatGPT Plus SubscriptionAPI Key
What it isMonthly subscription ($20/mo)Pay-per-use access
Used forchatgpt.com websiteThird-party apps and tools
BillingFlat monthly feePer-token usage
Typical cost$20/month fixed$1-10/month for most users
Accessed viaBrowser loginAPI key string
Separate account?Uses your regular accountSame account, but separate billing

Important: A ChatGPT Plus subscription does not give you API access. You need to separately add billing to your API account at platform.openai.com.

Getting API Keys: Step-by-Step for Every Major Provider

OpenAI (GPT-4o, GPT-4, GPT-3.5)

  1. Go to platform.openai.com (not chatgpt.com — they're different)
  2. Sign up or sign in with your OpenAI account
  3. Navigate to Settings → Billing and add a payment method
  4. Set a monthly spending limit (strongly recommended — start with $10)
  5. Go to API Keys in the left sidebar
  6. Click "Create new secret key"
  7. Give it a descriptive name (e.g., "Cognito Browser Extension")
  8. Copy the key immediately — you won't be able to see it again
  9. Store it securely (password manager recommended)

Pricing (2026 estimates):

  • GPT-4o: ~$2.50 per 1M input tokens, ~$10 per 1M output tokens
  • GPT-4o Mini: ~$0.15 per 1M input tokens, ~$0.60 per 1M output tokens
  • GPT-3.5 Turbo: ~$0.50 per 1M input tokens, ~$1.50 per 1M output tokens

In plain English: A typical conversation costs $0.001-$0.01. Most casual users spend $1-5 per month.

Anthropic (Claude Opus, Sonnet, Haiku)

  1. Go to console.anthropic.com
  2. Create an account or sign in
  3. Navigate to Billing and add a payment method
  4. Set a spending limit
  5. Go to API Keys
  6. Click "Create Key"
  7. Name it and copy it immediately

Pricing (2026 estimates):

  • Claude Opus: ~$15 per 1M input, ~$75 per 1M output (premium model)
  • Claude Sonnet: ~$3 per 1M input, ~$15 per 1M output (best value)
  • Claude Haiku: ~$0.25 per 1M input, ~$1.25 per 1M output (budget-friendly)

Google (Gemini Pro, Flash, Ultra)

  1. Go to aistudio.google.com
  2. Sign in with your Google account
  3. Click "Get API key" in the left sidebar
  4. Create a key in a new or existing Google Cloud project
  5. Copy the key

Pricing: Gemini offers a generous free tier. Gemini Flash is extremely cost-effective for lighter tasks.

OpenRouter (Access Multiple Providers)

OpenRouter is a meta-provider that gives you access to models from OpenAI, Anthropic, Google, Meta, and others through a single API key.

  1. Go to openrouter.ai
  2. Create an account
  3. Add credits to your balance
  4. Copy your API key from the dashboard
  5. In Cognito, select OpenRouter as your provider

Advantage: One key, many models. Switch between GPT-4, Claude, Llama, and others without managing separate accounts.

Using API Keys with Cognito

Setting up your API key in Cognito takes about 30 seconds:

  1. Click the Cognito extension icon in your browser
  2. Open Settings (gear icon)
  3. Select your AI Provider from the dropdown
  4. Paste your API key in the designated field
  5. Choose your preferred model
  6. Click Save

Critical security note: Your API key is stored locally in your browser — in Chrome's secure extension storage. Cognito never transmits your key to Cognito's servers. The key is used exclusively to make direct API calls from your browser to the AI provider.

Security Best Practices

API keys are credentials. Treat them with the same care as passwords.

Essential Security Rules

1. Never share API keys publicly: Don't post them in forums, GitHub repos, tweets, screenshots, or public documents. Automated bots scan for exposed API keys and can rack up hundreds of dollars in charges within minutes.

2. Set spending limits immediately: Every provider offers budget caps. Set them before using the key. Start low ($5-10/month) and increase as needed.

3. Use one key per application: Create a separate key for each tool you use. If one key is compromised, you can revoke it without affecting your other tools.

4. Monitor usage regularly: Check your provider's usage dashboard weekly. Unexpected spikes can indicate a compromised key.

5. Rotate keys periodically: Every 3-6 months, create a new key and delete the old one. This limits the damage window if a key is compromised without your knowledge.

6. Store keys in a password manager: Don't keep them in plain text files, sticky notes, or unencrypted documents. Use 1Password, Bitwarden, or similar tools.

What to Do If a Key Is Compromised

  1. Immediately revoke/delete the key in your provider's dashboard
  2. Create a new key
  3. Check your billing for unauthorized usage
  4. Contact the provider's support if you see charges you didn't make
  5. Update the key in all applications that use it

The Free Alternative: Ollama (No API Key Required)

If you want to avoid API keys entirely — whether for privacy, cost, or simplicity — Ollama lets you run AI models locally.

Setup:

  1. Install Ollama from ollama.com
  2. Run ollama pull llama3.1 in your terminal
  3. In Cognito settings, select Ollama as your provider
  4. No API key needed — everything runs on your machine

Trade-offs:

  • Free and completely private
  • Requires decent hardware (8GB+ RAM for small models)
  • Quality varies by model — local models are good but not quite GPT-4 level
  • No internet required after initial model download

Best for: Privacy-sensitive work, offline use, avoiding recurring costs, experimentation.

Cost Optimization Strategies

Model Selection by Task

You don't need GPT-4 for everything. Match the model to the task:

Task ComplexityRecommended ModelApproximate Cost
Quick questions, simple formattingGPT-4o Mini or Haiku~$0.001/query
Standard summarization and writingSonnet or GPT-4o~$0.005/query
Complex analysis and reasoningOpus or GPT-4~$0.02/query
Private/sensitive contentOllama (local)Free

Practical Monthly Budgets

Usage LevelDescriptionEstimated Monthly Cost
Light10-20 queries/day, simple tasks$1-3
Moderate30-50 queries/day, mixed tasks$5-10
Heavy100+ queries/day, complex tasks$15-30
Power userAll-day usage, long documents$30-50

Cost-Saving Tips

  • Start conversations with context: Include relevant information upfront instead of going back and forth (fewer tokens)
  • Use cheaper models for simple tasks: GPT-4o Mini is 20x cheaper than GPT-4 and handles most simple tasks well
  • Use local models for experimentation: Test prompts with Ollama before sending them to paid APIs
  • Monitor weekly: Check your usage dashboard every week to catch unexpected costs early
  • Set alerts: Most providers let you configure email alerts at spending thresholds

Frequently Asked Questions

Q: Can someone use my API key if they get it? Yes. An API key is like a credit card number — anyone who has it can make charges to your account. This is why spending limits and key rotation are essential.

Q: Is my data safe when using an API key with Cognito? Your data goes directly from your browser to the AI provider (e.g., OpenAI's servers). Cognito never sees, stores, or routes your data through its own servers. With Ollama, data never leaves your machine at all.

Q: Do I need a different API key for each AI model? No. One API key per provider gives you access to all of that provider's models. For example, one OpenAI key works for GPT-4, GPT-4o Mini, and GPT-3.5.

Q: What happens if I hit my spending limit? API requests will fail with an error. Cognito will show you a message indicating the issue. You can increase your limit in the provider's billing dashboard.

Q: Can I use Cognito without any API key? Yes — use Ollama as your provider for completely free, local AI with no API key required.


Related Reading

  • Local AI with Ollama
  • Privacy-First AI
  • ChatGPT vs Claude vs Gemini

Resources

  • OpenAI API Documentation
  • Anthropic API Documentation

Try Cognito AI — Free Chrome Extension

ChatGPT, Claude, Gemini & local models in your browser sidebar. No switching tabs.

ChromeAdd to Chrome — It's Free
API-keyssetupsecuritygetting-started

More from Cognito AI

Running AI Locally with Ollama: A Complete Guide
Cognito AIIn Tutorial by Cognito Team

Running AI Locally with Ollama: A Complete Guide

Learn how to run powerful AI models on your own machine with Ollama — zero cloud dependency, complete privacy, and surprisingly fast performance.

Mar 14, 2026·8 min read
Prompt Engineering: How to Get Better Answers from AI
Cognito AIIn Tutorial by Cognito Team

Prompt Engineering: How to Get Better Answers from AI

Master the art of prompt engineering with practical techniques that dramatically improve AI output quality — from zero-shot and chain-of-thought to role prompts and iterative refinement.

Feb 25, 2026·8 min read
AI Summarization: How to Instantly Digest Any Content
Cognito AIIn Tutorial by Cognito Team

AI Summarization: How to Instantly Digest Any Content

Learn how AI summarization works, the different techniques available, and how to get the best summaries from any content.

Feb 15, 2026·7 min read
Share this articleXLinkedInReddit

Free Weekly Newsletter

Get the AI Productivity Cheat Sheet

Join 1,000+ developers & knowledge workers. Every Tuesday: the best prompts, tools, and workflows to 10× your output with AI.

Previous7 Ways AI Transforms Your Web Browsing ExperienceNext AI Context Windows Explained: Why Size Matters
  • API Keys Demystified: What They Are and Why You Need Them
  • What Is an API Key, Exactly?
  • What an API Key Does
  • API Key vs. Subscription
  • Getting API Keys: Step-by-Step for Every Major Provider
  • OpenAI (GPT-4o, GPT-4, GPT-3.5)
  • Anthropic (Claude Opus, Sonnet, Haiku)
  • Google (Gemini Pro, Flash, Ultra)
  • OpenRouter (Access Multiple Providers)
  • Using API Keys with Cognito
  • Security Best Practices
  • Essential Security Rules
  • What to Do If a Key Is Compromised
  • The Free Alternative: Ollama (No API Key Required)
  • Cost Optimization Strategies
  • Model Selection by Task
  • Practical Monthly Budgets
  • Cost-Saving Tips
  • Frequently Asked Questions
Cognito AI

Cognito AI

Your AI Thinking Partner

Empowering conversations with advanced AI technology.

Product

  • Features
  • Pricing
  • Documentation
  • Blogs

Legal

  • Privacy Policy
  • Terms of Service
  • Refund Policy
  • Cookie Policy

Company

  • Blogs
  • Contact

© 2026 Cognito AI. All rights reserved.