Skip to navigation

Claude Opus 5 API

Use model: "claude-opus-5" to call Claude Opus 5. The examples below send a synchronous request using Anthropic Messages.

These are integration examples, not recorded model outputs. Keep the key in your server environment as BEATAPI_API_KEY; replace <BEATAPI_API_KEY> in the cURL example with your own key. Do not put the key in browser code.

Send a request

POST https://api.beatapi.io/v1/messages

Install @anthropic-ai/sdk in your server project.

import Anthropic from "@anthropic-ai/sdk";
const apiKey = process.env.BEATAPI_API_KEY;
if (!apiKey) throw new Error("Set BEATAPI_API_KEY in your server environment.");
const client = new Anthropic({
apiKey,
baseURL: "https://api.beatapi.io",
});
const message = await client.messages.create({
model: "claude-opus-5",
max_tokens: 2048,
messages: [{ role: "user", content: "Review this proposed webhook retry design: retry every failure indefinitely at one-second intervals, with no idempotency key. Return the failure modes and a revised design with explicit retry and stop conditions." }],
});
if (message.stop_reason !== "end_turn") {
throw new Error(`Handle the stop reason before accepting the result: ${message.stop_reason}`);
}
const text = message.content
.filter((block) => block.type === "text")
.map((block) => block.text)
.join("\n");
if (!text.trim()) throw new Error("The response contains no text answer.");
console.log(text);
console.log({ id: message.id, model: message.model, usage: message.usage });

max_tokens: 2048 is the output budget chosen for this example, not the model’s maximum output limit. The SDK base URL omits /v1 because the SDK supplies the endpoint path.

cURL

curl --request POST \
--url https://api.beatapi.io/v1/messages \
--header 'Authorization: Bearer <BEATAPI_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"model": "claude-opus-5",
"max_tokens": 2048,
"messages": [
{
"role": "user",
"content": "Review this proposed webhook retry design: retry every failure indefinitely at one-second intervals, with no idempotency key. Return the failure modes and a revised design with explicit retry and stop conditions."
}
]
}'

Read and validate the result

The SDK returns the native Messages response. Read text only from blocks whose type is text; inspect stop_reason and usage from the actual response. The example accepts end_turn. Handle max_tokens as a potentially truncated answer and tool_use as a request for the application to handle tools, not as a completed task.

An HTTP 200 alone does not prove that the answer satisfies your task. Validate the content in your application. These text requests return directly; do not poll /v1/tasks for them.

Check GET /v1/models for the model IDs available to your account. This minimal example does not claim support for additional reasoning, sampling, cache-control or hosted-tool settings.