Developer integration
Anthropic SDK
Use the official Anthropic SDK with the Albatross Gateway origin.
- Protocol
- Messages · count_tokens
- Support status
- Verified locally with Node.js SDK 0.123.0
Configure the client
Use the Gateway origin as baseURL. The SDK appends /v1/messages; do not append a second /v1. In a local example project with Node.js and pnpm installed, run the installation and environment commands in the same terminal (macOS/Linux shell; adapt export syntax on Windows). Save the client initialization as albatross-anthropic.mjs in that project and append one example from a later section; examples are alternatives, not commands to run independently. Then run the file from that project directory. Exported variables last only for that terminal and its children. After editing the file or environment, rerun Node to apply the changes.
pnpm add @anthropic-ai/sdk@0.123.0export ALBATROSS_ORIGIN="https://staging-gateway.bulakua.com"
export ALBATROSS_API_KEY="<ALBATROSS_API_KEY>"
export ALBATROSS_MODEL="<ALBATROSS_MODEL>"import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: process.env.ALBATROSS_API_KEY,
baseURL: process.env.ALBATROSS_ORIGIN,
maxRetries: 0,
});node albatross-anthropic.mjsCreate a message
const message = await client.messages.create({
model: process.env.ALBATROSS_MODEL,
max_tokens: 1024,
messages: [{ role: "user", content: "Reply with: connected" }],
});
console.log(message.content);const stream = client.messages.stream({
model: process.env.ALBATROSS_MODEL,
max_tokens: 1024,
messages: [{ role: "user", content: "Reply in one sentence" }],
});
stream.on("text", (text) => process.stdout.write(text));
const finalMessage = await stream.finalMessage();
console.log(finalMessage.usage);Tools, thinking, and caching
- Return assistant thinking, signature, and tool_use blocks unchanged on the next turn.
- Match every tool_result to its tool_use_id.
- Input usage includes input_tokens, cache_creation_input_tokens, and cache_read_input_tokens.
- Do not assume correct customer token billing proves upstream provider cost reconciliation.
Count tokens
const count = await client.messages.countTokens({
model: process.env.ALBATROSS_MODEL,
messages: [{ role: "user", content: "Count this request" }],
});
console.log(count.input_tokens);Acceptance checklist
- Bearer or x-api-key authentication
- Non-streaming and streaming Messages
- Tool use and tool result round-trip
- Thinking/signature preservation when enabled
- count_tokens and Retry-After error handling
- Cancellation
Switch models with one Anthropic SDK client
Configure the Gateway origin and one authentication mode once. Select the exact Messages alias on each messages.create call.
const models = { fast: '<ALBATROSS_MESSAGES_FAST_ALIAS>', quality: '<ALBATROSS_MESSAGES_QUALITY_ALIAS>' };
await client.messages.create({ model: models.fast, max_tokens: 1024, messages: [{ role: 'user', content: 'Confirm connection' }] });
await client.messages.create({ model: models.quality, max_tokens: 1024, messages: [{ role: 'user', content: 'Explain in detail' }] });