Skip to content

Commit d441b46

Browse files
committed
docs(readme): better documentation for vertex and bedrock
1 parent 52bed05 commit d441b46

2 files changed

Lines changed: 56 additions & 4 deletions

File tree

README.md

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ await anthropic.beta.messages.batches.create({
163163
});
164164
```
165165

166-
167166
### Getting results from a batch
168167

169168
Once a Message Batch has been processed, indicated by `.processing_status === 'ended'`, you can access the results with `.batches.results()`
@@ -172,7 +171,7 @@ Once a Message Batch has been processed, indicated by `.processing_status === 'e
172171
const results = await anthropic.beta.messages.batches.results(batch_id);
173172
for await (const entry of results) {
174173
if (entry.result.type === 'succeeded') {
175-
console.log(entry.result.message.content)
174+
console.log(entry.result.message.content);
176175
}
177176
}
178177
```
@@ -183,7 +182,60 @@ This SDK provides beta support for tool use, aka function calling. More details
183182

184183
## AWS Bedrock
185184

186-
We provide support for the [Anthropic Bedrock API](https://aws.amazon.com/bedrock/claude/) through a [separate package](https://github.com/anthropics/anthropic-sdk-typescript/tree/main/packages/bedrock-sdk).
185+
We provide support for the [Anthropic Bedrock API](https://aws.amazon.com/bedrock/claude/) through a [separate package](https://github.com/anthropics/anthropic-sdk-typescript/tree/main/packages/bedrock-sdk) which reads the [default config](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html).
186+
187+
```ts
188+
import { AnthropicBedrock } from '@anthropic-ai/bedrock-sdk';
189+
190+
// Note: this assumes you have configured AWS credentials in a way
191+
// that the AWS Node SDK will recognize, typically a shared `~/.aws/credentials`
192+
// file or `AWS_ACCESS_KEY_ID` & `AWS_SECRET_ACCESS_KEY` environment variables.
193+
//
194+
// https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials-node.html
195+
const client = new AnthropicBedrock();
196+
197+
async function main() {
198+
const message = await client.messages.create({
199+
model: 'anthropic.claude-3-sonnet-20240229-v1:0',
200+
messages: [
201+
{
202+
role: 'user',
203+
content: 'Hello!',
204+
},
205+
],
206+
max_tokens: 1024,
207+
});
208+
console.log(message);
209+
}
210+
211+
main();
212+
```
213+
214+
## Google Vertex
215+
216+
We provide support for the [Google Vertex API](https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/use-claude) through a [separate package](https://github.com/anthropics/anthropic-sdk-typescript/tree/main/packages/vertex-sdk) which uses [google-auth-library](https://github.com/googleapis/google-auth-library-nodejs) for authentication. `google-auth-library` which by default reads from [Application Default Credentials](https://cloud.google.com/docs/authentication/application-default-credentials) and a number of different authentication methods. If needed you can supply your own `GoogleAuth` instance via the `googleAuth` option.
217+
218+
```ts
219+
import { AnthropicVertex } from '@anthropic-ai/vertex-sdk';
220+
221+
const client = new AnthropicVertex();
222+
223+
async function main() {
224+
const message = await client.messages.create({
225+
model: 'claude-3-sonnet@20240229',
226+
messages: [
227+
{
228+
role: 'user',
229+
content: 'Hello!',
230+
},
231+
],
232+
max_tokens: 1024,
233+
});
234+
console.log(message);
235+
}
236+
237+
main();
238+
```
187239

188240
## Handling errors
189241

packages/bedrock-sdk/examples/demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { AnthropicBedrock } from '@anthropic-ai/bedrock-sdk';
44

55
// Note: this assumes you have configured AWS credentials in a way
6-
// that the AWS Node SDK will recognise, typicaly a shared `~/.aws/credentials`
6+
// that the AWS Node SDK will recognise, typically a shared `~/.aws/credentials`
77
// file or `AWS_ACCESS_KEY_ID` & `AWS_SECRET_ACCESS_KEY` environment variables.
88
//
99
// https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials-node.html

0 commit comments

Comments
 (0)