createPromptRouter method
Creates a prompt router that manages the routing of requests between multiple foundation models based on the routing criteria.
May throw AccessDeniedException.
May throw ConflictException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw TooManyTagsException.
May throw ValidationException.
Parameter fallbackModel :
The default model to use when the routing criteria is not met.
Parameter models :
A list of foundation models that the prompt router can route requests to.
At least one model must be specified.
Parameter promptRouterName :
The name of the prompt router. The name must be unique within your Amazon
Web Services account in the current region.
Parameter routingCriteria :
The criteria, which is the response quality difference, used to determine
how incoming requests are routed to different models.
Parameter clientRequestToken :
A unique, case-sensitive identifier that you provide to ensure idempotency
of your requests. If not specified, the Amazon Web Services SDK
automatically generates one for you.
Parameter description :
An optional description of the prompt router to help identify its purpose.
Parameter tags :
An array of key-value pairs to apply to this resource as tags. You can use
tags to categorize and manage your Amazon Web Services resources.
Implementation
Future<CreatePromptRouterResponse> createPromptRouter({
required PromptRouterTargetModel fallbackModel,
required List<PromptRouterTargetModel> models,
required String promptRouterName,
required RoutingCriteria routingCriteria,
String? clientRequestToken,
String? description,
List<Tag>? tags,
}) async {
final $payload = <String, dynamic>{
'fallbackModel': fallbackModel,
'models': models,
'promptRouterName': promptRouterName,
'routingCriteria': routingCriteria,
'clientRequestToken': clientRequestToken ?? _s.generateIdempotencyToken(),
if (description != null) 'description': description,
if (tags != null) 'tags': tags,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/prompt-routers',
exceptionFnMap: _exceptionFns,
);
return CreatePromptRouterResponse.fromJson(response);
}