Class PromptRouter
(experimental) Amazon Bedrock intelligent prompt routing provides a single serverless endpoint for efficiently routing requests between different foundational models within the same model family.
Namespace: Amazon.CDK.AWS.Bedrock.Alpha
Assembly: Amazon.CDK.AWS.Bedrock.Alpha.dll
Syntax (csharp)
public class PromptRouter : DeputyBase, IBedrockInvokable, IPromptRouter
Syntax (vb)
Public Class PromptRouter Inherits DeputyBase Implements IBedrockInvokable, IPromptRouter
Remarks
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.
Stability: Experimental
See: https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-routing.html
ExampleMetadata: fixture=default infused
Examples
// Create a prompt router for intelligent model selection
var promptRouter = PromptRouter.FromDefaultId(DefaultPromptRouterIdentifier.ANTHROPIC_CLAUDE_V1, "us-east-1");
// Use the prompt router with a prompt variant
var variant = PromptVariant.Text(new TextPromptVariantProps {
VariantName = "variant1",
PromptText = "What is the capital of France?",
Model = promptRouter
});
new Prompt(this, "Prompt", new PromptProps {
PromptName = "prompt-router-test",
Variants = new [] { variant }
});
Synopsis
Constructors
PromptRouter(IPromptRouterProps, string) | (experimental) Amazon Bedrock intelligent prompt routing provides a single serverless endpoint for efficiently routing requests between different foundational models within the same model family. |
Properties
InvokableArn | (experimental) The ARN used for invoking this prompt router. |
PromptRouterArn | (experimental) The ARN of the prompt router. |
PromptRouterId | (experimental) The ID of the prompt router. |
RoutingEndpoints | (experimental) The inference endpoints (cross-region profiles) that this router will route to. |
Methods
FromDefaultId(DefaultPromptRouterIdentifier, string) | (experimental) Creates a PromptRouter from a default router identifier. |
GrantInvoke(IGrantable) | (experimental) Grants the necessary permissions to invoke this prompt router and all its routing endpoints. |
Constructors
PromptRouter(IPromptRouterProps, string)
(experimental) Amazon Bedrock intelligent prompt routing provides a single serverless endpoint for efficiently routing requests between different foundational models within the same model family.
public PromptRouter(IPromptRouterProps props, string region)
Parameters
- props IPromptRouterProps
- region string
Remarks
Stability: Experimental
Properties
InvokableArn
(experimental) The ARN used for invoking this prompt router.
public virtual string InvokableArn { get; }
Property Value
Remarks
This equals to the promptRouterArn property, useful for implementing IBedrockInvokable interface.
Stability: Experimental
PromptRouterArn
(experimental) The ARN of the prompt router.
public virtual string PromptRouterArn { get; }
Property Value
Remarks
Stability: Experimental
Attribute: true
PromptRouterId
(experimental) The ID of the prompt router.
public virtual string PromptRouterId { get; }
Property Value
Remarks
Stability: Experimental
Attribute: true
RoutingEndpoints
(experimental) The inference endpoints (cross-region profiles) that this router will route to.
public virtual IBedrockInvokable[] RoutingEndpoints { get; }
Property Value
Remarks
These are created automatically based on the routing models and region.
Stability: Experimental
Methods
FromDefaultId(DefaultPromptRouterIdentifier, string)
(experimental) Creates a PromptRouter from a default router identifier.
public static PromptRouter FromDefaultId(DefaultPromptRouterIdentifier defaultRouter, string region)
Parameters
- defaultRouter DefaultPromptRouterIdentifier
- The default router configuration to use.
- region string
- The AWS region where the router will be used.
Returns
A new PromptRouter instance configured with the default settings
Remarks
Stability: Experimental
GrantInvoke(IGrantable)
(experimental) Grants the necessary permissions to invoke this prompt router and all its routing endpoints.
public virtual Grant GrantInvoke(IGrantable grantee)
Parameters
- grantee IGrantable
- The IAM principal to grant permissions to.
Returns
An IAM Grant object representing the granted permissions
Remarks
This method grants permissions to:
Stability: Experimental