@anvia/anthropic 1.1.4 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +23 -95
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,124 +1,52 @@
1
1
  # @anvia/anthropic
2
2
 
3
- Anthropic provider adapter for Anvia.
3
+ Run Anvia agents on Claude through Anthropic, Vertex AI, or an Anthropic-compatible
4
+ endpoint. Keep your tools and agent workflow while changing the model provider.
4
5
 
5
- Use this package when you want Anvia agents, extractors, or pipelines to run on Claude models through Anthropic's SDK, or through an Anthropic-compatible API endpoint.
6
-
7
- ## Installation
6
+ ## Install
8
7
 
9
8
  ```sh
10
9
  pnpm add @anvia/anthropic @anvia/core
11
10
  ```
12
11
 
13
- In this monorepo, the package is available through the workspace:
12
+ ## Quickstart
14
13
 
15
- ```sh
16
- pnpm --filter @anvia/anthropic build
17
- ```
18
-
19
- ## Usage
14
+ Set `ANTHROPIC_API_KEY` before running this example.
20
15
 
21
16
  ```ts
22
17
  import { Agent } from "@anvia/core";
23
18
  import { AnthropicClient } from "@anvia/anthropic";
24
19
 
25
20
  const client = new AnthropicClient({
26
- apiKey,
21
+ apiKey: process.env.ANTHROPIC_API_KEY!,
27
22
  });
28
-
29
- const model = client.completionModel({ modelId: "claude-opus-5" });
30
-
31
23
  const agent = new Agent({
32
24
  id: "assistant",
33
- model: model,
25
+ model: client.completionModel({ modelId: "claude-opus-5" }),
34
26
  instructions: "Answer clearly and concisely.",
35
27
  });
36
28
 
37
- const result = await agent.generate({ prompt: "Summarize Anvia in one sentence." });
38
- if (result.type === "response") console.log(result.output);
39
- ```
40
-
41
- ## Anthropic-Compatible APIs
42
-
43
- For APIs that expose an Anthropic-compatible surface, pass a custom `baseUrl`:
44
-
45
- ```ts
46
- import { AnthropicClient } from "@anvia/anthropic";
47
-
48
- const client = new AnthropicClient({
49
- apiKey,
50
- baseUrl,
29
+ const result = await agent.generate({
30
+ prompt: "What should I check before launching a new product?",
51
31
  });
52
32
 
53
- const model = client.completionModel({ modelId: "provider/model-name" });
33
+ if (result.type === "response") {
34
+ console.log(result.output);
35
+ }
54
36
  ```
55
37
 
56
- ## Vertex AI
57
-
58
- Use Anthropic's official Vertex SDK through `AnthropicVertexClient`:
38
+ ## What you can build
59
39
 
60
- ```ts
61
- import { AnthropicVertexClient } from "@anvia/anthropic";
62
-
63
- const client = new AnthropicVertexClient({
64
- projectId: "my-gcp-project",
65
- region: "global",
66
- });
67
-
68
- const model = client.completionModel({ modelId: "claude-sonnet-5" });
69
- ```
40
+ - Streaming completions, tool calls, image inputs, and document inputs.
41
+ - Typed reasoning controls for supported Claude models.
42
+ - `AnthropicVertexClient` for Google Cloud authentication and routing.
43
+ - Custom endpoints through `baseUrl`; model listing on `AnthropicClient`.
70
44
 
71
- The client follows the standard Google authentication flow. It reads
72
- `ANTHROPIC_VERTEX_PROJECT_ID` and `CLOUD_ML_REGION` when project and region are omitted, and supports
73
- Application Default Credentials such as `GOOGLE_APPLICATION_CREDENTIALS`:
45
+ For Vertex AI, use `AnthropicVertexClient` with your Google Cloud project and region.
46
+ The usage guide covers Application Default Credentials and custom authentication.
74
47
 
75
- ```sh
76
- export ANTHROPIC_VERTEX_PROJECT_ID="my-gcp-project"
77
- export CLOUD_ML_REGION="global"
78
- export GOOGLE_APPLICATION_CREDENTIALS="/absolute/path/service-account.json"
79
- ```
80
-
81
- For custom authentication, pass the official SDK's `googleAuth`, `authClient`, or `accessToken`
82
- options:
83
-
84
- ```sh
85
- pnpm add google-auth-library
86
- ```
87
-
88
- ```ts
89
- import { GoogleAuth } from "google-auth-library";
90
-
91
- const client = new AnthropicVertexClient({
92
- projectId: "my-gcp-project",
93
- region: "global",
94
- googleAuth: new GoogleAuth({
95
- credentials: serviceAccountJson,
96
- scopes: "https://www.googleapis.com/auth/cloud-platform",
97
- }),
98
- });
99
- ```
100
-
101
- You can also pass a preconfigured `authClient`, including impersonated credentials. Validate
102
- externally supplied credential configurations before using them, and never commit credential JSON
103
- or service-account keys.
104
-
105
- Vertex AI does not expose Anthropic's Models API, so `AnthropicVertexClient` intentionally does not
106
- provide `listModels()`.
107
-
108
- ## Exports
109
-
110
- - `AnthropicClient`
111
- - `AnthropicVertexClient`
112
- - structural Anthropic and Vertex completion handle types
113
- - `AnthropicCompletionModelId`
114
- - `anthropic`
115
-
116
- ## Development
117
-
118
- ```sh
119
- pnpm --filter @anvia/anthropic typecheck
120
- pnpm --filter @anvia/anthropic test
121
- pnpm --filter @anvia/anthropic build
122
- ```
48
+ ## Learn more
123
49
 
124
- Package-local `typecheck` and `build` scripts build `@anvia/core` first so core subpath types are available in a fresh worktree.
50
+ - [Usage guide](https://github.com/anvia-hq/anvia/blob/main/docs/packages/provider-anthropic.md)
51
+ - [Anvia overview](https://github.com/anvia-hq/anvia/blob/main/README.md)
52
+ - [Contributing](https://github.com/anvia-hq/anvia/blob/main/CONTRIBUTING.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anvia/anthropic",
3
- "version": "1.1.4",
3
+ "version": "1.1.7",
4
4
  "description": "Anthropic provider adapter for Anvia.",
5
5
  "author": "anvia",
6
6
  "license": "MIT",
@@ -25,18 +25,18 @@
25
25
  }
26
26
  },
27
27
  "dependencies": {
28
- "@anthropic-ai/sdk": "^0.125.0",
29
- "@anthropic-ai/vertex-sdk": "^0.19.8"
28
+ "@anthropic-ai/sdk": "^0.128.0",
29
+ "@anthropic-ai/vertex-sdk": "^0.19.11"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "^24.9.1",
33
33
  "tsup": "^8.5.0",
34
34
  "typescript": "^5.9.3",
35
- "vitest": "^4.0.8",
36
- "@anvia/core": "1.3.1"
35
+ "vitest": "^4.1.11",
36
+ "@anvia/core": "1.6.1"
37
37
  },
38
38
  "peerDependencies": {
39
- "@anvia/core": "^1.3.1"
39
+ "@anvia/core": "^1.6.1"
40
40
  },
41
41
  "scripts": {
42
42
  "prebuild": "test -f ../core/dist/index.d.ts || pnpm --filter @anvia/core build",