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:
  • 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.
      This parameter is required.
      region -
      • The AWS region where the router will be used.
      This parameter is required.
      Returns:
      A new PromptRouter instance configured with the default settings
    • grantInvoke

      @Stability(Experimental) @NotNull public Grant grantInvoke(@NotNull IGrantable grantee)
      (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 interface IBedrockInvokable
      Parameters:
      grantee -
      • The IAM principal to grant permissions to.
      This parameter is required.
      Returns:
      An IAM Grant object representing the granted permissions
    • getInvokableArn

      @Stability(Experimental) @NotNull public String 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 interface IBedrockInvokable
    • getPromptRouterArn

      @Stability(Experimental) @NotNull public String getPromptRouterArn()
      (experimental) The ARN of the prompt router.
      Specified by:
      getPromptRouterArn in interface IPromptRouter
    • getPromptRouterId

      @Stability(Experimental) @NotNull public String getPromptRouterId()
      (experimental) The ID of the prompt router.
      Specified by:
      getPromptRouterId in interface IPromptRouter
    • getRoutingEndpoints

      @Stability(Experimental) @NotNull public List<IBedrockInvokable> 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 interface IPromptRouter