# 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](/learn/claude-api-vs-subscription/) before buying API usage. | Route | Where to create a key | Billing and endpoint | | --- | --- | --- | | Anthropic direct | [Claude Console](https://platform.claude.com/) | Anthropic account and API billing; api.anthropic.com | | AI Prime Tech | [Create an account](/register), then open API Keys in the dashboard | Gateway 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](https://platform.claude.com/) 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](https://platform.claude.com/settings/keys), create a key for your application, and store it securely when it is displayed. 4. Follow Anthropic's [official quickstart](https://platform.claude.com/docs/en/get-started) 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](/register) and complete the verification shown during signup. 2. Choose [prepaid API credits](/topup/) for usage-based billing or review the [timed Claude plans](/plans/). Check the current offer, eligible models and limits before paying. If you want to evaluate the service first, the [trial guide](/learn/claude-api-free-trial/) 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. ```bash export ANTHROPIC_API_KEY="YOUR_GATEWAY_KEY" ``` On Windows PowerShell, use this environment-variable syntax: ```powershell $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: ```bash curl --fail-with-body --silent --show-error \ https://aiprimetech.io/v1/models \ -H "Authorization: Bearer $ANTHROPIC_API_KEY" ``` For PowerShell: ```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. ```bash 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](/agents/) 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. ```bash python -m pip install anthropic ``` ```python 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) ``` ```bash 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](/learn/anthropic-python-sdk/) or [OpenAI-compatible API guide](/learn/openai-compatible-claude-api/) 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](/learn/claude-code-api-key-setup/); for an IDE, follow the [Cursor guide](/learn/unlimited-cursor-claude-api/). ## If your Claude API key does not work | Symptom | What to check | | --- | --- | | 401 or API_KEY_REQUIRED | Confirm the environment variable is set in this terminal and the request sends the key to its issuing provider. | | 403 or access denied | Check the key's status, selected group, account permissions and requested model. | | Model not found or unsupported model | Copy 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 plan | Check the dashboard balance, plan period and the key's access group. | | 404 or an HTML response | Check the hostname, API format and path. Do not duplicate /v1 when a client adds it itself. | | 429, 500 or 529 | Inspect the response, reduce concurrency where needed and follow the [API error guide](/learn/claude-api-errors-troubleshooting/). | ## 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](/learn/claude-api-free-trial/) shows any available welcome offer; the [top-up page](/topup/) and [plans page](/plans/) show the ongoing paid options. Check eligibility and the offer shown at signup. A temporary credit or trial does not provide indefinitely free usage. ## FAQ ### How do I get a Claude API key? Create a key in the [Claude Console](https://platform.claude.com/settings/keys) for direct Anthropic access, or [register with AI Prime Tech](/register), 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](/learn/claude-api-free-trial/) 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](/learn/claude-api-vs-subscription/) 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. --- Source: https://aiprimetech.io/learn/how-to-get-a-claude-api-key/ Provider: AI Prime Tech — independent Anthropic-compatible API gateway (not affiliated with Anthropic).