Home / Learn / How to get a Claude API key
Claude API keys. A carefully drawn key unlocking a doorway made from a code window.

How to get a Claude API key

You can get a Claude API key from Anthropic's Claude Console for direct API access, or create an AI Prime Tech account for access through this independent gateway. Choose your provider first: its key, billing and base URL must match. The steps below cover both routes and show how to check a gateway key before sending a first request.

Choose where to get your Claude API key

An API key identifies the account or project that pays for requests. A Claude chat login and an API key serve different purposes. If you want the chat interface or subscription features, compare Claude API access and subscriptions before buying API usage.

Route Where to create a key Billing and endpoint
Anthropic directClaude ConsoleAnthropic account and API billing; api.anthropic.com
AI Prime TechCreate an account, then open API Keys in the dashboardGateway credits or an eligible timed plan; aiprimetech.io

AI Prime Tech is independently operated and is not affiliated with or endorsed by Anthropic. Use the route that fits your integration, billing and support requirements; the accounts and keys are separate.

Get a key from the official Claude Console

  1. Sign in to the Claude Console and select the workspace you will use.
  2. Review the account's API billing and usage limits. Complete any setup the Console requires for your account.
  3. Open API keys, create a key for your application, and store it securely when it is displayed.
  4. Follow Anthropic's official quickstart for direct requests. Keep the official endpoint for this route; the gateway example below uses an AI Prime Tech key.

Create an AI Prime Tech key

  1. Register with AI Prime Tech and complete the verification shown during signup.
  2. Choose prepaid API credits for usage-based billing or review the timed Claude plans. Check the current offer, eligible models and limits before paying. If you want to evaluate the service first, the trial guide shows any current welcome offer and its conditions.
  3. Open API Keys in the dashboard and create a key for this application. Check the selected group and any key restrictions so they match the Claude access you purchased.
  4. Copy the key into a local environment variable or secret manager. Use a separate key for each application so you can identify usage and replace one key without changing every integration.

Key creation and payment do not prove an integration works. First check the model catalogue with that key, then make a small request to the model you intend to use.

Verify the key and available model IDs

On macOS, Linux or WSL, set your gateway key in the current terminal. Replace the placeholder with your own key locally; keep it out of shared scripts and screenshots.

export ANTHROPIC_API_KEY="YOUR_GATEWAY_KEY"

On Windows PowerShell, use this environment-variable syntax:

$env:ANTHROPIC_API_KEY = "YOUR_GATEWAY_KEY"

Request the model list. This is a catalogue request; it does not generate a model response. The following command is for a Bash-compatible shell:

curl --fail-with-body --silent --show-error \
  https://aiprimetech.io/v1/models \
  -H "Authorization: Bearer $ANTHROPIC_API_KEY"

For PowerShell:

$headers = @{ Authorization = "Bearer $env:ANTHROPIC_API_KEY" }
(Invoke-RestMethod "https://aiprimetech.io/v1/models" -Headers $headers).data | Select-Object id

A successful response lists model IDs available to the key. Choose a Claude model and copy its id exactly into CLAUDE_MODEL. Model access can depend on the key's group and permissions; a catalogue response alone does not guarantee that an upstream model will complete a request.

export CLAUDE_MODEL="PASTE_A_CLAUDE_MODEL_ID_FROM_THE_RESPONSE"
# PowerShell alternative:
# $env:CLAUDE_MODEL = "PASTE_A_CLAUDE_MODEL_ID_FROM_THE_RESPONSE"

Before connecting an agent, confirm the key uses the group for your chosen access. The agent setup checklist connects that check to the appropriate tool guide.

Make your first Python request

Install the Anthropic Python SDK in your project's environment, save the example as test_claude.py, and run it from the terminal where you set the key and model. This request uses your selected model and is subject to your account's billing or plan.

python -m pip install anthropic
test_claude.py
import os
import anthropic

# Set CLAUDE_MODEL to an exact Claude model ID returned for your key.
client = anthropic.Anthropic(
    api_key=os.environ["ANTHROPIC_API_KEY"],
    base_url="https://aiprimetech.io",
)
message = client.messages.create(
    model=os.environ["CLAUDE_MODEL"],
    max_tokens=64,
    messages=[{"role": "user", "content": "Reply with hello."}],
)
for block in message.content:
    if block.type == "text":
        print(block.text)
python test_claude.py

For this SDK, the gateway base URL is https://aiprimetech.io without /v1; the SDK constructs the Messages API path. Clients using the OpenAI-compatible format generally use https://aiprimetech.io/v1. See the Anthropic Python SDK guide or OpenAI-compatible API guide for the format your application needs.

After the response arrives, check the dashboard's request and usage details. For the CLI, continue with Claude Code API key setup; for an IDE, follow the Cursor guide.

If your Claude API key does not work

Symptom What to check
401 or API_KEY_REQUIREDConfirm the environment variable is set in this terminal and the request sends the key to its issuing provider.
403 or access deniedCheck the key's status, selected group, account permissions and requested model.
Model not found or unsupported modelCopy the exact ID from your key's model list. If it is listed but still fails, contact support with the request error and ID, without the key.
Insufficient balance or no eligible planCheck the dashboard balance, plan period and the key's access group.
404 or an HTML responseCheck the hostname, API format and path. Do not duplicate /v1 when a client adds it itself.
429, 500 or 529Inspect the response, reduce concurrency where needed and follow the API error guide.

Where to find and manage your key

Open API Keys in the dashboard of the provider that issued the key. Follow its available copy, reveal and revoke controls. If you cannot retrieve a usable secret, create a replacement and revoke the old key after updating your application.

Keep keys out of source control, public issues and browser-side JavaScript. If a key is exposed, replace it and review its usage. A browser session cookie is not a substitute for an API key.

Is a Claude API key free?

Creating a key and paying for model usage are separate steps. Anthropic's current account terms are shown in its Console. On AI Prime Tech, the trial guide shows any available welcome offer; the top-up page and plans page show the ongoing paid options.

Check eligibility and the offer shown at signup. A temporary credit or trial does not provide indefinitely free usage.

Frequently asked questions

How do I get a Claude API key?
Create a key in the Claude Console for direct Anthropic access, or register with AI Prime Tech, choose the appropriate gateway access and create a key in the dashboard. Use the endpoint belonging to the provider that issued it.
Where do I find my Claude API key?
Open API Keys in the issuing provider's dashboard and use its available key-management controls. Store the secret securely; if you cannot recover it, create a replacement and revoke the old key.
Can I get a free Claude API key?
Key creation does not by itself fund API requests. Check the issuing provider's current terms. AI Prime Tech's trial guide lists any current welcome offer and conditions.
Does a Claude Pro or Max subscription pay for this gateway?
No. AI Prime Tech has its own account, keys and billing. Review API access versus subscriptions to choose the product you need.
Which model ID should I use?
Request GET /v1/models with your gateway key and choose an exact Claude model ID returned for that key. Complete a small Messages request to verify that the model works with your access.
Start using Claude in minutes

Get an API key — no Anthropic account or waitlist required.

Get your API key

AI Prime Tech is an independent API gateway. It is not affiliated with, endorsed by, or a reseller of Anthropic. Claude and related model names are trademarks of their respective owners.

More Claude API guides

Claude API Pricing, ExplainedThe Cheapest Way to Use the Claude APIUnlimited Cursor with the Claude APIUnlimited Claude Code AccessClaude API Gateway vs. Anthropic DirectUse Claude with the OpenAI SDK: OpenAI-compatible endpoint, streaming, tools and limitsClaude models explained: a Claude model comparison of Claude Opus vs Sonnet vs Haiku vs Fable — all Claude API models, Anthropic model names and prices (2026)Paying for the Claude API with CryptoClaude API Access Without a WaitlistHow to Reduce Claude Token UsageUnlimited Cline with the Claude APIUnlimited Roo Code with the Claude APIUnlimited Claude in JetBrains IDEsAider with Claude through a gateway: ANTHROPIC_API_BASE, config files, architect mode and fixesUnlimited Claude in VS CodeOpenCode config for Claude: opencode.json setup, models and common errorsHermes Agent with Claude through a gateway: custom provider setup, cost controls and fixesRunning Unlimited OpenClaw on ClaudeWhat an Anthropic-Compatible API MeansClaude Code API key — ANTHROPIC_API_KEY: how to get it, set it up, and when to use claude setup-token insteadClaude Code API Costs — Pricing and How to Cut ThemClaude API errors explained: server error 500, overloaded 529, rate limit 429, bad request 400 — and the fix for eachHow to buy Claude API creditsClaude free API: is there a free Claude API key, and what is actually free in 2026?Claude API vs Claude Pro/Max Subscription — Which to ChooseCodex CLI with a custom provider: config.toml, GPT and Claude models, IDE extension and fixesConnecting Claude to n8nRouting LiteLLM to ClaudeUsing Claude in Kilo CodeGitHub Copilot Chat with Claude through a gateway: Custom Endpoint setup, agent mode and fixesWire Zed to Claude Through the GatewayConnect Cherry Studio to ClaudeChatAnthropic in LangChain: import, base_url, streaming, tools and errorsAnthropic Python SDK: install, set base_url, stream, and handle errorsClaude with the Vercel AI SDK: createAnthropic baseURL, streaming and fixesRun Factory Droid on ClaudeThe Claude Code API, ExplainedIntegrating the Claude API Into Your ApplicationHow to get unlimited Claude usageWhat unlimited Claude API access means