The API instance to use for making requests.
Optional
auth?: AwsBedrockAuthConfigAuthentication configuration for AWS. Pass AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
here if not running in an AWS environment. Pass AWS_REGION
here if not set in process.env.
Optional
client?: HttpClient<THttpClientOptions>HTTP client to use for requests. If not supplied, the built-in fetch-based implementation will be used.
The model ID as defined by AWS Bedrock.
The AWS Bedrock Model Provider with the specified ModelApi.
import {
Ai21Jurassic2Api,
AmazonTitanTextApi,
CohereGenerateApi,
createAwsBedrockModelProvider,
Llama3ChatApi,
MistralBedrockApi,
} from "generative-ts";
const titanText = createAwsBedrockModelProvider({
api: AmazonTitanTextApi,
modelId: "amazon.titan-text-express-v1",
});
const cohereCommand = createAwsBedrockModelProvider({
api: CohereGenerateApi,
modelId: "cohere.command-text-v14",
});
const llama3 = createAwsBedrockModelProvider({
api: Llama3ChatApi,
modelId: "meta.llama3-8b-instruct-v1:0",
});
const mistral = createAwsBedrockModelProvider({
api: MistralBedrockApi,
modelId: "mistral.mistral-7b-instruct-v0:2",
});
const jurassic = createAwsBedrockModelProvider({
api: Ai21Jurassic2Api,
modelId: "ai21.j2-mid-v1",
});
const params = { $prompt: "Brief history of NY Mets:" };
const responses = await Promise.all([
titanText.sendRequest(params),
cohereCommand.sendRequest(params),
llama3.sendRequest(params),
mistral.sendRequest(params),
jurassic.sendRequest(params),
]);
Creates an AWS Bedrock ModelProvider with the provided ModelApi.
Compatible APIs
Provider Setup and Notes
In the Bedrock service in the AWS Console, use "Request Model Access" to enable access to Bedrock models.
Authorization
If your code is running in an AWS Environment (eg, Lambda) authorization should happen automatically. Otherwise, explicitly pass in
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
toauth
.Region is also specified in
auth
asAWS_REGION
. If not passed, it will be read from process.env.Model Parameters
Model IDs