@khulnasoft/anthropic
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

Vercel AI SDK - Anthropic Provider

Note: The Anthropic API does not support streaming tool calls yet.

The Anthropic provider contains language model support for the Anthropic Messages API. It creates language model objects that can be used with the generateText and streamTextAI functions.

Setup

The Anthropic provider is available in the @khulnasoft/anthropic module. You can install it with

npm i @khulnasoft/anthropic

Provider Instance

You can import Anthropic from ai/anthropic and initialize a provider instance with various settings:

import { Anthropic } from '@khulnasoft/anthropic';

const anthropic = new Anthropic({
  baseUrl: '', // optional base URL for proxies etc.
  apiKey: '', // optional API key, default to env property ANTHROPIC_API_KEY
});

The AI SDK also provides a shorthand anthropic import with a Anthropic provider instance that uses defaults:

import { anthropic } from '@khulnasoft/anthropic';

Messages Models

You can create models that call the Anthropic Messages API using the .messages() factory method. The first argument is the model id, e.g. claude-3-haiku-20240307. Some models have multi-modal capabilities.

const model = anthropic.messages('claude-3-haiku-20240307');

Anthropic Messages` models support also some model specific settings that are not part of the standard call settings. You can pass them as an options argument:

const model = anthropic.messages('claude-3-haiku-20240307', {
  topK: 0.2,
});

Dependents (0)

Package Sidebar

Install

npm i @khulnasoft/anthropic

Weekly Downloads

0

Version

0.0.1

License

Apache-2.0

Unpacked Size

81.8 kB

Total Files

8

Last publish

Collaborators

  • nextlinux