Skip to content

Commit

Permalink
Merge pull request #48 from ospar0829/main
Browse files Browse the repository at this point in the history
  • Loading branch information
xavidop authored Feb 18, 2025
2 parents 29cb247 + a924691 commit b88ee57
Showing 1 changed file with 59 additions and 11 deletions.
70 changes: 59 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,48 +41,96 @@ if you are using Genkit version `<v0.9.0`, please use the plugin version `v1.9.0

### Configuration

To use the plugin, you need to configure it with your AWS credentials key. You can do this by calling the `genkit` function:
To use the plugin, you need to configure it with your AWS credentials. There are several approaches depending on your environment.

#### Standard Initialization

You can configure the plugin by calling the `genkit` function with your AWS region and model:

```typescript
import { genkit, z } from 'genkit';
import {awsBedrock, amazonNovaProV1} from "genkitx-aws-bedrock";
import { awsBedrock, amazonNovaProV1 } from "genkitx-aws-bedrock";

const ai = genkit({
plugins: [
awsBedrock({ region: "<my-region>" }),
model: amazonNovaProV1,
]
],
model: amazonNovaProV1,
});
```

You can also intialize the plugin in this way if you have set the `AWS_` environment variable:
If you have set the `AWS_` environment variables, you can initialize it like this:

```typescript
import { genkit, z } from 'genkit';
import {awsBedrock, amazonNovaProV1} from "genkitx-aws-bedrock";
import { awsBedrock, amazonNovaProV1 } from "genkitx-aws-bedrock";

const ai = genkit({
plugins: [
awsBedrock(),
model: amazonNovaProV1,
]
],
model: amazonNovaProV1,
});
```

#### Production Environment Authentication

In production environments, it is often necessary to install an additional library to handle authentication. One approach is to use the `@aws-sdk/credential-providers` package:

```typescript
import { fromEnv } from "@aws-sdk/credential-providers";
const ai = genkit({
plugins: [
awsBedrock({
region: "us-east-1",
credentials: fromEnv(),
}),
],
});
```

Ensure you have a `.env` file with the necessary AWS credentials. Remember that the .env file must be added to your .gitignore to prevent sensitive credentials from being exposed.

```
AWS_ACCESS_KEY_ID =
AWS_SECRET_ACCESS_KEY =
```

#### Local Environment Authentication

For local development, you can directly supply the credentials:

```typescript
const ai = genkit({
plugins: [
awsBedrock({
region: "us-east-1",
credentials: {
accessKeyId: awsAccessKeyId.value(),
secretAccessKey: awsSecretAccessKey.value(),
},
}),
],
});
```

Each approach allows you to manage authentication effectively based on your environment needs.


### Configuration with Inference Endpoint

If you want to use a model that uses [Cross-region Inference Endpoints](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html), you can specify the region in the model configuration. Cross-region inference uses inference profiles to increase throughput and improve resiliency by routing your requests across multiple AWS Regions during peak utilization bursts:


```typescript
import { genkit, z } from 'genkit';
import {awsBedrock, amazonNovaProV1} from "genkitx-aws-bedrock";
import {awsBedrock, amazonNovaProV1, anthropicClaude35SonnetV2} from "genkitx-aws-bedrock";

const ai = genkit({
plugins: [
awsBedrock(),
model: anthropicClaude3SonnetV1("us"),
]
],
model: anthropicClaude35SonnetV2("us"),
});
```

Expand Down

0 comments on commit b88ee57

Please sign in to comment.