You have a task Claude could handle, but connecting it to your workflow means dealing with keys, billing, and a request that looks suspiciously like code.
The awkward part is knowing whether everything is set up correctly before you leave an automation running. A failed request wastes time, and a working request on an uncontrolled loop can waste money. This walkthrough takes cat-carrier review notes through a first API call to an email teaser, with checks for the connection, output, and cost before you reuse it in a workflow.
Set Up Claude API Access
Create an account in the Claude Console. This is where you manage API access, credentials, and usage. Before buying credits, confirm that your location appears in Anthropic’s supported regions.
Next, check the Console’s billing page for an available credit balance.

Most organizations pay for API usage with prepaid credits. If you need to purchase some, I would leave auto-reload off during your first test. Auto-reload buys more credits when your balance falls below a threshold you choose.
You don’t need a Claude chat subscription to use the API. If you already have an eligible Max, Ultra, or Team subscription, you can claim included monthly API credits by linking a Console organization. Check that those credits have reached the organization you plan to use. Anthropic’s billing guidance explains both payment routes.
Create a separate workspace for testing. A workspace groups usage and access within your organization, so it gives this experiment its own boundary.

Set a small spending limit there, and check your account’s actual allowances. Two limits matter:
- Spending Limit: Controls how much you can spend.
- Rate Limit: Controls how quickly you can send requests and process tokens.
Tokens are the pieces of text the model reads and generates. Your prompt uses input tokens, and Claude’s response uses output tokens. A short answer still has an input cost because Claude must read the request first.
Anthropic’s limits documentation explains how organization and workspace limits interact. For now, the useful rule is simple: choose your test budget before sending the request.
Create and Securely Store Your API Key
Create a Key for Your Test Workspace
An API key is a secret credential that lets software make requests against your account. Treat it like a password with permission to spend your API credits.
Open the API keys page in the Console and create a key with these settings:
- Name: Use something recognizable, such as
cat-gear-test. - Linked Account: Choose yourself to create a personal key for this test.
- Workspace: Select the test workspace.
- Expiration: Choose an expiration that covers your testing period.
Copy the secret into secure storage immediately. The Console shows the full key only once. You can reuse an existing key if you still have its saved secret, but a lost secret needs a replacement.
If key creation is disabled, ask your organization administrator for the required access.
Use a key scoped to your test workspace for this walkthrough. It automatically selects that workspace. An unscoped key also needs an anthropic-workspace-id header on each request.
Load the Key Without Putting It in Your Code
We’ll use Bash, a program for running terminal commands, and curl, which sends web requests. Bash runs on macOS and Linux; on Windows, use Windows Subsystem for Linux (WSL) to run it.
On macOS, enter bash in Terminal first if your current shell is different. The hidden-prompt command below uses Bash syntax.
Check that curl is available:
curl --version

If that prints version information, continue. If the command is missing, install curl through your operating system’s package manager.
The next commands store your key in an environment variable: a named value that commands in this terminal can read. Paste them below:
read -r -s -p "Paste your Claude API key: " ANTHROPIC_API_KEY
printf '\n'
export ANTHROPIC_API_KEY
test -n "$ANTHROPIC_API_KEY" && echo "API key is set"
Paste your key when prompted and press Enter. Nothing appears while you paste because the prompt hides your input.
The last command checks whether the variable contains a value without printing the secret. It does not check whether the key is valid. The API request will do that.
Run the next request in this same terminal. If you open a new terminal, repeat the key-loading step.
Keep the secret out of source files, repositories, screenshots, and logs. For a deployed workflow, use its credential storage or a secrets manager. If a key leaks, disable or revoke it and replace it wherever it was used.
Send Your First Claude API Request
Build and Run the Request
A request needs three things:
- Endpoint: The address receiving the task.
- Headers: Information that authenticates the request and identifies its format.
- Body: The model choice, settings, and prompt, written as JSON—a text format that organizes information into named fields and values.
We’ll send a POST request to https://api.anthropic.com/v1/messages. POST means we’re submitting data for processing.
The Authorization header carries your key. The anthropic-version header selects API behavior, while the model field selects which Claude model handles the task. Anthropic documents these separately in its API overview.

Start with a small transformation whose answer you can check against the input. For illustration, imagine your cat-travel gear review blog needs an email teaser from approved cat-carrier notes.
We’ll use claude-haiku-5-5 with low effort for this short task. Effort controls how much work Claude spends on the response. Keep max_tokens at 1024 for the first request.
Paste this complete command into the terminal where you loaded your key:
curl --silent --show-error --include \
https://api.anthropic.com/v1/messages \
--header "Authorization: Bearer $ANTHROPIC_API_KEY" \
--header "anthropic-version: 2026-10-21" \
--header "content-type: application/json" \
--data '{
"model": "claude-haiku-5-5",
"max_tokens": 1024,
"output_config": {"effort": "low"},
"messages": [{
"role": "user",
"content": "Write only an email teaser under 80 words using these review notes: Cat carrier: washable pad, top opening, shoulder strap. Do not add product features, testing claims, or safety claims."
}]
}'

Here is what the remaining parts do:
--data: Sends the JSON body and makes this a POST request.--include: Shows response headers above the response body.messages: Contains the task you want Claude to perform.max_tokens: Caps generated output. It does not cap the input charge.
Haiku 5.5 uses adaptive thinking by default, and that thinking shares the output allowance with the visible answer. That is why an 80-word teaser gets more than an 80-word-sized token allowance. Anthropic’s Haiku thinking guidance explains this behavior.
Keep the command unchanged for your first attempt. Once it succeeds, replace the notes with your own. Changing several settings before you have one working request makes troubleshooting unnecessarily entertaining.
Read the Response and Check Its Cost
Look for 200, the HTTP status code that means the request succeeded, followed by the JSON response.
Here is a shortened illustration. The text and token counts below are examples, not a recorded live response or measured charge:
{
"model": "claude-haiku-5-5",
"content": [
{
"type": "text",
"text": "Looking at cat carriers? This one has a washable pad, a top opening, and a shoulder strap. Read the review for a closer look at those features."
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 1000,
"output_tokens": 200
}
}
Check four fields:
model: Identifies the model that answered.content: Holds the response blocks. Read blocks whosetypeistext; a thinking block may come first.stop_reason: Shows why generation stopped.usage: Reports token usage for the request.
For this task, end_turn means Claude finished its turn. If you see max_tokens, check whether the teaser is incomplete or missing before deliberately increasing the allowance. The Messages API reference describes these fields.

Then read the teaser against the source notes. A successful request proves the connection works. It does not prove every sentence is suitable for publication.
The example notes support a washable pad, a top opening, and a shoulder strap. They don’t support “airline approved,” “escape proof,” or “tested on long journeys.” Remove any claim the notes cannot support.
To estimate cost, count the input tokens Claude read and the output tokens it generated. For this uncached text-only request, multiply each count by its applicable rate, then add the amounts.
Haiku 5.5’s standard rates for prompts up to 100,000 tokens are:
| Usage | Price Per Million Tokens |
|---|---|
| Input | $0.10 |
| Output | $0.50 |

Check Anthropic’s Haiku pricing for current rates before increasing volume.
Using the illustrative counts above:
Cost = (input tokens × input rate + output tokens × output rate)
÷ 1,000,000
= (1,000 × $0.10 + 200 × $0.50) ÷ 1,000,000
= $0.0002
Thinking tokens are already included in the reported output token count, so don’t add them again.
At that identical usage, 1,000 calls would cost $0.20 before additional requests or taxes. This is an illustration, not a quote for your workflow. Use your returned counts and compare the estimate with the Console’s recorded usage before processing a larger batch.
One request is easy to price; a workflow with checking and rewriting takes a little more arithmetic. Use your first call’s token counts to compare a normal run with a more expensive planning scenario.

Free API Cost Calculator




Fix a Failed First Request
Read the HTTP status and error.message before changing anything. Together, they usually tell you which part needs attention.

This table follows Anthropic’s error reference:
| Status Or Symptom | Likely Cause | Corrective Action |
|---|---|---|
401 | Missing, incorrect, revoked, or expired key | Confirm the variable is set in this terminal and the key is active. |
400 | Invalid request or a spending limit you set | Follow the message; check JSON, parameters, workspace selection, and spending limits. |
402 | Billing problem | Check credits and payment details. |
403 | Permission problem | Check organization and workspace access. |
404 | Incorrect endpoint or resource identifier | Check the request URL and any named resource IDs. |
429 | Throughput limit or monthly tier spending cap | For a temporary limit, honor retry-after. For a spending-cap block, wait for access to resume or obtain a higher tier. |
500 or 529 | Temporary server failure or overload | Retry with increasing delays and a fixed retry limit. |
A monthly tier spending-cap block has no retry-after header. Retrying won’t clear it: access resumes at 00:00 UTC on the first day of the next month, unless Anthropic raises your cap sooner.

For temporary server failures, I would allow three retries with increasing waits, then stop and flag the item for review. An endless retry loop is a surprisingly effective way to automate frustration.
Keep the request-id response header if you need support. Remove credentials and private source material before sharing logs.
Use Your API Key in a Workflow
Where Can You Use the Key?
Your key works in local scripts, code running on your server, and integrations that explicitly accept Anthropic API credentials.
You have three practical routes:
- HTTP Request: Reuse the endpoint, headers, and body above in a configurable HTTP step.
- Official SDK: Use Anthropic’s software library for your programming language. It handles much of the request formatting and authentication.
- Automation Tool: Store the key in a supported integration’s credential settings.
I use n8n to connect tools, so that is where I would start if you want a visual workflow. Add an Anthropic step and save your API key in its credential settings. Use a key scoped to the intended workspace.
For a website, keep the key on your server, often called the backend. The visitor’s browser sends a request to your backend, and your backend calls Claude. Anyone can inspect credentials embedded in browser-delivered JavaScript, as Anthropic explains in its authentication guidance.
Check the provider an integration connects to before entering credentials. Access through Amazon Bedrock or Google Cloud uses the provider’s authentication and billing arrangements. A field asking for cloud credentials is not a place to paste your direct Anthropic API key.
Turn the Test Into a Repeatable Task
Once one request works, give it a clear input and destination:
Approved cat-carrier review notes
→ Claude request
→ Extracted teaser text
→ Saved email draft
→ Human review
Start with a manual trigger. Load one approved item, send its notes, extract the text blocks, and save the result beside the source review.
In my Python content pipeline, I’ve had useful drafts arrive with an extra introductory sentence attached. That looks harmless in chat, but it becomes clutter in the saved draft. I now ask for just the copy I need and check the returned text before saving it.

For the cat-carrier task, keep the prompt instructions fixed and replace only the review notes. Reuse the model, effort, and output allowance too. That makes differences between results easier to investigate.
If you build the request body in an automation tool, use its JSON fields or a JSON serializer. Don’t paste changing review notes into raw JSON by hand; quotation marks and line breaks can break the request.
The next step is turning that working request into something you can run again without rebuilding it. This AI Skill writes the script around your task and keeps the first test to one item.

Free AI API Integration Studio





Before processing several items, add a few controls:
- Completed Items: Record the source item’s ID and its saved draft so later runs can skip it.
- Items Per Run: Set a small batch size while testing.
- Retry Limit: Stop after a fixed number of retries and flag unresolved items.
- Review Gate: Save drafts for approval before sending emails.
- Usage Record: Keep token counts and request IDs without logging the secret key.
I would keep automatic sending switched off until the drafts consistently stay within the notes. Faster drafting is useful even when a person still approves the email.
Estimate the next batch from several successful requests. If you plan to process 50 reviews once each, count 50 Claude calls. Add any separate rewrite or checking calls because they also use tokens.
Compare that estimate with your workspace spending limit, then increase volume gradually.
What Next?
Load your test key and run the single request above. Save the returned teaser beside its source notes, then check the wording and token usage before changing the task.
Use the social buttons to share this guide when you want to make that first API connection easier to follow.
Which task would you trust Claude to draft while you keep the final approval? Tell me in the comments, and bring any setup questions there too.
Share this post with your friends & followers:
