> **Experimental**
>
> `@aws-cdk/aws-bedrock-alpha` is an [**experimental**](/stability) (alpha) package: its API may change in any release, without a major version bump.
# PromptRouter

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.

Extends: PromptRouter
Implements: IBedrockInvokable, IPromptRouter

- Stability: [Experimental](/cdk/api/stability.html)
- Source: [`bedrock/inference-profiles/prompt-router.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0-alpha.0/packages/@aws-cdk/aws-bedrock-alpha/bedrock/inference-profiles/prompt-router.ts#L108)

## Example

```ts
// 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

```ts
new PromptRouter(props: PromptRouterProps, region: string)
```

## Properties

- `invokableArn`: string — The ARN used for invoking this prompt router.

  This equals to the promptRouterArn property, useful for implementing IBedrockInvokable interface.

- `promptRouterArn`: string — The ARN of the prompt router.

- `promptRouterId`: string — The ID of the prompt router.

- `routingEndpoints`: [IBedrockInvokable](/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.IBedrockInvokable.html)[] — The inference endpoints (cross-region profiles) that this router will route to.

  These are created automatically based on the routing models and region.

## Methods

- `fromDefaultId(defaultRouter: DefaultPromptRouterIdentifier, region: string): PromptRouter // chainable` (static) — 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(grantee: IGrantable): Grant` — 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
  [disable-awslint:no-grants]

  **Parameters**

  - `grantee` — - The IAM principal to grant permissions to.

  **Returns:** An IAM Grant object representing the granted permissions
