genkitx-aws-bedrock
Version:
Genkit AI framework plugin for AWS Bedrock APIs.
1,267 lines (1,266 loc) • 65.3 kB
JavaScript
"use strict";
/**
* Copyright 2026 Xavier Portilla Edo
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable @typescript-eslint/no-explicit-any */
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __asyncValues = (this && this.__asyncValues) || function (o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.metaLlama3370BInstruct = exports.metaLlama4Scout17BInstruct = exports.metaLlama4Maverick17BInstruct = exports.ai21Jurassic2UltraV1 = exports.ai21Jurassic2MidV1 = exports.ai21JambaInstructV1 = exports.ai21Jamba15MiniV1 = exports.ai21Jamba15LargeV1 = exports.mistral8x7BInstructV01 = exports.mistral7BInstructV02 = exports.mistralSmall2402V1 = exports.mistralLarge2402V1 = exports.pixtralLarge2502V1 = exports.mistralLarge3675BInstruct = exports.mistralMinistral33BInstruct = exports.mistralMinistral38BInstruct = exports.mistralMinistral314BInstruct = exports.mistralMagistralSmall2509 = exports.anthropicClaudeInstantV1 = exports.anthropicClaude2V1 = exports.anthropicClaude21V1 = exports.anthropicClaude3SonnetV1 = exports.anthropicClaude35SonnetV1 = exports.anthropicClaude35SonnetV2 = exports.anthropicClaude37SonnetV1 = exports.anthropicClaude3OpusV1 = exports.anthropicClaude3HaikuV1 = exports.anthropicClaude35HaikuV1 = exports.anthropicClaudeSonnet46V1 = exports.anthropicClaudeOpus46V1 = exports.anthropicClaudeOpus45V1 = exports.anthropicClaudeHaiku45V1 = exports.anthropicClaudeSonnet45V1 = exports.anthropicClaudeOpus41V1 = exports.anthropicClaudeOpus4V1 = exports.anthropicClaudeSonnet4V1 = exports.cohereCommandV14 = exports.cohereCommandLightV14 = exports.cohereCommandRPlusV1 = exports.cohereCommandRV1 = exports.cohereRerank35V1 = exports.googleGemma312BIt = exports.amazonTitanTextG1LiteV1 = exports.amazonTitanTextG1ExpressV1 = exports.amazonTitanTextG1PremierV1 = exports.amazonNovaMicroV1 = exports.amazonNovaLiteV1 = exports.amazonNovaProV1 = exports.amazonNovaPremierV1 = exports.amazonNova2LiteV1 = void 0;
exports.SUPPORTED_AWS_BEDROCK_MODELS = exports.metaLlama38BInstruct = exports.metaLlama370BInstruct = exports.metaLlama318BInstruct = exports.metaLlama3170BInstruct = exports.metaLlama3290BInstruct = exports.metaLlama323BInstruct = exports.metaLlama321BInstruct = exports.metaLlama3211BInstruct = void 0;
exports.toAwsBedrockTextAndMedia = toAwsBedrockTextAndMedia;
exports.getSystemMessage = getSystemMessage;
exports.toAwsBedrockMessages = toAwsBedrockMessages;
exports.toAwsBedrockRequestBody = toAwsBedrockRequestBody;
exports.awsBedrockModel = awsBedrockModel;
const genkit_1 = require("genkit");
const model_1 = require("genkit/model");
const plugin_1 = require("genkit/plugin");
const client_bedrock_runtime_1 = require("@aws-sdk/client-bedrock-runtime");
const amazonNova2LiteV1 = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.amazon.nova-2-lite-v1:0`,
info: {
versions: [`${inferenceRegion}.amazon.nova-2-lite-v1:0`],
label: "Amazon - Nova 2 Lite V1",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.amazonNova2LiteV1 = amazonNova2LiteV1;
const amazonNovaPremierV1 = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.amazon.nova-premier-v1:0`,
info: {
versions: [`${inferenceRegion}.amazon.nova-premier-v1:0`],
label: "Amazon - Nova Premier V1",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.amazonNovaPremierV1 = amazonNovaPremierV1;
const amazonNovaProV1 = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.amazon.nova-pro-v1:0`,
info: {
versions: [`${inferenceRegion}.amazon.nova-pro-v1:0`],
label: "Amazon - Nova Pro V1",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.amazonNovaProV1 = amazonNovaProV1;
exports.amazonNovaLiteV1 = (0, model_1.modelRef)({
name: "aws-bedrock/amazon.nova-lite-v1:0",
info: {
versions: ["amazon.nova-lite-v1:0"],
label: "Amazon - Nova Lite V1",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.amazonNovaMicroV1 = (0, model_1.modelRef)({
name: "aws-bedrock/amazon.nova-micro-v1:0",
info: {
versions: ["amazon.nova-micro-v1:0"],
label: "Amazon - Nova Micro V1",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.amazonTitanTextG1PremierV1 = (0, model_1.modelRef)({
name: "aws-bedrock/amazon.titan-text-premier-v1:0",
info: {
versions: ["amazon.titan-text-premier-v1:0"],
label: "Amazon - Titan Text Premier G1 V1",
supports: {
multiturn: true,
tools: false,
media: false,
systemRole: false,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.amazonTitanTextG1ExpressV1 = (0, model_1.modelRef)({
name: "aws-bedrock/amazon.titan-text-express-v1",
info: {
versions: ["amazon.titan-text-express-v1"],
label: "Amazon - Titan Text Express G1 V1",
supports: {
multiturn: true,
tools: false,
media: false,
systemRole: false,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.amazonTitanTextG1LiteV1 = (0, model_1.modelRef)({
name: "aws-bedrock/amazon.titan-text-lite-v1",
info: {
versions: ["amazon.titan-text-lite-v1"],
label: "Amazon - Titan Text Lite G1 V1",
supports: {
multiturn: true,
tools: false,
media: false,
systemRole: false,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.googleGemma312BIt = (0, model_1.modelRef)({
name: "aws-bedrock/google.gemma-3-12b-it",
info: {
versions: ["google.gemma-3-12b-it"],
label: "Google - Gemma 3 12B IT",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
constrained: "all"
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.cohereRerank35V1 = (0, model_1.modelRef)({
name: "aws-bedrock/cohere.rerank-v3-5:0",
info: {
versions: ["cohere.rerank-v3-5:0"],
label: "Cohere - Rerank 3.5",
supports: {
multiturn: false,
tools: false,
media: false,
systemRole: false,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.cohereCommandRV1 = (0, model_1.modelRef)({
name: "aws-bedrock/cohere.command-r-v1:0",
info: {
versions: ["cohere.command-r-v1:0"],
label: "Cohere - Command R",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.cohereCommandRPlusV1 = (0, model_1.modelRef)({
name: "aws-bedrock/cohere.command-r-plus-v1:0",
info: {
versions: ["cohere.command-r-plus-v1:0"],
label: "Cohere - Command R+",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.cohereCommandLightV14 = (0, model_1.modelRef)({
name: "aws-bedrock/cohere.command-light-text-v14",
info: {
versions: ["cohere.command-light-text-v14"],
label: "Cohere - Command Light V14",
supports: {
multiturn: true,
tools: false,
media: false,
systemRole: false,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.cohereCommandV14 = (0, model_1.modelRef)({
name: "aws-bedrock/cohere.command-text-v14",
info: {
versions: ["cohere.command-text-v14"],
label: "Cohere - Command V14",
supports: {
multiturn: true,
tools: false,
media: false,
systemRole: false,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
const anthropicClaudeSonnet4V1 = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.anthropic.claude-sonnet-4-20250514-v1:0`,
info: {
versions: [`${inferenceRegion}.anthropic.claude-sonnet-4-20250514-v1:0`],
label: "Anthropic - Claude Sonnet 4 V1",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.anthropicClaudeSonnet4V1 = anthropicClaudeSonnet4V1;
const anthropicClaudeOpus4V1 = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.anthropic.claude-opus-4-20250514-v1:0`,
info: {
versions: [`${inferenceRegion}.anthropic.claude-opus-4-20250514-v1:0`],
label: "Anthropic - Claude Opus 4 (Legacy) V1",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.anthropicClaudeOpus4V1 = anthropicClaudeOpus4V1;
const anthropicClaudeOpus41V1 = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.anthropic.claude-opus-4-1-20250805-v1:0`,
info: {
versions: [`${inferenceRegion}.anthropic.claude-opus-4-1-20250805-v1:0`],
label: "Anthropic - Claude Opus 4.1 V1",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.anthropicClaudeOpus41V1 = anthropicClaudeOpus41V1;
const anthropicClaudeSonnet45V1 = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.anthropic.claude-sonnet-4-5-20250929-v1:0`,
info: {
versions: [`${inferenceRegion}.anthropic.claude-sonnet-4-5-20250929-v1:0`],
label: "Anthropic - Claude Sonnet 4.5 V1",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
constrained: "all"
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.anthropicClaudeSonnet45V1 = anthropicClaudeSonnet45V1;
const anthropicClaudeHaiku45V1 = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.anthropic.claude-haiku-4-5-20251001-v1:0`,
info: {
versions: [`${inferenceRegion}.anthropic.claude-haiku-4-5-20251001-v1:0`],
label: "Anthropic - Claude Haiku 4.5 V1",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
constrained: "all"
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.anthropicClaudeHaiku45V1 = anthropicClaudeHaiku45V1;
const anthropicClaudeOpus45V1 = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.anthropic.claude-opus-4-5-20251101-v1:0`,
info: {
versions: [`${inferenceRegion}.anthropic.claude-opus-4-5-20251101-v1:0`],
label: "Anthropic - Claude Opus 4.5 V1",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
constrained: "all"
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.anthropicClaudeOpus45V1 = anthropicClaudeOpus45V1;
const anthropicClaudeOpus46V1 = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.anthropic.claude-opus-4-6-v1`,
info: {
versions: [`${inferenceRegion}.anthropic.claude-opus-4-6-v1`],
label: "Anthropic - Claude Opus 4.6 V1",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
constrained: "all"
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.anthropicClaudeOpus46V1 = anthropicClaudeOpus46V1;
const anthropicClaudeSonnet46V1 = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.anthropic.claude-sonnet-4-6`,
info: {
versions: [`${inferenceRegion}.anthropic.claude-sonnet-4-6`],
label: "Anthropic - Claude Sonnet 4.6",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
constrained: "all"
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.anthropicClaudeSonnet46V1 = anthropicClaudeSonnet46V1;
const anthropicClaude35HaikuV1 = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.anthropic.claude-3-5-haiku-20241022-v1:0`,
info: {
versions: [`${inferenceRegion}.anthropic.claude-3-5-haiku-20241022-v1:0`],
label: "Anthropic - Claude 3.5 Haiku V1",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.anthropicClaude35HaikuV1 = anthropicClaude35HaikuV1;
const anthropicClaude3HaikuV1 = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.anthropic.claude-3-haiku-20240307-v1:0`,
info: {
versions: [`${inferenceRegion}.anthropic.claude-3-haiku-20240307-v1:0`],
label: "Anthropic - Claude 3 Haiku V1",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.anthropicClaude3HaikuV1 = anthropicClaude3HaikuV1;
const anthropicClaude3OpusV1 = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.anthropic.claude-3-opus-20240229-v1:0`,
info: {
versions: [`${inferenceRegion}.anthropic.claude-3-opus-20240229-v1:0`],
label: "Anthropic - Claude 3 Opus V1",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.anthropicClaude3OpusV1 = anthropicClaude3OpusV1;
const anthropicClaude37SonnetV1 = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.anthropic.claude-3-7-sonnet-20250219-v1:0`,
info: {
versions: [
`${inferenceRegion}.anthropic.claude-3-7-sonnet-20250219-v1:0`,
],
label: "Anthropic - Claude 3.7 Sonnet V1",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.anthropicClaude37SonnetV1 = anthropicClaude37SonnetV1;
const anthropicClaude35SonnetV2 = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.anthropic.claude-3-5-sonnet-20241022-v2:0`,
info: {
versions: [
`${inferenceRegion}.anthropic.claude-3-5-sonnet-20241022-v2:0`,
],
label: "Anthropic - Claude 3.5 Sonnet V2",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.anthropicClaude35SonnetV2 = anthropicClaude35SonnetV2;
const anthropicClaude35SonnetV1 = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.anthropic.claude-3-5-sonnet-20240620-v1:0`,
info: {
versions: [
`${inferenceRegion}.anthropic.claude-3-5-sonnet-20240620-v1:0`,
],
label: "Anthropic - Claude 3.5 Sonnet V1",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.anthropicClaude35SonnetV1 = anthropicClaude35SonnetV1;
const anthropicClaude3SonnetV1 = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.anthropic.claude-3-sonnet-20240229-v1:0`,
info: {
versions: [`${inferenceRegion}.anthropic.claude-3-sonnet-20240229-v1:0`],
label: "Anthropic - Claude 3 Sonnet V1",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.anthropicClaude3SonnetV1 = anthropicClaude3SonnetV1;
exports.anthropicClaude21V1 = (0, model_1.modelRef)({
name: "aws-bedrock/anthropic.claude-v2:1",
info: {
versions: ["anthropic.claude-v2:1"],
label: "Anthropic - Claude 2.1 V1",
supports: {
multiturn: true,
tools: false,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.anthropicClaude2V1 = (0, model_1.modelRef)({
name: "aws-bedrock/anthropic.claude-v2",
info: {
versions: ["anthropic.claude-v2"],
label: "Anthropic - Claude 2 V1",
supports: {
multiturn: true,
tools: false,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.anthropicClaudeInstantV1 = (0, model_1.modelRef)({
name: "aws-bedrock/anthropic.claude-instant-v1",
info: {
versions: ["anthropic.claude-instant-v1"],
label: "Anthropic - Claude Instant V1",
supports: {
multiturn: true,
tools: false,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.mistralMagistralSmall2509 = (0, model_1.modelRef)({
name: "aws-bedrock/mistral.magistral-small-2509",
info: {
versions: ["mistral.magistral-small-2509"],
label: "Mistral - Magistral Small 2509",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
constrained: "all"
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.mistralMinistral314BInstruct = (0, model_1.modelRef)({
name: "aws-bedrock/mistral.ministral-3-14b-instruct",
info: {
versions: ["mistral.ministral-3-14b-instruct"],
label: "Mistral - Ministral 3 14B Instruct",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
constrained: "all"
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.mistralMinistral38BInstruct = (0, model_1.modelRef)({
name: "aws-bedrock/mistral.ministral-3-8b-instruct",
info: {
versions: ["mistral.ministral-3-8b-instruct"],
label: "Mistral - Ministral 3 8B Instruct",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
constrained: "all"
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.mistralMinistral33BInstruct = (0, model_1.modelRef)({
name: "aws-bedrock/mistral.ministral-3-3b-instruct",
info: {
versions: ["mistral.ministral-3-3b-instruct"],
label: "Mistral - Ministral 3 3B Instruct",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
constrained: "all"
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.mistralLarge3675BInstruct = (0, model_1.modelRef)({
name: "aws-bedrock/mistral.mistral-large-3-675b-instruct",
info: {
versions: ["mistral.mistral-large-3-675b-instruct"],
label: "Mistral - Large 3 (675B) Instruct",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
constrained: "all"
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.pixtralLarge2502V1 = (0, model_1.modelRef)({
name: "aws-bedrock/mistral.pixtral-large-2502-v1:0",
info: {
versions: ["mistral.pixtral-large-2502-v1:0"],
label: "Mistral - Pixtral Large (25.02)",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.mistralLarge2402V1 = (0, model_1.modelRef)({
name: "aws-bedrock/mistral.mistral-large-2402-v1:0",
info: {
versions: ["mistral.mistral-large-2402-v1:0"],
label: "Mistral - Large (24.02)",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.mistralSmall2402V1 = (0, model_1.modelRef)({
name: "aws-bedrock/mistral.mistral-small-2402-v1:0",
info: {
versions: ["mistral.mistral-small-2402-v1:0"],
label: "Mistral - Small (24.02)",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.mistral7BInstructV02 = (0, model_1.modelRef)({
name: "aws-bedrock/mistral.mistral-7b-instruct-v0:2",
info: {
versions: ["mistral.mistral-7b-instruct-v0:2"],
label: "Mistral - 7B Instruct",
supports: {
multiturn: true,
tools: false,
media: false,
systemRole: false,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.mistral8x7BInstructV01 = (0, model_1.modelRef)({
name: "aws-bedrock/mistral.mixtral-8x7b-instruct-v0:1",
info: {
versions: ["mistral.mixtral-8x7b-instruct-v0:1"],
label: "Mistral - 8x7B Instruct",
supports: {
multiturn: true,
tools: false,
media: false,
systemRole: false,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.ai21Jamba15LargeV1 = (0, model_1.modelRef)({
name: "aws-bedrock/ai21.jamba-1-5-large-v1:0",
info: {
versions: ["ai21.jamba-1-5-large-v1:0"],
label: "AI21 - Jambda 1.5 Large",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.ai21Jamba15MiniV1 = (0, model_1.modelRef)({
name: "aws-bedrock/ai21.jamba-1-5-mini-v1:0",
info: {
versions: ["ai21.jamba-1-5-mini-v1:0"],
label: "AI21 - Jambda 1.5 Mini",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.ai21JambaInstructV1 = (0, model_1.modelRef)({
name: "aws-bedrock/ai21.jamba-instruct-v1:0",
info: {
versions: ["ai21.jamba-instruct-v1:0"],
label: "AI21 - Jambda Instruct",
supports: {
multiturn: true,
tools: false,
media: false,
systemRole: false,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.ai21Jurassic2MidV1 = (0, model_1.modelRef)({
name: "aws-bedrock/ai21.j2-mid-v1",
info: {
versions: ["ai21.j2-mid-v1"],
label: "AI21 - Jurassic-2 Mid",
supports: {
multiturn: true,
tools: false,
media: false,
systemRole: false,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.ai21Jurassic2UltraV1 = (0, model_1.modelRef)({
name: "aws-bedrock/ai21.j2-ultra-v1",
info: {
versions: ["ai21.j2-ultra-v1"],
label: "AI21 - Jurassic-2 Ultra",
supports: {
multiturn: true,
tools: false,
media: false,
systemRole: false,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
const metaLlama4Maverick17BInstruct = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.meta.llama4-maverick-17b-instruct-v1:0`,
info: {
versions: [`${inferenceRegion}.meta.llama4-maverick-17b-instruct-v1:0`],
label: "Meta - Llama 4 Maverick 17b Instruct",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.metaLlama4Maverick17BInstruct = metaLlama4Maverick17BInstruct;
const metaLlama4Scout17BInstruct = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.meta.llama4-scout-17b-instruct-v1:0`,
info: {
versions: [`${inferenceRegion}.meta.llama4-scout-17b-instruct-v1:0`],
label: "Meta - Llama 4 Scout 17b Instruct",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.metaLlama4Scout17BInstruct = metaLlama4Scout17BInstruct;
const metaLlama3370BInstruct = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.meta.llama3-3-70b-instruct-v1:0`,
info: {
versions: [`${inferenceRegion}.meta.llama3-3-70b-instruct-v1:0`],
label: "Meta - Llama 3.3 70b Instruct",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.metaLlama3370BInstruct = metaLlama3370BInstruct;
const metaLlama3211BInstruct = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.meta.llama3-2-11b-instruct-v1:0`,
info: {
versions: [`${inferenceRegion}.meta.llama3-2-11b-instruct-v1:0`],
label: "Meta - Llama 3.2 11b Instruct",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.metaLlama3211BInstruct = metaLlama3211BInstruct;
const metaLlama321BInstruct = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.meta.llama3-2-1b-instruct-v1:0`,
info: {
versions: [`${inferenceRegion}.meta.llama3-2-1b-instruct-v1:0`],
label: "Meta - Llama 3.2 1b Instruct",
supports: {
multiturn: true,
tools: false,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.metaLlama321BInstruct = metaLlama321BInstruct;
const metaLlama323BInstruct = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.meta.llama3-2-3b-instruct-v1:0`,
info: {
versions: [`${inferenceRegion}.meta.llama3-2-3b-instruct-v1:0`],
label: "Meta - Llama 3.2 3b Instruct",
supports: {
multiturn: true,
tools: false,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.metaLlama323BInstruct = metaLlama323BInstruct;
const metaLlama3290BInstruct = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.meta.llama3-2-90b-instruct-v1:0`,
info: {
versions: [`${inferenceRegion}.meta.llama3-2-90b-instruct-v1:0`],
label: "Meta - Llama 3.2 90b Instruct",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.metaLlama3290BInstruct = metaLlama3290BInstruct;
const metaLlama3170BInstruct = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.meta.llama3-1-70b-instruct-v1:0`,
info: {
versions: [`${inferenceRegion}.meta.llama3-1-70b-instruct-v1:0`],
label: "Meta - Llama 3.1 70b Instruct",
supports: {
multiturn: true,
tools: false,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.metaLlama3170BInstruct = metaLlama3170BInstruct;
const metaLlama318BInstruct = (inferenceRegion = "us") => {
return (0, model_1.modelRef)({
name: `aws-bedrock/${inferenceRegion}.meta.llama3-1-8b-instruct-v1:0`,
info: {
versions: [`${inferenceRegion}.meta.llama3-1-8b-instruct-v1:0`],
label: "Meta - Llama 3.1 8b Instruct",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
};
exports.metaLlama318BInstruct = metaLlama318BInstruct;
exports.metaLlama370BInstruct = (0, model_1.modelRef)({
name: "aws-bedrock/meta.llama3-70b-instruct-v1:0",
info: {
versions: ["meta.llama3-70b-instruct-v1:0"],
label: "Meta - Llama 3 70b Instruct",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
exports.metaLlama38BInstruct = (0, model_1.modelRef)({
name: "aws-bedrock/meta.llama3-8b-instruct-v1:0",
info: {
versions: ["meta.llama3-8b-instruct-v1:0"],
label: "Meta - Llama 3 8b Instruct",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: genkit_1.GenerationCommonConfigSchema,
});
const SUPPORTED_AWS_BEDROCK_MODELS = (inferenceRegion = "us") => {
return {
[`${inferenceRegion}.amazon.nova-pro-v1:0`]: (0, exports.amazonNovaProV1)(inferenceRegion),
"amazon.nova-lite-v1:0": exports.amazonNovaLiteV1,
"amazon.nova-micro-v1:0": exports.amazonNovaMicroV1,
"amazon.titan-text-premier-v1:0": exports.amazonTitanTextG1PremierV1,
"amazon.titan-text-express-v1": exports.amazonTitanTextG1ExpressV1,
"amazon.titan-text-lite-v1": exports.amazonTitanTextG1LiteV1,
"cohere.command-r-v1:0": exports.cohereCommandRV1,
"cohere.command-r-plus-v1:0": exports.cohereCommandRPlusV1,
"cohere.command-light-text-v14": exports.cohereCommandLightV14,
"cohere.command-text-v14": exports.cohereCommandV14,
"mistral.mistral-large-2402-v1:0": exports.mistralLarge2402V1,
"mistral.mistral-small-2402-v1:0": exports.mistralSmall2402V1,
"mistral.mistral-7b-instruct-v0:2": exports.mistral7BInstructV02,
"mistral.mixtral-8x7b-instruct-v0:1": exports.mistral8x7BInstructV01,
"ai21.jamba-1-5-large-v1:0": exports.ai21Jamba15LargeV1,
"ai21.jamba-1-5-mini-v1:0": exports.ai21Jamba15MiniV1,
"ai21.jamba-instruct-v1:0": exports.ai21JambaInstructV1,
"ai21.j2-mid-v1": exports.ai21Jurassic2MidV1,
"ai21.j2-ultra-v1": exports.ai21Jurassic2UltraV1,
[`${inferenceRegion}.meta.llama3-3-70b-instruct-v1:0`]: (0, exports.metaLlama3370BInstruct)(inferenceRegion),
[`${inferenceRegion}.meta.llama3-2-11b-instruct-v1:0`]: (0, exports.metaLlama3211BInstruct)(inferenceRegion),
[`${inferenceRegion}.meta.llama3-2-1b-instruct-v1:0`]: (0, exports.metaLlama321BInstruct)(inferenceRegion),
[`${inferenceRegion}.meta.llama3-2-3b-instruct-v1:0`]: (0, exports.metaLlama323BInstruct)(inferenceRegion),
[`${inferenceRegion}.meta.llama3-2-90b-instruct-v1:0`]: (0, exports.metaLlama3290BInstruct)(inferenceRegion),
[`${inferenceRegion}.meta.llama3-1-70b-instruct-v1:0`]: (0, exports.metaLlama3170BInstruct)(inferenceRegion),
[`${inferenceRegion}.meta.llama3-1-8b-instruct-v1:0`]: (0, exports.metaLlama318BInstruct)(inferenceRegion),
"meta.llama3-70b-instruct-v1:0": exports.metaLlama370BInstruct,
"meta.llama3-8b-instruct-v1:0": exports.metaLlama38BInstruct,
"anthropic.claude-v2:1": exports.anthropicClaude21V1,
"anthropic.claude-v2": exports.anthropicClaude2V1,
"anthropic.claude-instant-v1": exports.anthropicClaudeInstantV1,
[`${inferenceRegion}.anthropic.claude-3-5-haiku-20241022-v1:0`]: (0, exports.anthropicClaude35HaikuV1)(inferenceRegion),
[`${inferenceRegion}.anthropic.claude-3-7-sonnet-20250219-v1:0`]: (0, exports.anthropicClaude37SonnetV1)(inferenceRegion),
[`${inferenceRegion}.anthropic.claude-3-5-sonnet-20241022-v2:0`]: (0, exports.anthropicClaude35SonnetV2)(inferenceRegion),
[`${inferenceRegion}.anthropic.claude-3-5-sonnet-20240620-v1:0`]: (0, exports.anthropicClaude35SonnetV1)(inferenceRegion),
[`${inferenceRegion}.anthropic.claude-3-opus-20240229-v1:0`]: (0, exports.anthropicClaude3OpusV1)(inferenceRegion),
[`${inferenceRegion}.anthropic.claude-3-haiku-20240307-v1:0`]: (0, exports.anthropicClaude3HaikuV1)(inferenceRegion),
[`${inferenceRegion}.anthropic.claude-3-sonnet-20240229-v1:0`]: (0, exports.anthropicClaude3SonnetV1)(inferenceRegion),
// Added models
[`${inferenceRegion}.anthropic.claude-sonnet-4-20250514-v1:0`]: (0, exports.anthropicClaudeSonnet4V1)(inferenceRegion),
[`${inferenceRegion}.anthropic.claude-opus-4-20250514-v1:0`]: (0, exports.anthropicClaudeOpus4V1)(inferenceRegion),
[`${inferenceRegion}.anthropic.claude-opus-4-1-20250805-v1:0`]: (0, exports.anthropicClaudeOpus41V1)(inferenceRegion),
[`${inferenceRegion}.anthropic.claude-sonnet-4-5-20250929-v1:0`]: (0, exports.anthropicClaudeSonnet45V1)(inferenceRegion),
[`${inferenceRegion}.anthropic.claude-haiku-4-5-20251001-v1:0`]: (0, exports.anthropicClaudeHaiku45V1)(inferenceRegion),
[`${inferenceRegion}.anthropic.claude-opus-4-5-20251101-v1:0`]: (0, exports.anthropicClaudeOpus45V1)(inferenceRegion),
[`${inferenceRegion}.anthropic.claude-opus-4-6-v1`]: (0, exports.anthropicClaudeOpus46V1)(inferenceRegion),
[`${inferenceRegion}.anthropic.claude-sonnet-4-6`]: (0, exports.anthropicClaudeSonnet46V1)(inferenceRegion),
[`${inferenceRegion}.meta.llama4-maverick-17b-instruct-v1:0`]: (0, exports.metaLlama4Maverick17BInstruct)(inferenceRegion),
[`${inferenceRegion}.meta.llama4-scout-17b-instruct-v1:0`]: (0, exports.metaLlama4Scout17BInstruct)(inferenceRegion),
[`${inferenceRegion}.amazon.nova-2-lite-v1:0`]: (0, exports.amazonNova2LiteV1)(inferenceRegion),
[`${inferenceRegion}.amazon.nova-premier-v1:0`]: (0, exports.amazonNovaPremierV1)(inferenceRegion),
"mistral.magistral-small-2509": exports.mistralMagistralSmall2509,
"mistral.ministral-3-14b-instruct": exports.mistralMinistral314BInstruct,
"mistral.ministral-3-8b-instruct": exports.mistralMinistral38BInstruct,
"mistral.ministral-3-3b-instruct": exports.mistralMinistral33BInstruct,
"mistral.mistral-large-3-675b-instruct": exports.mistralLarge3675BInstruct,
"mistral.pixtral-large-2502-v1:0": exports.pixtralLarge2502V1,
"google.gemma-3-12b-it": exports.googleGemma312BIt,
"cohere.rerank-v3-5:0": exports.cohereRerank35V1,
};
};
exports.SUPPORTED_AWS_BEDROCK_MODELS = SUPPORTED_AWS_BEDROCK_MODELS;
function toAwsBedrockbRole(role) {
switch (role) {
case "user":
return "user";
case "model":
return "assistant";
case "system":
return "system";
case "tool":
return "tool";
default:
throw new Error(`role ${role} doesn't map to an AWS Bedrock role.`);
}
}
function toAwsBedrockTool(tool) {
// Handle both inputSchema and inputJsonSchema (from MCP tools)
// inputJsonSchema is mutually exclusive with inputSchema in ToolConfig
const schema = tool.inputSchema || tool.inputJsonSchema;
return {
toolSpec: {
name: tool.name,
description: tool.description,
inputSchema: schema ? { json: schema } : undefined,
},
};
}
const regex = /data:.*base64,/;
const getDataPart = (dataUrl) => dataUrl.replace(regex, "");
/**
* Extracts the content type from a data URL.
* @param url The data URL to parse.
* @returns The content type, or null if invalid.
*/
function extractContentTypeFromDataUrl(url) {
const match = url.match(/^data:([^;]+);base64,/);
return match ? match[1] : null;
}
/**
* Map of MIME types to Bedrock document formats.
*/
const MIME_TO_DOCUMENT_FORMAT = {
"application/pdf": "pdf",
"text/csv": "csv",
"text/plain": "txt",
"text/html": "html",
"text/markdown": "md",
"application/msword": "doc",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
"application/vnd.ms-excel": "xls",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
};
/**
* Checks if a content type is an image type.
* @param contentType The content type to check.
* @returns True if the content type is an image type.
*/
function isImageContentType(contentType) {
if (!contentType)
return false;
return contentType.startsWith("image/");
}
/**
* Gets the Bedrock document format from a MIME type.
* @param contentType The MIME type.
* @returns The Bedrock document format, or undefined if not supported.
*/
function getDocumentFormat(contentType) {
return MIME_TO_DOCUMENT_FORMAT[contentType];
}
/**
* Generates a unique filename from a document format.
* AWS Bedrock document names can only contain alphanumeric characters,
* whitespace, hyphens, parentheses, and square brackets (no dots/periods).
* @param format The document format.
* @returns A valid unique document name.
*/
function generateFilenameFromFormat(format) {
return `document-${format}-${Math.random().toString(36).slice(2)}`;
}
function toAwsBedrockTextAndMedia(part, imageFormat) {
if (part.text) {
return {
text: part.text,
};
}
else if (part.media) {
// Determine the content type from the media part or data URL
let contentType = part.media.contentType;
if (!contentType && part.media.url.startsWith("data:")) {
contentType = extractContentTypeFromDataUrl(part.media.url) || undefined;
}
const dataBuffer = new Uint8Array(Buffer.from(getDataPart(part.media.url), "base64"));
// Handle media based on content type
if (contentType) {
const docFormat = getDocumentFormat(contentType);
if (docFormat) {
return {
document: {
name: generateFilenameFromFormat(docFormat),
format: docFormat,
source: { bytes: dataBuffer },
},
};
}
if (isImageContentType(contentType)) {
return {
image: {
source: { bytes: dataBuffer },
format: imageFormat,
},
};
}
// For unsupported content types, throw an error
throw Error(`Unsupported media content type: ${contentType}. Supported types are images and documents (pdf, csv, txt, html, md, doc, docx, xls, xlsx).`);
}
// Default to image when no contentType is provided (preserve legacy behavior)
return {
image: {
source: { bytes: dataBuffer },
format: imageFormat,
},
};
}
throw Error(`Unsupported genkit part fields encountered for current message role: ${part}.`);
}
function getSystemMessage(messages) {
for (const message of messages) {
if (message.role === "system") {
return [
{
text: message.content[0].text,
},
];
}
}
return null;
}
function toAwsBedrockMessages(messages, imageFormat = "png") {
const awsBedrockMsgs = [];
for (const message of messages) {
const msg = new genkit_1.Message(message);
const role = toAwsBedrockbRole(message.role);
switch (role) {
case "system": {
break;
}
case "user": {
const textAndMedia = msg.content.map((part) => toAwsBedrockTextAndMedia(part, imageFormat));
if (textAndMedia.length > 1) {
awsBedrockMsgs.push({
role: role,
content: textAndMedia,
});
}
else {
awsBedrockMsgs.push({
role: role,
content: [
{
text: msg.text,
},
],
});
}
break;
}
case "assistant": {
// Request to call the tool
const toolCalls = msg.content
.filter((part) => part.toolRequest)
.map((part) => {
if (!part.toolRequest) {
throw Error("Mapping genkit message to openai tool call content part but message.toolRequest not provided.");
}
return {
toolUseId: part.toolRequest.ref || "",
name: part.toolRequest.name,
input: part.toolRequest.input,
};
});
if ((toolCalls === null || toolCalls === void 0 ? void 0 : toolCalls.length) > 0) {
awsBedrockMsgs.push({
role: role,
content: toolCalls.map((toolCall) => ({ toolUse: toolCall })),
});
}
else {
awsBedrockMsgs.push({