You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<h4align="center">Anthropic AI plugin for Google Firebase Genkit</h4>
6
6
7
-
`@genkit-ai/anthropic` is the official Anthropic plugin for [Firebase Genkit](https://github.com/firebase/genkit). It supersedes the earlier community package `genkitx-anthropic` and is now maintained by Google.
7
+
`@genkit-ai/anthropic` is the official Anthropic plugin for
8
+
[Firebase Genkit](https://github.com/firebase/genkit). It supersedes the earlier
9
+
community package `genkitx-anthropic` and is now maintained by Google.
8
10
9
11
## Supported models
10
12
11
-
The plugin supports the most recent Anthropic models: **Claude Haiku 4.5**, **Claude Sonnet 4.5**, and **Claude Opus 4.5**. Additionally, the plugin supports all of the [non-retired older models](https://platform.claude.com/docs/en/about-claude/model-deprecations#model-status).
13
+
The plugin supports the most recent Anthropic models: **Claude Haiku 4.5**,
14
+
**Claude Sonnet 4.5**, and **Claude Opus 4.5**. Additionally, the plugin
// specify a default model for generate here if you wish:
32
-
model: anthropic.model('claude-sonnet-4-5'),
37
+
model: anthropic.model("claude-sonnet-4-5"),
33
38
});
34
39
```
35
40
@@ -39,8 +44,8 @@ The simplest way to generate text is by using the `generate` method:
39
44
40
45
```typescript
41
46
const response =awaitai.generate({
42
-
model: anthropic.model('claude-haiku-4-5'),
43
-
prompt: 'Tell me a joke.',
47
+
model: anthropic.model("claude-haiku-4-5"),
48
+
prompt: "Tell me a joke.",
44
49
});
45
50
46
51
console.log(response.text);
@@ -53,7 +58,7 @@ console.log(response.text);
53
58
54
59
const response =awaitai.generate({
55
60
prompt: [
56
-
{ text: 'What animal is in the photo?' },
61
+
{ text: "What animal is in the photo?" },
57
62
{ media: { url: imageUrl } },
58
63
],
59
64
});
@@ -62,11 +67,12 @@ console.log(response.text);
62
67
63
68
### Extended thinking
64
69
65
-
Claude 4.5 models can expose their internal reasoning. Enable it per-request with the Anthropic thinking config and read the reasoning from the response:
70
+
Claude 4.5 models can expose their internal reasoning. Enable it per-request
71
+
with the Anthropic thinking config and read the reasoning from the response:
66
72
67
73
```typescript
68
74
const response =awaitai.generate({
69
-
prompt: 'Walk me through your reasoning for Fermat’s little theorem.',
75
+
prompt: "Walk me through your reasoning for Fermat’s little theorem.",
When thinking is enabled, request bodies sent through the plugin include the `thinking` payload (`{ type: 'enabled', budget_tokens: … }`) that Anthropic's API expects, and streamed responses deliver `reasoning` parts as they arrive so you can render the chain-of-thought incrementally.
88
+
When thinking is enabled, request bodies sent through the plugin include the
89
+
`thinking` payload (`{ type: 'enabled', budget_tokens: … }`) that Anthropic's
90
+
API expects, and streamed responses deliver `reasoning` parts as they arrive so
91
+
you can render the chain-of-thought incrementally.
92
+
93
+
### Document Citations
94
+
95
+
Claude can cite specific parts of documents you provide, making it easy to trace
96
+
where information in the response came from. Use the `anthropicDocument()`
97
+
helper to create citable documents. For more details, see the
-`url` - PDFs accessible via URL (returns `page_location` citations)
140
+
-`content` - Custom content blocks with text/images (returns
141
+
`content_block_location` citations)
142
+
-`file` - File references from Anthropic's Files API, beta API only (returns
143
+
`page_location` citations)
144
+
145
+
Citations are returned in the response parts' metadata and include information
146
+
about the document index, cited text, and location (character indices, page
147
+
numbers, or block indices depending on the source type).
83
148
84
149
### Beta API Limitations
85
150
86
-
The beta API surface provides access to experimental features, but some server-managed tool blocks are not yet supported by this plugin. The following beta API features will cause an error if encountered:
151
+
The beta API surface provides access to experimental features, but some
152
+
server-managed tool blocks are not yet supported by this plugin. The following
153
+
beta API features will cause an error if encountered:
87
154
88
155
-`web_fetch_tool_result`
89
156
-`code_execution_tool_result`
@@ -93,18 +160,19 @@ The beta API surface provides access to experimental features, but some server-m
93
160
-`mcp_tool_use`
94
161
-`container_upload`
95
162
96
-
Note that `server_tool_use` and `web_search_tool_result` ARE supported and work with both stable and beta APIs.
163
+
Note that `server_tool_use` and `web_search_tool_result` ARE supported and work
@@ -169,22 +238,29 @@ This approach is useful for:
169
238
170
239
## Acknowledgements
171
240
172
-
This plugin builds on the community work published as [`genkitx-anthropic`](https://github.com/BloomLabsInc/genkit-plugins/blob/main/plugins/anthropic/README.md) by Bloom Labs Inc. Their Apache 2.0–licensed implementation provided the foundation for this maintained package.
241
+
This plugin builds on the community work published as
by Bloom Labs Inc. Their Apache 2.0–licensed implementation provided the
244
+
foundation for this maintained package.
173
245
174
246
## Contributing
175
247
176
-
Want to contribute to the project? That's awesome! Head over to our [Contribution Guidelines](CONTRIBUTING.md).
248
+
Want to contribute to the project? That's awesome! Head over to our
249
+
[Contribution Guidelines](CONTRIBUTING.md).
177
250
178
251
## Need support?
179
252
180
253
> [!NOTE]
181
-
> This repository depends on Google's Firebase Genkit. For issues and questions related to Genkit, please refer to instructions available in [Genkit's repository](https://github.com/firebase/genkit).
182
-
254
+
> This repository depends on Google's Firebase Genkit. For issues and questions
255
+
> related to Genkit, please refer to instructions available in
0 commit comments