Skip to content

@anvia/anthropic ​

Anthropic’s provider adapter supplies streaming Claude completion models for Anvia agents, direct completions, extractors, and pipelines. It supports Anthropic’s API, compatible Messages endpoints, and Claude on Google Vertex AI.

SupportFirst-party
Version0.5.1
RuntimeESM, server-side JavaScript
Peer@anvia/core >=0.7.1 <1.0.0

Install ​

bash
pnpm add @anvia/anthropic @anvia/core

Create a Claude agent ​

ts
import { AgentBuilder } from '@anvia/core'
import { AnthropicClient } from '@anvia/anthropic'

const anthropic = new AnthropicClient({
  apiKey: process.env.ANTHROPIC_API_KEY,
})

const agent = new AgentBuilder(
  'assistant',
  anthropic.completionModel('claude-sonnet-4-20250514'),
)
  .instructions('Give direct, well-supported answers.')
  .build()

const result = await agent.prompt('Summarize the release notes.').send()
console.log(result.output)

Capabilities ​

CapabilitySupport
Completion and streamingYes
Tools and structured outputYes
Text and image message contentYes
Model listingAnthropic API client only
Vertex AIDedicated client
Embeddings and media generationNo

The package maps Anvia history, documents, tools, tool results, reasoning, streaming events, and usage to Anthropic Messages. It intentionally does not pretend that Anthropic exposes Anvia embedding or media model contracts.

Common patterns ​

Use an Anthropic-compatible endpoint ​

ts
const compatible = new AnthropicClient({
  apiKey: process.env.PROVIDER_API_KEY,
  baseUrl: 'https://provider.example.com',
})

const model = compatible.completionModel('provider/model-name')

Run Claude through Vertex AI ​

ts
import { AnthropicVertexClient } from '@anvia/anthropic'

const vertex = new AnthropicVertexClient({
  projectId: 'my-gcp-project',
  region: 'global',
})

const model = vertex.completionModel('claude-sonnet-5')

The Vertex client follows Google authentication through the official Anthropic Vertex SDK. It can use Application Default Credentials or explicit SDK authentication options, but it does not expose listModels() because Vertex does not provide Anthropic’s Models API.

Compatibility ​

@anvia/anthropic is ESM and depends on the official Anthropic and Anthropic Vertex SDKs. AnthropicClient accepts a preconfigured Anthropic client. AnthropicVertexClientOptions extends the official Vertex ClientOptions, so transport and authentication compatibility follow that SDK.

Continue ​

Built for Anvia.