
Product
Introducing Socket Scanning for OpenVSX Extensions
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.
@gensx/anthropic
Advanced tools
A pre-wrapped version of the Anthropic SDK for GenSX. This package provides a simple way to use Anthropic's API with GenSX components.
npm install @gensx/anthropic
You can use this package in two ways:
Simply replace your Anthropic import with the GenSX version:
// Instead of:
// import { Anthropic } from '@anthropic-ai/sdk';
// Use:
import { Anthropic } from "@gensx/anthropic";
// Create a client as usual
const client = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
});
// All methods are automatically wrapped with GenSX functionality
const completion = await client.messages.create({
model: "claude-sonnet-4-20250514",
messages: [{ role: "user", content: "Hello!" }],
max_tokens: 1000,
});
// Use streaming
const stream = await client.messages.create({
model: "claude-sonnet-4-20250514",
messages: [{ role: "user", content: "Hello!" }],
max_tokens: 1000,
stream: true,
});
If you already have an Anthropic instance, you can wrap it with GenSX functionality:
import { Anthropic } from "@anthropic-ai/sdk";
import { wrapAnthropic } from "@gensx/anthropic";
// Create your Anthropic instance as usual
const client = wrapAnthropic(
new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
}),
);
// Now all methods are wrapped with GenSX functionality
const completion = await client.messages.create({
model: "claude-sonnet-4-20250514",
messages: [{ role: "user", content: "Hello!" }],
max_tokens: 1000,
});
You can also use the package with GenSX components:
import * as gensx from "@gensx/core";
import { AnthropicProvider, ChatCompletion } from "@gensx/anthropic";
const ChatBot = gensx.Component(async ({ userInput }) => {
return (
<AnthropicProvider apiKey={process.env.ANTHROPIC_API_KEY!}>
<ChatCompletion
system="You are a helpful assistant."
messages={[{ role: "user", content: userInput }]}
model="claude-sonnet-4-20250514"
temperature={0.7}
/>
</AnthropicProvider>
);
});
// Use with streaming
const StreamingChat = gensx.Component(async ({ userInput }) => {
return (
<AnthropicProvider apiKey={process.env.ANTHROPIC_API_KEY!}>
<ChatCompletion
system="You are a helpful assistant."
messages={[{ role: "user", content: userInput }]}
stream={true}
model="claude-sonnet-4-20250514"
>
{async (stream) => {
for await (const token of stream) {
process.stdout.write(token);
}
}}
</ChatCompletion>
</AnthropicProvider>
);
});
The package exports:
Anthropic - A drop-in replacement for the Anthropic client that automatically wraps all methods with GenSX functionalitywrapAnthropic - A function to manually wrap an Anthropic instance with GenSX functionalityAnthropicProvider - A GenSX component for providing Anthropic contextChatCompletion - A GenSX component for creating chat completionsAll methods from the Anthropic SDK are supported and automatically wrapped with GenSX functionality.
Apache-2.0
FAQs
Anthropic integration for GenSX.
We found that @gensx/anthropic demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.

Product
Bringing supply chain security to the next generation of JavaScript package managers

Product
A safer, faster way to eliminate vulnerabilities without updating dependencies