TypeScript SDK
Claude API TypeScript SDK — install, configure, and make requests using the Anthropic TypeScript library with Node.js.
Anthropic SDK base URL: https://api2.claudestore.store. OpenAI SDK base URL: https://api2.claudestore.store/v1. Best for: Node.js apps, workers, serverless runtimes. Same API key: Yes.
Which Format Should I Use?
- Use Anthropic SDK when you want native Messages API semantics, native streaming events, and direct Claude-style payloads.
- Use OpenAI SDK when you already have an OpenAI-compatible abstraction, shared middleware, or provider switching logic.
- Both routes use the same ClaudeStore API key and the same Claude model IDs.
If your project already has logging, retries, and middleware around the OpenAI SDK, keeping that client usually minimizes migration work.
Anthropic SDK
Installbash
npm install @anthropic-ai/sdkBasic usagetypescript
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "YOUR_API_KEY",
baseURL: "https://api2.claudestore.store",
});
const message = await client.messages.create({
model: "claude-sonnet-4.6",
max_tokens: 1024,
messages: [
{ role: "user", content: "Write a TypeScript utility type for deep partial." }
],
});
console.log(message.content[0].text);Streamingtypescript
const stream = client.messages.stream({
model: "claude-sonnet-4.6",
max_tokens: 1024,
messages: [{ role: "user", content: "Explain TypeScript generics." }],
});
for await (const event of stream) {
if (event.type === "content_block_delta" && event.delta.type === "text_delta") {
process.stdout.write(event.delta.text);
}
}OpenAI SDK
Installbash
npm install openaiBasic usagetypescript
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://api2.claudestore.store/v1",
});
const response = await client.chat.completions.create({
model: "claude-sonnet-4.6",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(response.choices[0].message.content);Common Mistakes
- Using
/v1with the Anthropic SDK. The native client should usehttps://api2.claudestore.store. - Using the bare domain with the OpenAI SDK. OpenAI-compatible TypeScript clients should use
https://api2.claudestore.store/v1. - Shipping API keys into browser bundles. Keep ClaudeStore keys on the server, in edge runtimes, or in local developer tooling.