> ## Documentation Index
> Fetch the complete documentation index at: https://docs.promptfoundry.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Evaluation Assertion

> Creates a new evaluation assertion



## OpenAPI

````yaml post /sdk/v1/evaluation-assertions
openapi: 3.0.0
info:
  title: Prompt Foundry API
  version: 1.0.0
  description: The API for managing prompts, tools, evaluations, and evaluation assertions.
servers:
  - url: https://api.promptfoundry.ai
    description: Prompt Foundry Production API
security: []
paths:
  /sdk/v1/evaluation-assertions:
    post:
      summary: Create Evaluation Assertion
      description: Creates a new evaluation assertion
      operationId: createEvaluationAssertion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EvaluationAssertionBody'
      responses:
        '201':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EvaluationAssertion'
        '400':
          description: Missing or invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import PromptFoundry from '@prompt-foundry/typescript-sdk';

            const client = new PromptFoundry({
              apiKey: process.env['PROMPT_FOUNDRY_API_KEY'], // This is the default and can be omitted
            });

            async function main() {
              const evaluationAssertion = await client.evaluationAssertions.create({
                evaluationId: 'evaluationId',
                targetValue: 'targetValue',
                type: 'EXACT_MATCH',
              });

              console.log(evaluationAssertion);
            }

            main();
        - lang: Python
          source: |-
            import os
            from prompt_foundry_python_sdk import PromptFoundry

            client = PromptFoundry(
                # This is the default and can be omitted
                api_key=os.environ.get("PROMPT_FOUNDRY_API_KEY"),
            )
            evaluation_assertion = client.evaluation_assertions.create(
                evaluation_id="evaluationId",
                target_value="targetValue",
                type="EXACT_MATCH",
            )
            print(evaluation_assertion)
components:
  schemas:
    EvaluationAssertionBody:
      oneOf:
        - $ref: '#/components/schemas/EvaluationAssertionExactMatchBody'
        - $ref: '#/components/schemas/EvaluationAssertionContainsAllBody'
        - $ref: '#/components/schemas/EvaluationAssertionContainsAnyBody'
        - $ref: '#/components/schemas/EvaluationAssertionStartsWithBody'
        - $ref: '#/components/schemas/EvaluationAssertionCostBody'
        - $ref: '#/components/schemas/EvaluationAssertionLatencyBody'
        - $ref: '#/components/schemas/EvaluationAssertionToolCalledBody'
        - $ref: '#/components/schemas/EvaluationAssertionToolCalledWithBody'
      discriminator:
        propertyName: type
        mapping:
          EXACT_MATCH: '#/components/schemas/EvaluationAssertionExactMatchBody'
          CONTAINS_ALL: '#/components/schemas/EvaluationAssertionContainsAllBody'
          CONTAINS_ANY: '#/components/schemas/EvaluationAssertionContainsAnyBody'
          STARTS_WITH: '#/components/schemas/EvaluationAssertionStartsWithBody'
          COST: '#/components/schemas/EvaluationAssertionCostBody'
          LATENCY: '#/components/schemas/EvaluationAssertionLatencyBody'
          TOOL_CALLED: '#/components/schemas/EvaluationAssertionToolCalledBody'
          TOOL_CALLED_WITH: '#/components/schemas/EvaluationAssertionToolCalledWithBody'
    EvaluationAssertion:
      oneOf:
        - $ref: '#/components/schemas/EvaluationAssertionExactMatch'
        - $ref: '#/components/schemas/EvaluationAssertionContainsAll'
        - $ref: '#/components/schemas/EvaluationAssertionContainsAny'
        - $ref: '#/components/schemas/EvaluationAssertionStartsWith'
        - $ref: '#/components/schemas/EvaluationAssertionCost'
        - $ref: '#/components/schemas/EvaluationAssertionLatency'
        - $ref: '#/components/schemas/EvaluationAssertionToolCalled'
        - $ref: '#/components/schemas/EvaluationAssertionToolCalledWith'
      discriminator:
        propertyName: type
        mapping:
          EXACT_MATCH: '#/components/schemas/EvaluationAssertionExactMatch'
          CONTAINS_ALL: '#/components/schemas/EvaluationAssertionContainsAll'
          CONTAINS_ANY: '#/components/schemas/EvaluationAssertionContainsAny'
          STARTS_WITH: '#/components/schemas/EvaluationAssertionStartsWith'
          COST: '#/components/schemas/EvaluationAssertionCost'
          LATENCY: '#/components/schemas/EvaluationAssertionLatency'
          TOOL_CALLED: '#/components/schemas/EvaluationAssertionToolCalled'
          TOOL_CALLED_WITH: '#/components/schemas/EvaluationAssertionToolCalledWith'
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: 'Example: "Prompt ID is required."'
      required:
        - error
    EvaluationAssertionExactMatchBody:
      type: object
      properties:
        type:
          type: string
          enum:
            - EXACT_MATCH
        evaluationId:
          type: string
        weight:
          type: number
          minimum: 0
          maximum: 1
          default: 1
          description: How heavily to weigh the assertion within the evaluation.
        targetValue:
          type: string
          description: The value to match.
        jsonPath:
          type: string
          nullable: true
          default: $
          description: A JSON path to use when matching a JSON response.
        ignoreCase:
          type: boolean
          default: false
          description: Whether to ignore case when comparing strings.
        negate:
          type: boolean
          default: false
          description: >-
            Whether to negate the assertion. "true" means the assertion must NOT
            be true.
      required:
        - type
        - evaluationId
        - targetValue
      title: EvaluationAssertionExactMatchBody
    EvaluationAssertionContainsAllBody:
      type: object
      properties:
        type:
          type: string
          enum:
            - CONTAINS_ALL
        evaluationId:
          type: string
        weight:
          type: number
          minimum: 0
          maximum: 1
          default: 1
          description: How heavily to weigh the assertion within the evaluation.
        targetValues:
          type: array
          items:
            type: string
          minItems: 1
          description: List of values any of which may be present.
        jsonPath:
          type: string
          nullable: true
          default: $
          description: A JSON path to use when matching a JSON response.
        ignoreCase:
          type: boolean
          default: false
          description: Whether to ignore case when comparing strings.
        negate:
          type: boolean
          default: false
          description: >-
            Whether to negate the assertion. "true" means the assertion must NOT
            be true.
      required:
        - type
        - evaluationId
        - targetValues
      title: EvaluationAssertionContainsAllBody
    EvaluationAssertionContainsAnyBody:
      type: object
      properties:
        type:
          type: string
          enum:
            - CONTAINS_ANY
        evaluationId:
          type: string
        weight:
          type: number
          minimum: 0
          maximum: 1
          default: 1
          description: How heavily to weigh the assertion within the evaluation.
        targetValues:
          type: array
          items:
            type: string
          minItems: 1
          description: List of values any of which may be present.
        jsonPath:
          type: string
          nullable: true
          default: $
          description: A JSON path to use when matching a JSON response.
        ignoreCase:
          type: boolean
          default: false
          description: Whether to ignore case when comparing strings.
        negate:
          type: boolean
          default: false
          description: >-
            Whether to negate the assertion. "true" means the assertion must NOT
            be true.
      required:
        - type
        - evaluationId
        - targetValues
      title: EvaluationAssertionContainsAnyBody
    EvaluationAssertionStartsWithBody:
      type: object
      properties:
        type:
          type: string
          enum:
            - STARTS_WITH
        evaluationId:
          type: string
        weight:
          type: number
          minimum: 0
          maximum: 1
          default: 1
          description: How heavily to weigh the assertion within the evaluation.
        targetValue:
          type: string
          description: The value that the response should start with.
        jsonPath:
          type: string
          nullable: true
          default: $
          description: A JSON path to use when matching a JSON response.
        ignoreCase:
          type: boolean
          default: false
          description: Whether to ignore case when comparing strings.
        negate:
          type: boolean
          default: false
          description: >-
            Whether to negate the assertion. "true" means the assertion must NOT
            be true.
      required:
        - type
        - evaluationId
        - targetValue
      title: EvaluationAssertionStartsWithBody
    EvaluationAssertionCostBody:
      type: object
      properties:
        type:
          type: string
          enum:
            - COST
        evaluationId:
          type: string
        weight:
          type: number
          minimum: 0
          maximum: 1
          default: 1
          description: How heavily to weigh the assertion within the evaluation.
        targetThreshold:
          type: number
          description: The cost threshold to be evaluated against.
      required:
        - type
        - evaluationId
        - targetThreshold
      title: EvaluationAssertionCostBody
    EvaluationAssertionLatencyBody:
      type: object
      properties:
        type:
          type: string
          enum:
            - LATENCY
        evaluationId:
          type: string
        weight:
          type: number
          minimum: 0
          maximum: 1
          default: 1
          description: How heavily to weigh the assertion within the evaluation.
        targetThreshold:
          type: number
          description: The latency threshold to be evaluated against.
      required:
        - type
        - evaluationId
        - targetThreshold
      title: EvaluationAssertionLatencyBody
    EvaluationAssertionToolCalledBody:
      type: object
      properties:
        type:
          type: string
          enum:
            - TOOL_CALLED
        evaluationId:
          type: string
        weight:
          type: number
          minimum: 0
          maximum: 1
          default: 1
          description: How heavily to weigh the assertion within the evaluation.
        toolName:
          type: string
          description: The name of the tool that should have been called.
      required:
        - type
        - evaluationId
        - toolName
      title: EvaluationAssertionToolCalledBody
    EvaluationAssertionToolCalledWithBody:
      type: object
      properties:
        type:
          type: string
          enum:
            - TOOL_CALLED_WITH
        evaluationId:
          type: string
        weight:
          type: number
          minimum: 0
          maximum: 1
          default: 1
          description: How heavily to weigh the assertion within the evaluation.
        argKeyName:
          type: string
          description: The argument name to be matched.
        toolName:
          type: string
          description: The name of the tool that should have been called.
        ignoreCase:
          type: boolean
          default: false
          description: Whether to ignore case when comparing argument names.
        negate:
          type: boolean
          default: false
          description: >-
            Whether to negate the assertion. "true" means the assertion must NOT
            be true.
      required:
        - type
        - evaluationId
        - argKeyName
        - toolName
      title: EvaluationAssertionToolCalledWithBody
    EvaluationAssertionExactMatch:
      type: object
      properties:
        type:
          type: string
          enum:
            - EXACT_MATCH
        evaluationId:
          type: string
        weight:
          type: number
          minimum: 0
          maximum: 1
          default: 1
          description: How heavily to weigh the assertion within the evaluation.
        targetValue:
          type: string
          description: The value to match.
        jsonPath:
          type: string
          nullable: true
          default: $
          description: A JSON path to use when matching a JSON response.
        ignoreCase:
          type: boolean
          default: false
          description: Whether to ignore case when comparing strings.
        negate:
          type: boolean
          default: false
          description: >-
            Whether to negate the assertion. "true" means the assertion must NOT
            be true.
        id:
          type: string
      required:
        - type
        - evaluationId
        - targetValue
        - id
      title: EvaluationAssertionExactMatch
    EvaluationAssertionContainsAll:
      type: object
      properties:
        type:
          type: string
          enum:
            - CONTAINS_ALL
        evaluationId:
          type: string
        weight:
          type: number
          minimum: 0
          maximum: 1
          default: 1
          description: How heavily to weigh the assertion within the evaluation.
        targetValues:
          type: array
          items:
            type: string
          minItems: 1
          description: List of values any of which may be present.
        jsonPath:
          type: string
          nullable: true
          default: $
          description: A JSON path to use when matching a JSON response.
        ignoreCase:
          type: boolean
          default: false
          description: Whether to ignore case when comparing strings.
        negate:
          type: boolean
          default: false
          description: >-
            Whether to negate the assertion. "true" means the assertion must NOT
            be true.
        id:
          type: string
      required:
        - type
        - evaluationId
        - targetValues
        - id
      title: EvaluationAssertionContainsAll
    EvaluationAssertionContainsAny:
      type: object
      properties:
        type:
          type: string
          enum:
            - CONTAINS_ANY
        evaluationId:
          type: string
        weight:
          type: number
          minimum: 0
          maximum: 1
          default: 1
          description: How heavily to weigh the assertion within the evaluation.
        targetValues:
          type: array
          items:
            type: string
          minItems: 1
          description: List of values any of which may be present.
        jsonPath:
          type: string
          nullable: true
          default: $
          description: A JSON path to use when matching a JSON response.
        ignoreCase:
          type: boolean
          default: false
          description: Whether to ignore case when comparing strings.
        negate:
          type: boolean
          default: false
          description: >-
            Whether to negate the assertion. "true" means the assertion must NOT
            be true.
        id:
          type: string
      required:
        - type
        - evaluationId
        - targetValues
        - id
      title: EvaluationAssertionContainsAny
    EvaluationAssertionStartsWith:
      type: object
      properties:
        type:
          type: string
          enum:
            - STARTS_WITH
        evaluationId:
          type: string
        weight:
          type: number
          minimum: 0
          maximum: 1
          default: 1
          description: How heavily to weigh the assertion within the evaluation.
        targetValue:
          type: string
          description: The value that the response should start with.
        jsonPath:
          type: string
          nullable: true
          default: $
          description: A JSON path to use when matching a JSON response.
        ignoreCase:
          type: boolean
          default: false
          description: Whether to ignore case when comparing strings.
        negate:
          type: boolean
          default: false
          description: >-
            Whether to negate the assertion. "true" means the assertion must NOT
            be true.
        id:
          type: string
      required:
        - type
        - evaluationId
        - targetValue
        - id
      title: EvaluationAssertionStartsWith
    EvaluationAssertionCost:
      type: object
      properties:
        type:
          type: string
          enum:
            - COST
        evaluationId:
          type: string
        weight:
          type: number
          minimum: 0
          maximum: 1
          default: 1
          description: How heavily to weigh the assertion within the evaluation.
        targetThreshold:
          type: number
          description: The cost threshold to be evaluated against.
        id:
          type: string
      required:
        - type
        - evaluationId
        - targetThreshold
        - id
      title: EvaluationAssertionCost
    EvaluationAssertionLatency:
      type: object
      properties:
        type:
          type: string
          enum:
            - LATENCY
        evaluationId:
          type: string
        weight:
          type: number
          minimum: 0
          maximum: 1
          default: 1
          description: How heavily to weigh the assertion within the evaluation.
        targetThreshold:
          type: number
          description: The latency threshold to be evaluated against.
        id:
          type: string
      required:
        - type
        - evaluationId
        - targetThreshold
        - id
      title: EvaluationAssertionLatency
    EvaluationAssertionToolCalled:
      type: object
      properties:
        type:
          type: string
          enum:
            - TOOL_CALLED
        evaluationId:
          type: string
        weight:
          type: number
          minimum: 0
          maximum: 1
          default: 1
          description: How heavily to weigh the assertion within the evaluation.
        toolName:
          type: string
          description: The name of the tool that should have been called.
        id:
          type: string
      required:
        - type
        - evaluationId
        - toolName
        - id
      title: EvaluationAssertionToolCalled
    EvaluationAssertionToolCalledWith:
      type: object
      properties:
        type:
          type: string
          enum:
            - TOOL_CALLED_WITH
        evaluationId:
          type: string
        weight:
          type: number
          minimum: 0
          maximum: 1
          default: 1
          description: How heavily to weigh the assertion within the evaluation.
        argKeyName:
          type: string
          description: The argument name to be matched.
        toolName:
          type: string
          description: The name of the tool that should have been called.
        ignoreCase:
          type: boolean
          default: false
          description: Whether to ignore case when comparing argument names.
        negate:
          type: boolean
          default: false
          description: >-
            Whether to negate the assertion. "true" means the assertion must NOT
            be true.
        id:
          type: string
      required:
        - type
        - evaluationId
        - argKeyName
        - toolName
        - id
      title: EvaluationAssertionToolCalledWith

````