Tech AI LabsAI Growth Infrastructure for Business

How to use the Anthropic API: Claude in your own product

By the Tech AI Labs teamChecked 22 November 20264 min read
How to use the Anthropic API: Claude in your own product: a practical workflow overview

The Anthropic API puts Claude - the model family behind claude.ai - inside your own software: support agents, document processing, analysis pipelines. This guide gets you from console signup to a first working request, with the cost controls to run it safely.

The short answer

Create a Console account, check API billing and store a workspace API key securely. Send a small Messages API request using an available model and an output-token limit. Inspect the content blocks and validate the result before it drives another action.

Step 1: Console, workspace and key

In the Anthropic Console, create a workspace for your project, then generate an API key. Store it immediately in a secrets manager or environment variable; keep its permissions restricted to the intended project or workspace.

Step 2: Your first request

Install the official SDK with pip install anthropic. Set ANTHROPIC_API_KEY securely and set ANTHROPIC_MODEL to a model available in your workspace. The client reads the API key from the environment:

python
import os
from anthropic import Anthropic

client = Anthropic()
message = client.messages.create(
    model=os.environ["ANTHROPIC_MODEL"],
    max_tokens=200,
    messages=[{"role": "user", "content": "Summarise this fictional note: please call me back."}]
)
for block in message.content:
    if block.type == "text":
        print(block.text)

This example follows the current Messages API shape but was not executed using paid API credits. A request can incur charges; check billing and model access before running it.

A bounded worked example with explicit source, task and rules.
Guide diagram: A bounded worked example with explicit source, task and rules.

Worked example, fictional data:

Step 3: Pick the right Claude size

The Claude family comes in tiers - a fast, cheap tier for high-volume simple tasks (Haiku), a balanced tier for most real work (Sonnet), and a top tier for the hardest reasoning (Opus). Route each workflow to the smallest tier that passes your quality bar; this one decision drives most of your bill.

Step 4: Use the features that cut cost and latency

Prompt caching reuses long repeated context (your system prompt, product docs) across calls at a fraction of the cost. Batch processing handles large offline jobs at a discount. Both are documented in the console and are the difference between a demo bill and a production bill.

Step 5: Build the safety rails before you need them

Validate every response before it touches a customer, set spend alerts in the console, log requests so you can audit quality, and keep a human approval step on outward-facing actions until the workflow has earned trust.

Pricing (checked 22 November 2026)

API usage is pay-as-you-go per million tokens, with rates varying by model tier; prompt caching and batch mode reduce effective cost. Current rates: https://www.anthropic.com/pricing

Try one bounded work task

Start with one fictional support note and ask for a short classification or summary. Validate the returned structure, record only the non-sensitive diagnostics you need, and keep the next external action under human review.

Example brief: Classify this fictional support note as billing, appointment or other. Return the chosen label and quote the words that support it. If the evidence is insufficient, choose other.

A source-to-claim check showing what is and is not supported.
Guide diagram: A source-to-claim check showing what is and is not supported.

Review the example:

Check the output before using it

Use a key scoped to the intended workspace, an available model and a bounded output limit. Inspect text blocks rather than assuming every response is a single string. Avoid logging keys or confidential request bodies.

Choose the right next tool

For adjacent tasks, read Claude chat if you do not need an integration, the OpenAI Responses API, an interactive ChatGPT workflow. These are different workflows, not a ranking of the tools.

Official reference

This guide uses the current official getting-started guidance. Features and account access can change. Check the provider before buying a plan or connecting business data.

FAQ

Quick answers

How do I get an Anthropic API key?

Sign up at console.anthropic.com, add billing, create a workspace and generate an API key. Store it securely - it is shown only once.

How is the Anthropic API billed?

Pay-as-you-go per million tokens, varying by model tier. Prompt caching and batch processing reduce effective costs.

Which Claude model tier should I start with?

Start with the balanced tier (Sonnet), drop to the fast tier (Haiku) for simple high-volume tasks, and reserve the top tier (Opus) for the hardest reasoning.

Which API endpoint is used here?

The example uses the Messages API at /v1/messages. The official quickstart shows the required model, max_tokens and messages fields.

What does max_tokens control?

It bounds the generated output token allowance for the request. It is not a total monthly spending limit.

Can I reuse my Claude chat subscription as API credit?

Do not assume that a chat subscription includes API usage. Check the billing terms for the intended Console account before running requests.

How should I read the result?

The response contains content blocks. Inspect their types and handle the text blocks you expect instead of assuming every result is one plain string.

Were these API requests run for this guide?

No. The examples were checked against documentation but not executed using paid API credits. Review model access and current billing before running them.

IN THE DIRECTORY

See how this tool compares, what it costs and what it is best for.

Open the tool page →
How to use Claude: a practical guide for real work: article illustration
TUTORIALS

How to use Claude: a practical guide for real work

Read →
How to use the OpenAI API: from key to first request: article illustration
TUTORIALS

How to use the OpenAI API: from key to first request

Read →
How to use ChatGPT: a practical guide for real work: article illustration
TUTORIALS

How to use ChatGPT: a practical guide for real work

Read →

Keep exploring

Move from research to a useful workflow. Check the source, learn the steps, then discuss implementation.

Discuss your workflow