Connect Anthropic SDK
Use Anthropic clients with Gigatoken
Gigatoken exposes an Anthropic-compatible Messages adapter at /v1/messages. This guide uses the official Anthropic JavaScript and TypeScript SDK against Gigatoken's coordinator, with the same inference keys and catalog model ids used by the OpenResponses API.
What you need
- A Gigatoken inference key. Generate one from the Inference console API keys page.
- A served Gigatoken catalog model, such as
qwen/qwen3.5-0.8b. Live availability is exposed byGET /v1/models. - The official Anthropic SDK installed in your application.
npm install @anthropic-ai/sdkBase URL and authentication
Set the SDK baseURL to the coordinator origin without /v1. The Anthropic SDK appends /v1/messages and /v1/messages/count_tokens itself.
Pass your Gigatoken inference key as apiKey. The official SDK sends it as x-api-key. Provider keys are rejected by inference endpoints. Raw HTTP clients may also send Authorization: Bearer ....
anthropic-version is accepted for SDK and client compatibility, but Gigatoken ignores the value because the adapter version is tied to the deployed coordinator.
export GIGATOKEN_ANTHROPIC_BASE_URL="https://coordinator.gigatoken.baremetallabs.ai"
export GIGATOKEN_INFERENCE_KEY="gt_your_inference_key"
export GIGATOKEN_MODEL="qwen/qwen3.5-0.8b"Model selection
Use exact Gigatoken catalog ids in the Anthropic model field. For example, pass qwen/qwen3.5-0.8b, not a Claude model name.
Gigatoken does not alias or translate Claude model names. A client configured with names like claude-3-5-sonnet-latest must map them to catalog ids before sending the request.
End-to-end TypeScript sample
This single sample covers text, SDK streaming accumulation, tool use, extended thinking, and token counting.
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: process.env.GIGATOKEN_INFERENCE_KEY,
baseURL:
process.env.GIGATOKEN_ANTHROPIC_BASE_URL ??
"https://coordinator.gigatoken.baremetallabs.ai",
});
const model = process.env.GIGATOKEN_MODEL ?? "qwen/qwen3.5-0.8b";
const text = await client.messages.create({
model,
max_tokens: 128,
system: "Reply plainly and briefly.",
messages: [{ role: "user", content: "Reply with one word: ready" }],
});
const streamed = await client.messages
.stream({
model,
max_tokens: 128,
system: "Reply plainly and briefly.",
messages: [{ role: "user", content: "Reply with one word: ready" }],
})
.finalMessage();
const weatherTool = {
name: "get_weather",
description: "Get weather",
input_schema: {
type: "object",
properties: {
location: { type: "string" },
},
required: ["location"],
},
} as const;
const toolRequest = await client.messages.create({
model,
max_tokens: 128,
messages: [{ role: "user", content: "What is the weather in Boston?" }],
tools: [weatherTool],
tool_choice: { type: "tool", name: "get_weather" },
});
const toolUse = toolRequest.content.find((block) => block.type === "tool_use");
if (!toolUse || toolUse.type !== "tool_use") {
throw new Error("Expected get_weather tool_use");
}
const toolFollowUp = await client.messages.create({
model,
max_tokens: 128,
messages: [
{ role: "user", content: "What is the weather in Boston?" },
{ role: "assistant", content: toolRequest.content },
{
role: "user",
content: [
{
type: "tool_result",
tool_use_id: toolUse.id,
content: "72 F and sunny",
},
],
},
],
});
const thinking = await client.messages.create({
model,
max_tokens: 2048,
thinking: { type: "enabled", budget_tokens: 1024 },
messages: [
{ role: "user", content: "Think briefly, then reply with one word: ready" },
],
});
const count = await client.messages.countTokens({
model,
messages: [{ role: "user", content: "Reply with one word: ready" }],
});
console.log(text.content);
console.log(streamed.content);
console.log(toolFollowUp.content);
console.log(thinking.content);
console.log(count.input_tokens);Image input
Image input works when the requested catalog model is currently served with a projector. Use a vision-capable model such as google/gemma-4-26b-a4b-it-q4. Current image-capable catalog ids: google/gemma-4-31b-it, google/gemma-4-26b-a4b-it, google/gemma-4-26b-a4b-it-q4, google/gemma-4-12b-it, qwen/qwen3.6-27b, qwen/qwen3.6-35b-a3b, qwen/qwen3.6-35b-a3b-q4.
Image sources may be base64 or url. Supported media types are image/jpeg, image/png, image/gif, and image/webp. Anthropic Files API file_id image sources are not supported.
Image content can appear in user message content and inside tool_result content. Document and PDF content blocks are currently unsupported.
The live production post-deploy gate deliberately excludes image requests while the always-on production device is text-only. Image conformance is verified hermetically in CI.
Supported capabilities
- Text responses with
client.messages.create(). - Streaming with the SDK accumulator, including
client.messages.stream(...).finalMessage(). - Tool requests,
tool_useresponses, and follow-uptool_resultmessages. - Extended thinking via
thinking: { type: "enabled", budget_tokens: 1024 }. - Image input on vision-capable served models.
- Token counting with
client.messages.countTokens().
Known limitations
- There is no Claude model-name aliasing. Clients must send exact Gigatoken catalog ids.
stop_sequences,top_k, and per-blockcache_controlare accepted, ignored before provider dispatch, and recorded by the adapter's lossy-field tracking.- Image sources are limited to
base64andurl. Anthropic Files APIfile_idimage sources are not supported. - Document and PDF content blocks are currently unsupported.
- Image input requires a vision-capable model to be currently served.
count_tokensrejects images, tools,tool_choice, thinking, document blocks,tool_use,tool_result, and thinking history instead of partially counting unsupported mixed content.
For the general OpenResponses API, continue to use the inference API quickstart.