listModels method

Future<ListModelsResponse> listModels({
  1. required String assistantId,
  2. AIPromptType? aiPromptType,
  3. int? maxResults,
  4. ModelLifecycle? modelLifecycle,
  5. String? nextToken,
})

Lists the models available to an Amazon Q in Connect assistant in the assistant's Amazon Web Services Region. The available models are determined by the region of the specified assistant.

May throw AccessDeniedException. May throw ConflictException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw UnauthorizedException. May throw ValidationException.

Parameter assistantId : The identifier of the Amazon Q in Connect assistant. Can be either the ID or the ARN. URLs cannot contain the ARN. The assistant's region determines which models are available.

Parameter aiPromptType : The type of the AI Prompt to filter models by. When specified, only models that support the given AI Prompt type are returned.

Parameter maxResults : The maximum number of results to return per page.

Parameter modelLifecycle : The lifecycle status of models to filter by. When specified, only models with the given lifecycle status are returned.

Parameter nextToken : The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.

Implementation

Future<ListModelsResponse> listModels({
  required String assistantId,
  AIPromptType? aiPromptType,
  int? maxResults,
  ModelLifecycle? modelLifecycle,
  String? nextToken,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    100,
  );
  final $query = <String, List<String>>{
    if (aiPromptType != null) 'aiPromptType': [aiPromptType.value],
    if (maxResults != null) 'maxResults': [maxResults.toString()],
    if (modelLifecycle != null) 'modelLifecycle': [modelLifecycle.value],
    if (nextToken != null) 'nextToken': [nextToken],
  };
  final response = await _protocol.send(
    payload: null,
    method: 'GET',
    requestUri: '/assistants/${Uri.encodeComponent(assistantId)}/models',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return ListModelsResponse.fromJson(response);
}