How to Get an Anthropic API Key: A Step-by-Step Guide
On this page
In this guide, you'll learn how to get your Anthropic API key. You'll create an Anthropic account, generate your key, and make your first API call. We'll also show you a simpler alternative if you want access to hundreds of AI models without managing multiple accounts.
Prerequisites
- An email address (or a Google account for single sign-on)
- A payment method — Anthropic's API is usage-based
- Basic familiarity with code (we'll show simple JavaScript examples)
Step 1: Create Your Anthropic Account
Go to platform.anthropic.com. This is the API platform where you manage your keys, billing, and usage.
Click Sign up and create your account using your email or Google SSO. Once you're in, you'll land on the dashboard.
Before your API key will work, you need to add a payment method. Go to Settings → Billing and add a credit card. Anthropic charges per token, and pricing varies by model. Set a monthly spending limit here to avoid surprises — you can always increase it later.
Step 2: Generate Your API Key
In the left sidebar, click API Keys, then click Create Key.
Give your key a descriptive name like my-app-dev so you can identify it later, then click Create Key.
Important: Copy the key immediately. Anthropic only shows it once. If you lose it, you'll need to generate a new one.
Store it somewhere safe — a password manager, an .env file, or your platform's secrets manager. Never commit API keys to a public repository.
Step 3: Make Your First API Call
Now you're ready to use the key. Here's a quick example using the Anthropic JavaScript SDK:
npm install @anthropic-ai/sdk
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
});
const response = await client.messages.create({
model: "claude-sonnet-4-6",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello, world!" }],
});
console.log(response);
If you get a response back, everything is working.
One API Key, Hundreds of Models
The process above works well for Anthropic specifically — but what happens when you want to use GPT, Gemini, Llama, Mistral, or any of the other major models?
You'd need to repeat the entire process for each provider: create an account, set up billing, generate and manage a separate key. That's a lot of overhead, especially if you're experimenting or building something that uses multiple models.
Puter offers a simpler approach: one account, one auth token, access to hundreds of models across providers.
Instead of managing five different API dashboards, you point your existing code to Puter's OpenAI-compatible endpoint and use your Puter auth token:
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.puter.com/puterai/openai/v1/",
apiKey: "YOUR_PUTER_AUTH_TOKEN",
});
const response = await client.chat.completions.create({
model: "claude-sonnet-4-6", // or gpt-5-nano, gemini-2.5-flash-lite, llama, etc.
messages: [{ role: "user", content: "Hello, world!" }],
});
console.log(response.choices[0].message.content);
The request is conceptually similar — you still specify a model and messages — but this example uses the OpenAI-compatible SDK shape (client.chat.completions.create) rather than the Anthropic SDK. When using the OpenAI SDK with Puter, you mainly change the baseURL, your API key, and the model string to switch between models.
To get your Puter auth token, create a free account at puter.com, then go to puter.com/dashboard and click Copy to grab your token.
Conclusion
You now know how to create an Anthropic account, generate an API key, and make your first API call. For a deeper dive, check out Anthropic's official API docs.
Related
Free, Serverless AI and Cloud
Start creating powerful web applications with Puter.js in seconds!
Get Started Now