Your First Claude API Request: API Key, Base URL, and Verification
Prepare an API key and Base URL, copy a current model ID, send one Claude-compatible request, and verify the response and token usage.
Contents
This guide takes you from an existing API key to one verified Claude-compatible request. If you are still choosing an access and billing route, start with the Claude API overview; the steps below focus only on the technical first request.
A Claude-compatible API connection needs three separate pieces: a provider account, an API key issued by that provider, and the endpoint required by the protocol. In this guide, you create a BetterToken API key. It is not an official Anthropic API key, even though the request uses the Anthropic Messages format.
1. Create your BetterToken API key
- Sign in to BetterToken Workspace.
- Create a new API key for the documented Claude-compatible key group.
- Copy the key once and store it in a secret manager or a local environment file that is excluded from Git.
- Open the current API documentation and the pricing page to confirm the current model ID and availability.
Do not paste the key into source code, a prompt, a screenshot, a support message, or a public repository. BetterToken users work through their own accounts and keys; the service does not issue an Anthropic Console key or sell access to a shared Claude.ai account.
2. Use the Anthropic-compatible endpoint
For the Anthropic SDK or Claude Code, the BetterToken Base URL is:
https://bettertoken.ai/?utm_source=blog&utm_medium=organic_content&utm_campaign=SEO-059&utm_content=claude-api-v-rossii-klyuch-pervyy-zapros
Do not add /v1 to that Base URL. For a raw HTTP Messages request, the full resource path is different:
POST https://www.bettertoken.ai/v1/messages?utm_source=blog&utm_medium=organic_content&utm_campaign=SEO-059&utm_content=claude-api-v-rossii-klyuch-pervyy-zapros
The distinction matters: SDKs append the resource path, while a raw curl command needs the complete URL. OpenAI-compatible tools use another Base URL and should follow their own setup guide.
3. Send the first request
Set the BetterToken key in a local environment variable. The variable name follows the Anthropic SDK convention, but its value is still your BetterToken API key.
export ANTHROPIC_API_KEY="your_api_key"
export ANTHROPIC_BASE_URL="https://bettertoken.ai/?utm_source=blog&utm_medium=organic_content&utm_campaign=SEO-059&utm_content=claude-api-v-rossii-klyuch-pervyy-zapros"
export CLAUDE_MODEL_ID="YOUR_MODEL_ID"
curl --fail-with-body "$ANTHROPIC_BASE_URL/v1/messages" \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d "{
\"model\": \"$CLAUDE_MODEL_ID\",
\"max_tokens\": 64,
\"messages\": [{\"role\": \"user\", \"content\": \"Return only the word pong.\"}]
}"
Replace the two placeholders only in your local shell. Use an exact current model ID from BetterToken Docs or the pricing page; model names and availability can change.
4. Verify the response and usage record
A successful request returns HTTP 200 and a JSON message object. Check:
typeismessage;contentcontains the model response;usagecontains input and output token counts.
The official Anthropic Messages reference defines the protocol shape. That reference does not make a BetterToken-issued key an Anthropic key; it only documents the compatible request and response format.
Next, open BetterToken Workspace and match the request by time. Confirm the model, status, input/output/cache tokens where applicable, and corresponding cost. Workspace is for usage metadata and billing records; do not assume that it stores the complete prompt or response.
5. Fix common first-request errors
- 404 or incorrect route: raw HTTP uses
/v1/messages;/messagesalone is incomplete. - 400: check
anthropic-version,content-type, model ID,max_tokens, and themessagesarray. - 401 or 403: check the BetterToken key, key group, Base URL, and accidental whitespace. Do not send the key to support.
- 429: read the response body, respect the indicated delay, and inspect concurrent requests and current limits before retrying.
- No Workspace record: verify that the request used the BetterToken Base URL rather than another provider left in your environment.
If another provider’s values remain in the shell, clear them before starting over:
unset ANTHROPIC_API_KEY
unset ANTHROPIC_BASE_URL
unset CLAUDE_MODEL_ID
Then set the three values again from the current BetterToken setup information and send one request—not a retry loop.
Next step
After the minimal request succeeds, move the key into your application’s secret store, set a finite timeout, and add bounded retries only for temporary failures. Review the current BetterToken Docs, then keep Workspace open while you test the first real integration.