Key takeaways
- The Claude API takes a model name, system prompt and messages, and returns Claude's response, billed per input and output token.
- Create and copy API keys in the Anthropic Console; store them in environment variables, never in front-end code.
- The API is paid separately from Claude Pro; rate limits rise with usage tiers.
- Anthropic's commercial terms say API data is not used to train models by default.
- The API reads PDFs, supports MCP servers and tool use, and its key can be added to tools like Cursor.
The Claude API lets developers send messages to Anthropic's Claude models from their own code: you choose a model, provide a system prompt and conversation messages, optionally define tools, and receive Claude's reply, paying per token processed. It powers chatbots, document analysis, coding tools and agents. I build AI products with multiple providers and fallbacks, so this page covers how the API works, keys, payment, rates and tokens, Pro versus API, data use, PDFs, MCP, and using your key in Cursor.
How does the Claude API work?
You send an HTTPS request to the Messages endpoint with your API key, a model name, a maximum output length, an optional system prompt and a list of messages. Claude returns a response containing content blocks, such as text or tool calls, plus token usage.
Also asked as: how claude api works
import anthropic
client = anthropic.Anthropic() # reads ANTHROPIC_API_KEY from the environment
msg = client.messages.create(model="claude-sonnet-4-5", max_tokens=500,
messages=[{"role": "user", "content": "Explain RAG in two sentences."}])
print(msg.content[0].text)
The API is stateless: send the conversation history with each request. Features include streaming, tool use, vision, PDF input, prompt caching, batch processing and extended thinking. Check the documentation for current model names.
How do I find my Claude API key?
Sign in to the Anthropic Console, open the API keys section, and create a new key. Copy it immediately, because it is shown only once, and store it in an environment variable or a secrets manager.
Also asked as: how to find claude api key
If you lose a key, create a new one and delete the old one. Use separate keys for development and production, and for different applications, so you can revoke one without breaking others. Never commit keys to git, paste them into front-end code, or share them in screenshots. If a key leaks, revoke it in the Console right away and check usage for unexpected activity.
Is the Claude API paid?
Yes. The Claude API is billed by usage: you pay for input and output tokens, with prices varying by model. New accounts may receive limited free credits for testing depending on current offers, and you add credits or set up billing to continue.
Also asked as: is claude api paid
Costs depend on model choice, prompt length, output length and volume. Reduce them by choosing smaller models for simple tasks, keeping prompts concise, using prompt caching for repeated context, using the batch API for non-urgent jobs, and limiting maximum output tokens. Set spending limits and alerts in the Console. Check Anthropic's pricing page for current rates.
What are the Claude API rates and limits?
"Rates" can mean prices or rate limits. Prices are charged per million input and output tokens per model, with larger models costing more. Rate limits cap requests and tokens per minute, and they increase as your account moves up usage tiers.
Also asked as: what are claude api rates
When you exceed a rate limit, the API returns a 429 error with headers indicating when to retry. Handle it with exponential backoff, spread requests over time, and batch work where possible. Higher tiers come with sustained usage and payment history. For high-volume production, contact Anthropic or use cloud platforms such as Amazon Bedrock or Google Cloud, which have their own quotas.
What is a token in the Claude API?
A token is a chunk of text, often part of a word, that the model processes. Billing, context limits and rate limits are all measured in tokens: input tokens for everything you send, and output tokens for what Claude generates.
Also asked as: what is claude api token
As a rough guide, one English token is about three to four characters, so a page of text might be several hundred tokens; other languages and code tokenise differently. The API returns exact usage with each response, and a token-counting endpoint estimates costs before sending. Long conversations grow input tokens every turn, since history is resent, which is why summarising or trimming history saves money.
Can I use the Claude API with a Pro subscription?
No, the API is billed separately. A Claude Pro subscription covers the Claude apps, not API usage, so you need API credits or billing in the Anthropic Console for developer access.
Also asked as: can i use claude api with pro
Some Anthropic tools can use your subscription instead of API billing; for example, Claude Code can be used with Pro or Max plans, within their usage limits. For building your own applications, though, the API with its own billing is required. Keep personal subscription use and application API use separate, which also helps track costs per project.
Does the Claude API train on your data?
According to Anthropic's commercial terms, data sent through the API is not used to train its models by default. Anthropic retains API data for a limited period for safety and abuse monitoring, with options such as zero data retention for eligible enterprise customers.
Also asked as: does claude api train on your data
Always review the current terms and privacy documentation, since policies can change, and consumer apps have different settings from the API. For sensitive data, minimise what you send, redact personal information where possible, and check compliance needs such as data residency. Cloud platforms offering Claude, such as Amazon Bedrock, also have their own data handling terms.
Can the Claude API read PDFs?
Yes. You can send PDFs directly as document content blocks, either base64-encoded or by URL or file reference, and Claude reads both the text and visual elements such as charts and tables on each page, then answers questions or extracts data.
Also asked as: can claude api read pdf
PDF limits apply on size and page count per request, and each page uses tokens for both text and images. For large document collections, a RAG pipeline that retrieves relevant pages is more efficient than sending entire PDFs every time. Enable citations to have Claude point to the passages it used, which is how document question answering stays verifiable.
Can the Claude API use MCP?
Yes. The API's MCP connector lets you specify remote MCP servers in a request, so Claude can call their tools directly, and the Claude Agent SDK and Claude apps support MCP servers too. You can also convert MCP tools into standard tool definitions in your own code.
Also asked as: can claude api use mcp
MCP, the Model Context Protocol, standardises how AI applications connect to tools and data sources, such as GitHub, databases or internal services. Only connect trusted servers, scope their permissions narrowly, and review which tools Claude can call, because tool results can contain malicious instructions in prompt-injection attacks.
Can I use my Claude API key in Cursor?
Yes. Cursor's settings let you add your own Anthropic API key so requests to Claude models are billed to your Anthropic account instead of Cursor's included usage, subject to Cursor's current options for custom keys.
Also asked as: can i use claude api key in cursor
Using your own key can be useful for higher limits or cost tracking, but some Cursor features may only work with its built-in models. Keep the key secure, monitor usage in the Anthropic Console, and remove it if you stop using it. Similar options exist in other tools, such as Continue and Cline, which let you choose Claude models with your own API key.





