class PromptRouter
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.Bedrock.Alpha.PromptRouter |
![]() | github.com/aws/aws-cdk-go/awsbedrockalpha/v2#PromptRouter |
![]() | software.amazon.awscdk.services.bedrock.alpha.PromptRouter |
![]() | aws_cdk.aws_bedrock_alpha.PromptRouter |
![]() | @aws-cdk/aws-bedrock-alpha ยป PromptRouter |
Implements
IBedrock
, IPrompt
Amazon Bedrock intelligent prompt routing provides a single serverless endpoint for efficiently routing requests between different foundational models within the same model family.
It can help you optimize for response quality and cost.
Intelligent prompt routing predicts the performance of each model for each request, and dynamically routes each request to the model that it predicts is most likely to give the desired response at the lowest cost.
See also: https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-routing.html
Example
// Create a prompt router for intelligent model selection
const promptRouter = bedrock.PromptRouter.fromDefaultId(
bedrock.DefaultPromptRouterIdentifier.ANTHROPIC_CLAUDE_V1,
'us-east-1'
);
// Use the prompt router with a prompt variant
const variant = bedrock.PromptVariant.text({
variantName: 'variant1',
promptText: 'What is the capital of France?',
model: promptRouter,
});
new bedrock.Prompt(this, 'Prompt', {
promptName: 'prompt-router-test',
variants: [variant],
});
Initializer
new PromptRouter(props: PromptRouterProps, region: string)
Parameters
- props
Prompt
Router Props - region
string
Properties
Name | Type | Description |
---|---|---|
invokable | string | The ARN used for invoking this prompt router. |
prompt | string | The ARN of the prompt router. |
prompt | string | The ID of the prompt router. |
routing | IBedrock [] | The inference endpoints (cross-region profiles) that this router will route to. |
invokableArn
Type:
string
The ARN used for invoking this prompt router.
This equals to the promptRouterArn property, useful for implementing IBedrockInvokable interface.
promptRouterArn
Type:
string
The ARN of the prompt router.
promptRouterId
Type:
string
The ID of the prompt router.
routingEndpoints
Type:
IBedrock
[]
The inference endpoints (cross-region profiles) that this router will route to.
These are created automatically based on the routing models and region.
Methods
Name | Description |
---|---|
grant | Grants the necessary permissions to invoke this prompt router and all its routing endpoints. |
static from | Creates a PromptRouter from a default router identifier. |
grantInvoke(grantee)
public grantInvoke(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
โ - The IAM principal to grant permissions to.
Returns
Grants the necessary permissions to invoke this prompt router and all its routing endpoints.
This method grants permissions to:
- Get prompt router details (bedrock:GetPromptRouter)
- Invoke models through the router (bedrock:InvokeModel)
- Use all underlying models and cross-region profiles
static fromDefaultId(defaultRouter, region)
public static fromDefaultId(defaultRouter: DefaultPromptRouterIdentifier, region: string): PromptRouter
Parameters
- defaultRouter
Default
โ - The default router configuration to use.Prompt Router Identifier - region
string
โ - The AWS region where the router will be used.
Returns
Creates a PromptRouter from a default router identifier.