BedrockAgentCore / Client / create_ab_test

create_ab_test

BedrockAgentCore.Client.create_ab_test(**kwargs)

Creates an A/B test for comparing agent configurations. A/B tests split traffic between a control variant and a treatment variant through a gateway, then evaluate performance using online evaluation configurations to determine which variant performs better.

See also: AWS API Documentation

Request Syntax

response = client.create_ab_test(
    name='string',
    description='string',
    gatewayArn='string',
    variants=[
        {
            'name': 'string',
            'weight': 123,
            'variantConfiguration': {
                'configurationBundle': {
                    'bundleArn': 'string',
                    'bundleVersion': 'string'
                },
                'target': {
                    'name': 'string'
                }
            }
        },
    ],
    gatewayFilter={
        'targetPaths': [
            'string',
        ]
    },
    evaluationConfig={
        'onlineEvaluationConfigArn': 'string',
        'perVariantOnlineEvaluationConfig': [
            {
                'name': 'string',
                'onlineEvaluationConfigArn': 'string'
            },
        ]
    },
    roleArn='string',
    enableOnCreate=True|False,
    clientToken='string'
)
Parameters:
  • name (string) –

    [REQUIRED]

    The name of the A/B test. Must be unique within your account.

  • description (string) – The description of the A/B test.

  • gatewayArn (string) –

    [REQUIRED]

    The Amazon Resource Name (ARN) of the gateway to use for traffic splitting.

  • variants (list) –

    [REQUIRED]

    The list of variants for the A/B test. Must contain exactly two variants: a control (C) and a treatment (T1), each with a configuration bundle or target reference and a traffic weight.

    • (dict) –

      A variant in an A/B test, representing either the control (C) or treatment (T1) configuration.

      • name (string) – [REQUIRED]

        The name of the variant. Must be C for control or T1 for treatment.

      • weight (integer) – [REQUIRED]

        The percentage of traffic to route to this variant. Weights across all variants must sum to 100.

      • variantConfiguration (dict) – [REQUIRED]

        The configuration for this variant, including the configuration bundle or target reference.

        • configurationBundle (dict) –

          A reference to a configuration bundle version to use for this variant.

          • bundleArn (string) – [REQUIRED]

            The Amazon Resource Name (ARN) of the configuration bundle.

          • bundleVersion (string) – [REQUIRED]

            The version of the configuration bundle.

        • target (dict) –

          A reference to a gateway target to route traffic to for this variant.

          • name (string) – [REQUIRED]

            The name of the gateway target.

  • gatewayFilter (dict) –

    Optional filter to restrict which gateway target paths are included in the A/B test.

    • targetPaths (list) –

      A list of target path patterns to include in the A/B test.

      • (string) –

  • evaluationConfig (dict) –

    [REQUIRED]

    The evaluation configuration specifying which online evaluation configurations to use for measuring variant performance.

    Note

    This is a Tagged Union structure. Only one of the following top level keys can be set: onlineEvaluationConfigArn, perVariantOnlineEvaluationConfig.

    • onlineEvaluationConfigArn (string) –

      The Amazon Resource Name (ARN) of a single online evaluation configuration to use for both variants.

    • perVariantOnlineEvaluationConfig (list) –

      Per-variant online evaluation configurations, allowing different evaluation settings for each variant.

      • (dict) –

        An online evaluation configuration associated with a specific A/B test variant.

        • name (string) – [REQUIRED]

          The name of the variant this evaluation configuration applies to.

        • onlineEvaluationConfigArn (string) – [REQUIRED]

          The Amazon Resource Name (ARN) of the online evaluation configuration for this variant.

  • roleArn (string) –

    [REQUIRED]

    The IAM role ARN that grants permissions for the A/B test to access gateway and evaluation resources.

  • enableOnCreate (boolean) – Whether to enable the A/B test immediately upon creation. If true, traffic splitting begins automatically.

  • clientToken (string) –

    A unique, case-sensitive identifier to ensure that the API request completes no more than one time. If this token matches a previous request, the service ignores the request, but does not return an error.

    This field is autopopulated if not provided.

Return type:

dict

Returns:

Response Syntax

{
    'abTestId': 'string',
    'abTestArn': 'string',
    'name': 'string',
    'status': 'CREATING'|'ACTIVE'|'CREATE_FAILED'|'UPDATING'|'UPDATE_FAILED'|'DELETING'|'DELETE_FAILED'|'FAILED',
    'executionStatus': 'PAUSED'|'RUNNING'|'STOPPED'|'NOT_STARTED',
    'createdAt': datetime(2015, 1, 1)
}

Response Structure

  • (dict) –

    • abTestId (string) –

      The unique identifier of the created A/B test.

    • abTestArn (string) –

      The Amazon Resource Name (ARN) of the created A/B test.

    • name (string) –

      The name of the A/B test.

    • status (string) –

      The status of the A/B test.

    • executionStatus (string) –

      The execution status indicating whether the A/B test is currently running.

    • createdAt (datetime) –

      The timestamp when the A/B test was created.

Exceptions

  • BedrockAgentCore.Client.exceptions.ServiceQuotaExceededException

  • BedrockAgentCore.Client.exceptions.UnauthorizedException

  • BedrockAgentCore.Client.exceptions.ValidationException

  • BedrockAgentCore.Client.exceptions.AccessDeniedException

  • BedrockAgentCore.Client.exceptions.ConflictException

  • BedrockAgentCore.Client.exceptions.ThrottlingException

  • BedrockAgentCore.Client.exceptions.InternalServerException