What is a Claude API key, and how do you get and set up the Claude API?

A Claude API key lets your code call Claude models. How to get one in the Claude Console, how the API works and differs from claude.ai, and using it in VS Code.

Pranjul Rathour
Pranjul Rathour

Key takeaways

  • A Claude API key is a secret token that identifies your account when your code calls Claude; treat it like a password.
  • Create keys in the Claude Console, set the ANTHROPIC_API_KEY environment variable, and never commit the key to Git.
  • claude.ai is the chat product with a subscription; the API is pay-per-use for developers, billed separately.
  • Every API call is a Messages request: model, max tokens and a list of messages, with optional tools, images and streaming.
  • In VS Code, use Claude Code's extension or a coding extension that accepts an Anthropic key.

A Claude API key is a secret token that lets your own code call Claude models through Anthropic's API; requests made with it are billed to your developer account. You create keys in the Claude Console, store them in an environment variable, and use them with Anthropic's SDKs or plain HTTP. This page covers getting a key, the Console and developer platform, the docs, how the API differs from the claude.ai app, how a request works, setting it up in Python, using Claude in VS Code, and whether the API supports skills.

What is a Claude API key?

A Claude API key is a long secret string, beginning with sk-ant-, that authenticates requests to Anthropic's API. Anyone who has your key can make requests that are charged to your account, so it must be kept private.

Also asked as: what is claude api key

Keys belong to a workspace in your organisation in the Claude Console, so you can create separate keys for development and production, set spending limits per workspace, and revoke a key instantly if it leaks. A key is not your claude.ai login and does not give access to your chat history. Common leaks happen when keys are pasted into front-end JavaScript, committed to a public GitHub repository or shared in screenshots. Keep keys in environment variables or a secrets manager, and rotate any key you suspect has been exposed.

How do I get a Claude AI API key?

Sign up in the Claude Console, set up billing for your organisation, then open the API keys page and create a key. Copy it immediately; the Console shows the full key only once.

Also asked as: how to claude ai api key · claude ai vs claude api

The steps:

  • Sign in to the Console with your email or Google account.
  • Add billing details and purchase credits or set up payment, as the Console prompts.
  • Go to API keys and choose "Create key", giving it a clear name such as "college-project-dev".
  • Copy the key into a password manager or your project's .env file.

A claude.ai Pro or Max subscription does not include API credits; the two are billed separately. Students should set a low spending limit while learning, so a bug in a loop cannot run up a large bill.

Where is the Claude API Console?

The Claude Console, previously called the Anthropic Console, is Anthropic's web dashboard for developers, linked from the Claude developer documentation. It is where you create keys, manage billing, test prompts and see usage.

Also asked as: where is claude api console

Inside the Console you will find a Workbench for trying prompts and model settings before writing code, a prompt generator and improver, usage and cost dashboards, rate-limit information for your tier, and organisation settings for inviting teammates and creating workspaces. It is separate from claude.ai, even though you can use the same email for both. If a link or tutorial points to an old address, start from Anthropic's documentation site and follow the link to the Console from there.

What is the Claude API platform?

The Claude Developer Platform is Anthropic's set of services for building with Claude: the API itself, the Console, SDKs, documentation and features such as tool use, batch processing, prompt caching, files and agent tooling.

Also asked as: what is claude api platform

Building blocks you will meet:

  • Messages API: the core request for a model response.
  • Tool use: let Claude call your functions and APIs.
  • Message Batches: process large jobs asynchronously at lower cost.
  • Prompt caching: reuse long, repeated context cheaply and quickly.
  • Files API and PDF support: reuse uploaded documents.
  • Agent SDK and MCP: build agents and connect tools in a standard way.

Claude models are also available through cloud providers such as Amazon Bedrock and Google Cloud Vertex AI, which suits teams already on those clouds.

Where are the Claude API docs?

Anthropic's developer documentation covers getting started, every API endpoint, the SDKs, model details, pricing, rate limits and guides on prompting, tool use, retrieval and agents. It is linked from anthropic.com and the Console.

Also asked as: what are claude api docs

Read these first: the quickstart, the Messages API reference, the models overview for current model names, the guide to tool use, and the prompt engineering guide. The docs include runnable examples in Python and TypeScript, and an API reference with every parameter. When a blog post or video disagrees with the docs, trust the docs; model names and parameters change, and older tutorials go stale quickly.

What is the difference between Claude AI and the Claude API?

Claude AI usually means claude.ai, the chat product for people, with a free tier and subscriptions. The Claude API is the developer interface for building Claude into your own software, paid per token used.

The chat app gives you a ready interface, conversation history, projects, file uploads and apps on every device. The API gives you only the model: you send messages and get responses, and you build the interface, storage and logic yourself. Subscriptions and API credits are billed separately; a Pro plan does not cover API usage. Use claude.ai to learn, write and think; use the API when you want Claude inside a website, bot, app or automated workflow.

How does the Claude API work?

Your code sends an HTTPS request to the Messages endpoint with your API key, a model name, a maximum number of output tokens and a list of messages. Claude returns a response containing content blocks, a stop reason and token usage.

Also asked as: how does claude api work

Key ideas:

  • Stateless: the API does not remember earlier calls; send the conversation history you want it to consider each time.
  • System prompt: sets the role, rules and context for the whole conversation.
  • Tokens: you pay for input and output tokens, and limits apply per minute.
  • Streaming: receive the response as it is generated for a responsive UI.
  • Tools: describe functions with JSON schemas; Claude replies with a tool call, you run it and send the result back.

Errors come back with clear types, such as rate limits and temporary overload, which you handle with retries.

How do I set up the Claude API?

Install the SDK, set your key as an environment variable, and make a first request. In Python, that is three steps and about ten lines.

Also asked as: how to set up claude api

pip install anthropic
export ANTHROPIC_API_KEY="sk-ant-..."     # on Windows PowerShell: $env:ANTHROPIC_API_KEY="sk-ant-..."
from anthropic import Anthropic

client = Anthropic()
reply = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=400,
    messages=[{"role": "user", "content": "Give me three RAG project ideas for students."}],
)
print(reply.content[0].text)

For projects, keep the key in a .env file loaded at startup and add .env to .gitignore. Check the models overview for the current model names.

How do I use the Claude API in VS Code?

The simplest route is Claude Code's VS Code extension, which brings Claude's coding agent into the editor. Alternatively, coding extensions that support multiple providers let you paste an Anthropic API key and choose a Claude model.

Also asked as: vs code claude api

With Claude Code, you install it, sign in with your Claude account or use an API key, and work with it in the editor: it reads your project, proposes edits shown as diffs and runs commands with your approval. Third-party extensions such as open-source coding assistants also accept Anthropic keys and bill usage to your API account. Whichever you use, set a spending limit in the Console, keep the key out of your settings files that get committed, and review every change before accepting it.

Can the Claude API use skills?

Yes. Agent Skills, packaged folders of instructions, scripts and resources that Claude loads when relevant, can be used through the Claude API together with its code execution tool, as well as in Claude Code and the Claude apps.

Also asked as: can claude api use skills

Anthropic provides some prebuilt skills, for example for working with document formats, and you can upload custom skills for your organisation, such as your report template or data-cleaning procedure. Claude sees a short description of each available skill and loads the full contents only when a task needs it, which keeps context small. Because this feature is newer and its request format may change, follow the current skills guide in the API documentation for the exact parameters, and test custom skills on small tasks first.

Sources

  1. Anthropic, Claude API documentationdocs.anthropic.com
  2. Anthropic, Client SDKsdocs.anthropic.com
  3. Anthropic, Claude Code overviewdocs.anthropic.com
  4. Anthropic, Claude Consoleconsole.anthropic.com
Pranjul Rathour
Pranjul Rathour
GenAI Engineer · India

GenAI engineer and AI product builder with 2+ years shipping production-grade AI systems: RAG pipelines, fine-tuned LLMs, hybrid retrieval and multi-modal apps across vision, speech and OCR, architected end to end from ingestion to deployment. Leads engineering for SCULT INDIA's 14-member team, founded the 500+ member TechVerse Enclave community and has mentored 200+ students. Three hackathon first prizes: Changethon 2025 (IIT Roorkee), Product Genesis at Vividhotsava 2025 (CSJMU) and BYTEBATTLE (MeetKats).

Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges. For campus sessions the inviting institution covers the visit end to end: travel (a First AC train ticket for journeys up to five hours, a flight for anything longer), accommodation, meals, and pickup and drop; the honorarium and workshop fees are negotiable on WhatsApp or on the call, and requests are welcome from institutions that can cover the visit this way. Email pranjulrathour41@gmail.com.

Keep reading

More on Shipping AI apps

All Shipping AI apps guides →
Campus talks · hackathon judging · mentoring

Want this as a live session at your college?

Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges. For campus sessions the inviting institution covers the visit end to end: travel (a First AC train ticket for journeys up to five hours, a flight for anything longer), accommodation, meals, and pickup and drop; the honorarium and workshop fees are negotiable on WhatsApp or on the call, and requests are welcome from institutions that can cover the visit this way.

Pranjul Rathour, GenAI engineer in India