Class PromptRouter
java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.bedrock.alpha.PromptRouter
- All Implemented Interfaces:
IBedrockInvokable
,IPromptRouter
,software.amazon.jsii.JsiiSerializable
@Generated(value="jsii-pacmak/1.112.0 (build de1bc80)",
date="2025-08-06T18:14:48.079Z")
@Stability(Experimental)
public class PromptRouter
extends software.amazon.jsii.JsiiObject
implements IBedrockInvokable, IPromptRouter
(experimental) 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.
Example:
// Create a prompt router for intelligent model selection PromptRouter promptRouter = PromptRouter.fromDefaultId(DefaultPromptRouterIdentifier.ANTHROPIC_CLAUDE_V1, "us-east-1"); // Use the prompt router with a prompt variant IPromptVariant variant = PromptVariant.text(TextPromptVariantProps.builder() .variantName("variant1") .promptText("What is the capital of France?") .model(promptRouter) .build()); Prompt.Builder.create(this, "Prompt") .promptName("prompt-router-test") .variants(List.of(variant)) .build();
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
(experimental) A fluent builder forPromptRouter
.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.bedrock.alpha.IBedrockInvokable
IBedrockInvokable.Jsii$Default, IBedrockInvokable.Jsii$Proxy
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.bedrock.alpha.IPromptRouter
IPromptRouter.Jsii$Default, IPromptRouter.Jsii$Proxy
-
Constructor Summary
ConstructorsModifierConstructorDescriptionPromptRouter
(PromptRouterProps props, String region) protected
PromptRouter
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
PromptRouter
(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionstatic PromptRouter
fromDefaultId
(DefaultPromptRouterIdentifier defaultRouter, String region) (experimental) Creates a PromptRouter from a default router identifier.(experimental) The ARN used for invoking this prompt router.(experimental) The ARN of the prompt router.(experimental) The ID of the prompt router.(experimental) The inference endpoints (cross-region profiles) that this router will route to.grantInvoke
(IGrantable grantee) (experimental) Grants the necessary permissions to invoke this prompt router and all its routing endpoints.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
PromptRouter
protected PromptRouter(software.amazon.jsii.JsiiObjectRef objRef) -
PromptRouter
protected PromptRouter(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
PromptRouter
@Stability(Experimental) public PromptRouter(@NotNull PromptRouterProps props, @NotNull String region) - Parameters:
props
- This parameter is required.region
- This parameter is required.
-
-
Method Details
-
fromDefaultId
@Stability(Experimental) @NotNull public static PromptRouter fromDefaultId(@NotNull DefaultPromptRouterIdentifier defaultRouter, @NotNull String region) (experimental) Creates a PromptRouter from a default router identifier.- Parameters:
defaultRouter
-- The default router configuration to use.
region
-- The AWS region where the router will be used.
- Returns:
- A new PromptRouter instance configured with the default settings
-
grantInvoke
(experimental) 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
- Specified by:
grantInvoke
in interfaceIBedrockInvokable
- Parameters:
grantee
-- The IAM principal to grant permissions to.
- Returns:
- An IAM Grant object representing the granted permissions
-
getInvokableArn
(experimental) The ARN used for invoking this prompt router.This equals to the promptRouterArn property, useful for implementing IBedrockInvokable interface.
- Specified by:
getInvokableArn
in interfaceIBedrockInvokable
-
getPromptRouterArn
(experimental) The ARN of the prompt router.- Specified by:
getPromptRouterArn
in interfaceIPromptRouter
-
getPromptRouterId
(experimental) The ID of the prompt router.- Specified by:
getPromptRouterId
in interfaceIPromptRouter
-
getRoutingEndpoints
(experimental) The inference endpoints (cross-region profiles) that this router will route to.These are created automatically based on the routing models and region.
- Specified by:
getRoutingEndpoints
in interfaceIPromptRouter
-