Socket
Book a DemoInstallSign in
Socket

@gensx/anthropic

Package Overview
Dependencies
Maintainers
3
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gensx/anthropic

Anthropic integration for GenSX.

0.2.13
latest
Source
npmnpm
Version published
Maintainers
3
Created
Source

@gensx/anthropic

A pre-wrapped version of the Anthropic SDK for GenSX. This package provides a simple way to use Anthropic's API with GenSX components.

Installation

npm install @gensx/anthropic

Usage

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,
});

2. Wrap an Existing Instance

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,
});

3. Using with GenSX Components

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>
  );
});

API

The package exports:

  • Anthropic - A drop-in replacement for the Anthropic client that automatically wraps all methods with GenSX functionality
  • wrapAnthropic - A function to manually wrap an Anthropic instance with GenSX functionality
  • AnthropicProvider - A GenSX component for providing Anthropic context
  • ChatCompletion - A GenSX component for creating chat completions

All methods from the Anthropic SDK are supported and automatically wrapped with GenSX functionality.

License

Apache-2.0

Keywords

gensx

FAQs

Package last updated on 14 Aug 2025

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.