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

# Run an evaluator as a guardrail

> Run an evaluator inline and gate on one boolean. Same call as the evaluate path with `as_guardrail` set: every outcome carries `passed`, so an evaluator that skips or fails does not block the request it was guarding. Check `passed` and let the request through when it is true.



## OpenAPI

````yaml POST /api/guardrails/{evaluator}/evaluate
openapi: 3.1.0
info:
  title: LangWatch API
  version: 1.0.0
  description: LangWatch openapi spec
servers:
  - url: https://app.langwatch.ai
security:
  - project_api_key: []
paths:
  /api/guardrails/{evaluator}/evaluate:
    post:
      tags:
        - Evaluations
      summary: Run an evaluator as a guardrail
      description: >-
        Run an evaluator inline and gate on one boolean. Same call as the
        evaluate path with `as_guardrail` set: every outcome carries `passed`,
        so an evaluator that skips or fails does not block the request it was
        guarding. Check `passed` and let the request through when it is true.
      operationId: postApiGuardrailsByEvaluatorEvaluate
      parameters:
        - in: path
          name: evaluator
          required: true
          schema:
            type: string
          description: >-
            Which evaluator to run. Either a built-in id (`ragas/faithfulness`),
            the slug of a monitor configured in this project, or
            `evaluators/{slug|id}` for a saved evaluator. `GET
            /api/evaluations/list` returns the built-in ids.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: object
                  additionalProperties: {}
                  description: >-
                    What the evaluator scores. Which fields are required depends
                    on the evaluator; its own entry under Built-in Evaluators
                    lists them.
                settings:
                  type: object
                  additionalProperties: {}
                  description: >-
                    Per-call overrides of the evaluator's settings. Anything
                    omitted falls back to the saved evaluator or monitor, then
                    to the evaluator's own defaults.
                trace_id:
                  type: string
                  nullable: true
                  description: Attaches the result to a trace you already sent
                evaluation_id:
                  type: string
                  nullable: true
                  description: Supply your own id to make the call idempotent
                evaluator_id:
                  type: string
                  nullable: true
                name:
                  type: string
                  nullable: true
                  description: Overrides the name the result is recorded under
                as_guardrail:
                  type: boolean
                  nullable: true
                  description: >-
                    Evaluate as a guardrail: a skipped or failed evaluation
                    answers `passed` rather than an error, so a caller can gate
                    on one field. The /api/guardrails path sets this for you.
              required:
                - data
              additionalProperties: false
      responses:
        '200':
          description: >-
            The evaluator ran, declined, or failed. Branch on `status`; in
            guardrail mode `passed` is set on all three.
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                    properties:
                      status:
                        type: string
                        const: processed
                      score:
                        type: number
                      passed:
                        type: boolean
                      label:
                        type: string
                      details:
                        type: string
                      cost:
                        type: object
                        properties:
                          currency:
                            type: string
                          amount:
                            type: number
                        required:
                          - currency
                          - amount
                        description: What running the evaluator cost
                      raw_response:
                        description: The evaluator's own output, unprocessed
                    required:
                      - status
                  - type: object
                    properties:
                      status:
                        type: string
                        const: skipped
                      details:
                        type: string
                        description: Why the evaluator declined to score this input
                      passed:
                        type: boolean
                        description: >-
                          Always true in guardrail mode, so a skip does not
                          block
                    required:
                      - status
                  - type: object
                    properties:
                      status:
                        type: string
                        const: error
                      error_type:
                        type: string
                        const: EVALUATOR_ERROR
                        description: 'Constant: the evaluator''s own type is not exposed'
                      details:
                        type: string
                      passed:
                        type: boolean
                        description: >-
                          Always true in guardrail mode, so a failure does not
                          block
                    required:
                      - status
                      - error_type
                      - details
        '400':
          description: >-
            The body was not valid JSON, failed validation, or omitted a field
            this evaluator requires
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: The failure, as a sentence
                  kind:
                    type: string
                    description: Stable failure code, on the failures that carry one
                  meta:
                    type: object
                    additionalProperties: {}
                    description: >-
                      What the code needs to be acted on, such as the missing
                      field
                required:
                  - error
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: The failure, as a sentence
                  kind:
                    type: string
                    description: Stable failure code, on the failures that carry one
                  meta:
                    type: object
                    additionalProperties: {}
                    description: >-
                      What the code needs to be acted on, such as the missing
                      field
                required:
                  - error
        '403':
          description: The API key lacks evaluations:manage
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: The failure, as a sentence
                  kind:
                    type: string
                    description: Stable failure code, on the failures that carry one
                  meta:
                    type: object
                    additionalProperties: {}
                    description: >-
                      What the code needs to be acted on, such as the missing
                      field
                required:
                  - error
        '404':
          description: No evaluator answers to that id
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: The failure, as a sentence
                  kind:
                    type: string
                    description: Stable failure code, on the failures that carry one
                  meta:
                    type: object
                    additionalProperties: {}
                    description: >-
                      What the code needs to be acted on, such as the missing
                      field
                required:
                  - error
components:
  securitySchemes:
    project_api_key:
      type: apiKey
      in: header
      name: X-Auth-Token
      description: >-
        Project API key for sending traces and accessing project-scoped
        resources. Format: sk-lw-... (no underscore). Obtain one by creating a
        project via the Admin API or the LangWatch UI.

````