@galdor/provider-anthropic 0.3.0 → 0.3.1
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.
- package/README.md +49 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# @galdor/provider-anthropic
|
|
2
|
+
|
|
3
|
+
The [Anthropic](https://docs.anthropic.com) (Claude Messages API) provider
|
|
4
|
+
adapter for [galdor](https://github.com/YasserCR/galdor-bun). Implements the core
|
|
5
|
+
`Provider` interface, so it drops into any graph, agent, or council.
|
|
6
|
+
|
|
7
|
+
Covers generate + streaming, tool calling, structured output, vision, extended
|
|
8
|
+
thinking (including signature round-trips and redacted thinking), prompt caching,
|
|
9
|
+
the typed error taxonomy with `Retry-After`, cancellation, and a stream-safe
|
|
10
|
+
header timeout (60 s default).
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
bun add @galdor/provider-anthropic # or: npm install @galdor/provider-anthropic
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { newAnthropic } from "@galdor/provider-anthropic";
|
|
22
|
+
import { userMessage, messageText } from "@galdor/core/schema";
|
|
23
|
+
|
|
24
|
+
const provider = newAnthropic({
|
|
25
|
+
apiKey: process.env.ANTHROPIC_API_KEY!,
|
|
26
|
+
// baseURL: "https://api.anthropic.com", // optional override
|
|
27
|
+
// timeoutMs: 60_000, // header timeout; 0 disables
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// One-shot
|
|
31
|
+
const res = await provider.generate({
|
|
32
|
+
model: "claude-haiku-4-5",
|
|
33
|
+
messages: [userMessage("Explain MCP in one sentence.")],
|
|
34
|
+
});
|
|
35
|
+
console.log(messageText(res.message), res.usage);
|
|
36
|
+
|
|
37
|
+
// Streaming
|
|
38
|
+
for await (const ev of provider.stream({ model: "claude-haiku-4-5", messages: [userMessage("Count to 3.")] })) {
|
|
39
|
+
// ev is a provider Event (content deltas, tool calls, message stop, …)
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Pass `tools`, `toolChoice`, `responseFormat`, `reasoning`, and message
|
|
44
|
+
`cacheControl` on the request; unsupported features surface as a typed
|
|
45
|
+
`UnsupportedError` rather than being silently dropped.
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
|
|
49
|
+
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@galdor/provider-anthropic",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Anthropic (Claude Messages API) provider adapter for galdor-bun.",
|
|
6
6
|
"author": {
|
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
"bun": ">=1.3"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@galdor/core": "0.3.
|
|
34
|
+
"@galdor/core": "0.3.1"
|
|
35
35
|
}
|
|
36
36
|
}
|