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

# Evaluate Document Groundedness

> Calculates how well the candidate document is supported by the source context.
The source context is a transcript or a list of facts.<br/><Info>We plan to extend this to combinations and string source context in the future.</Info>

The API splits each section of the candidate document into sentences.
Each sentence becomes one claim.
A language model compares each claim with the source context and gives a verdict.
Each claim contains the evidence from the source context. A `not_applicable` claim contains no evidence.

This operation uses a language model. It uses credits.




## OpenAPI

````yaml /api-reference/auto-generated-openapi.yml post /tools/evaluations/text/documents/groundedness
openapi: 3.0.0
info:
  title: Corti API
  version: 2.0.0
servers:
  - url: https://api.{environment}.corti.app/v2/
    variables:
      environment:
        default: eu
        enum:
          - us
          - eu
security:
  - AuthorizationHeader:
      - bearer
tags:
  - name: Interactions
  - name: Recordings
  - name: Transcripts
  - name: Facts
  - name: Codes
  - name: FHIR
  - name: Languages
  - name: Guided Documents
  - name: Guided Templates
  - name: Guided Sections
  - name: Documents (Classic)
  - name: Templates (Classic)
  - name: Evaluations
paths:
  /tools/evaluations/text/documents/groundedness:
    post:
      tags:
        - Evaluations
      summary: Evaluate Document Groundedness
      description: >
        Calculates how well the candidate document is supported by the source
        context.

        The source context is a transcript or a list of facts.<br/><Info>We plan
        to extend this to combinations and string source context in the
        future.</Info>


        The API splits each section of the candidate document into sentences.

        Each sentence becomes one claim.

        A language model compares each claim with the source context and gives a
        verdict.

        Each claim contains the evidence from the source context. A
        `not_applicable` claim contains no evidence.


        This operation uses a language model. It uses credits.
      operationId: evaluations_documents_groundedness
      parameters:
        - $ref: '#/components/parameters/Tenant-Name'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EvaluationGroundednessRequest'
      responses:
        '200':
          description: >-
            The scores and a list of claims, each claim corresponding to one
            sentence from the candidate document.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EvaluationGroundednessResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '403':
          $ref: '#/components/responses/EvaluationForbidden'
        '429':
          $ref: '#/components/responses/EvaluationTooManyRequests'
        '500':
          $ref: '#/components/responses/EvaluationInternalError'
        '502':
          $ref: '#/components/responses/EvaluationBadGateway'
components:
  parameters:
    Tenant-Name:
      name: Tenant-Name
      in: header
      description: >-
        Identifies a distinct entity within Corti's multi-tenant system. Ensures
        correct routing and authentication of the request.
      required: true
      example: base
      schema:
        type: string
        description: >-
          Identifies a distinct entity within Corti's multi-tenant system.
          Ensures correct routing and authentication of the request.
        example: base
  schemas:
    EvaluationGroundednessRequest:
      type: object
      required:
        - language
        - candidateDocument
        - sourceContext
      properties:
        language:
          $ref: '#/components/schemas/EvaluationLanguage'
        candidateDocument:
          $ref: '#/components/schemas/EvaluationDocument'
        sourceContext:
          $ref: '#/components/schemas/EvaluationSourceContext'
    EvaluationGroundednessResponse:
      allOf:
        - $ref: '#/components/schemas/EvaluationScores'
        - type: object
          required:
            - claims
          properties:
            claims:
              type: array
              items:
                allOf:
                  - $ref: '#/components/schemas/EvaluationClaim'
                  - type: object
                    required:
                      - candidateDocumentSpan
                      - sourceContextEvidence
                    properties:
                      candidateDocumentSpan:
                        $ref: '#/components/schemas/EvaluationDocumentSpan'
                      sourceContextEvidence:
                        type: array
                        items:
                          $ref: '#/components/schemas/EvaluationSourceEvidenceSpan'
    EvaluationLanguage:
      type: string
      description: |
        The language of the documents, as a BCP-47 language tag.
        For example `en` or `en-US`.
      example: en
    EvaluationDocument:
      type: object
      description: >
        A document. Each key is a section ID. Each value is the text of that
        section.

        Section IDs must not be empty.


        The API processes the sections in the order of the request.

        The spans and claims in the response are in the order of the sections in
        the request, and then in the order in the text.
      minProperties: 1
      additionalProperties:
        type: string
      example:
        subjective: Patient reports right knee pain for two weeks.
        plan: Follow-up in one week.
    EvaluationSourceContext:
      description: |
        The source context for the candidate document.
        A transcript or a list of facts.
      oneOf:
        - $ref: '#/components/schemas/CommonTranscriptContext'
        - $ref: '#/components/schemas/CommonFactsContext'
      discriminator:
        propertyName: type
        mapping:
          transcript: '#/components/schemas/CommonTranscriptContext'
          facts: '#/components/schemas/CommonFactsContext'
    EvaluationScores:
      type: object
      required:
        - score
        - strictScore
        - looseScore
        - evaluationConfigHash
        - usageInfo
      properties:
        score:
          type: number
          format: double
          minimum: 0
          maximum: 1
          description: >
            The mean value of the verdicts. A `grounded` verdict is 1, a
            `partial` verdict is 0.5 and an `ungrounded` verdict is 0.

            When all claims are `not_applicable`, the score is 1.
        strictScore:
          type: number
          format: double
          minimum: 0
          maximum: 1
          description: The same as `score`, but a `partial` verdict is 0.
        looseScore:
          type: number
          format: double
          minimum: 0
          maximum: 1
          description: The same as `score`, but a `partial` verdict is 1.
        evaluationConfigHash:
          type: string
          description: >
            A SHA-256 hash of the evaluation configuration: the language model,
            the prompt and the parameters of the language model.

            The hash does not include the content of the request.

            Compare scores only when they have the same hash.
          example: >-
            sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
        usageInfo:
          $ref: '#/components/schemas/CommonUsageInfo'
    EvaluationClaim:
      type: object
      required:
        - verdict
      properties:
        verdict:
          $ref: '#/components/schemas/EvaluationVerdict'
        reason:
          type: string
          description: The language model's reasoning for the verdict.
    EvaluationDocumentSpan:
      type: object
      description: >
        A sentence in a section of a document.

        `start` and `end` are character offsets in the text of the section. The
        API counts Unicode code points.

        `start` is inclusive. `end` is exclusive.
      required:
        - start
        - end
        - text
        - sectionId
      properties:
        start:
          type: integer
          minimum: 0
          description: The offset of the first character of the sentence.
        end:
          type: integer
          minimum: 0
          description: The offset after the last character of the sentence.
        text:
          type: string
          minLength: 1
          description: >-
            The text of the sentence. The text has no whitespace at the start or
            at the end.
        sectionId:
          type: string
          minLength: 1
          description: The section ID in the document.
    EvaluationSourceEvidenceSpan:
      type: object
      description: >
        A part of the source context that the language model cites as evidence.

        `start` and `end` are character offsets in the text of the transcript
        segment or the fact. The API counts Unicode code points.

        The evidence cites exactly one item of the source context:
        `utteranceIndex` for a transcript source context, `factIndex` for a
        facts source context. Exactly one of the two indices is present.
      required:
        - start
        - end
        - text
      properties:
        start:
          type: integer
          minimum: 0
        end:
          type: integer
          minimum: 0
        text:
          type: string
        utteranceIndex:
          type: integer
          minimum: 0
          description: >-
            The index of the transcript segment in
            `sourceContext.transcript.transcripts`.
        factIndex:
          type: integer
          minimum: 0
          description: The index of the fact in `sourceContext.facts.facts`.
      oneOf:
        - type: object
          required:
            - utteranceIndex
        - type: object
          required:
            - factIndex
    ErrorResponse:
      type: object
      required:
        - requestid
        - status
        - type
        - detail
      properties:
        requestid:
          type: string
        status:
          type: integer
        type:
          type: string
        detail:
          type: string
        validationErrors:
          type: array
          items:
            type: object
            additionalProperties:
              type: string
    CommonTranscriptContext:
      type: object
      required:
        - type
        - transcript
      description: A transcript provided as input context to the model.
      properties:
        type:
          type: string
          enum:
            - transcript
        transcript:
          $ref: '#/components/schemas/GuidedDocumentTranscriptMinimal'
    CommonFactsContext:
      type: object
      required:
        - type
        - facts
      description: A list of facts provided as input context to the model.
      properties:
        type:
          type: string
          enum:
            - facts
        facts:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/GuidedDocumentFactMinimal'
    CommonUsageInfo:
      type: object
      description: Credits consumed for this request.
      required:
        - creditsConsumed
      properties:
        creditsConsumed:
          type: number
    EvaluationVerdict:
      type: string
      description: >
        The verdict given by the language model for a claim.

        - `grounded`: The evidence supports the claim.

        - `partial`: The evidence supports a part of the claim.

        - `ungrounded`: The evidence does not support the claim.

        - `not_applicable`: The claim is a section heading or text that has no
        clinical content. The scores do not include this claim.
      enum:
        - grounded
        - partial
        - ungrounded
        - not_applicable
    GuidedDocumentTranscriptMinimal:
      type: object
      required:
        - transcripts
      description: >
        Minimal transcript shape accepted as input context. Decoupled from the
        transcript resource: only `transcripts` is required, and within each
        segment only `text` is required.
      properties:
        metadata:
          $ref: '#/components/schemas/GuidedDocumentTranscriptMetadataMinimal'
        transcripts:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/GuidedDocumentTranscriptSegmentMinimal'
    GuidedDocumentFactMinimal:
      type: object
      required:
        - text
      description: Minimal fact shape. Only `text` is required.
      properties:
        text:
          type: string
          description: The text of the fact.
          minLength: 1
        group:
          type: string
          description: The group to which the fact belongs.
          example: Others
    GuidedDocumentTranscriptMetadataMinimal:
      type: object
      description: Optional transcript-level metadata. All fields optional.
      properties:
        participantsRoles:
          type: array
          items:
            $ref: '#/components/schemas/TranscriptsParticipant'
          nullable: true
    GuidedDocumentTranscriptSegmentMinimal:
      type: object
      required:
        - text
      description: Minimal transcript segment. Only `text` is required.
      properties:
        channel:
          type: integer
          description: The channel associated with this phrase/utterance.
        participant:
          type: integer
          description: The identifier of the participant.
        speakerId:
          type: integer
          description: Id to tag an identified speaker.
        text:
          type: string
          description: The spoken phrase or utterance.
          minLength: 1
        start:
          type: integer
          description: Start time in milliseconds for phrase/utterance.
        end:
          type: integer
          description: End time in milliseconds for phrase/utterance.
    TranscriptsParticipant:
      type: object
      required:
        - channel
        - role
      properties:
        channel:
          type: integer
          minimum: 0
          description: The audio channel to associate with a participant role.
        role:
          type: string
          description: >-
            Free-form label for the participant role (e.g., 'doctor', 'patient',
            'Attending Physician'). Must not be empty or whitespace-only after
            trimming, must not contain control characters, and must not exceed
            100 characters or 10 words.
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    EvaluationForbidden:
      description: The access token does not have the scope for evaluations.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    EvaluationTooManyRequests:
      description: >-
        The API has too many evaluation requests. Wait. Then send the request
        again.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    EvaluationInternalError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    EvaluationBadGateway:
      description: The API could not complete the evaluation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    AuthorizationHeader:
      type: http
      description: Input your token
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.