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

> ## Agent Instructions
> Krun API base URL: https://api.krun.ai. Authenticate server-side with `Authorization: Bearer $KRUN_API_KEY`; never put a Krun API key in browser code.
> Prefer the Python SDK in examples: `pip install krun-ai`, `from krun import Krun`. The TypeScript SDK `@krun-ai/sdk` is not published on npm yet: do not tell users to `npm install` it.
> The only question type is `choice`. `confidence` is the top-1 minus top-2 probability margin, not the probability that the answer is correct. `choice` is null when `abstain` is true.
> Usage reports `input_tokens` only. There are no output tokens.

# Feedback

> Report whether one answer of a previous decision was correct. `request_id` is the `X-Request-ID` of a `/v1/decide` call made by the same project, and `question_id` names the answer being reviewed. `expected` is the correct answer, typed like the question (`choice`: option id, `noul`: boolean, `score`: level index); `expected_decision` is still accepted for choice.



## OpenAPI

````yaml https://api.krun.ai/openapi.json post /v1/feedback
openapi: 3.1.0
info:
  title: Krun API
  description: >-
    Krun decision API. Authenticate with `Authorization: Bearer krun_live_...`
    from your server.
  version: 1.0.0-beta
servers:
  - url: https://api.krun.ai
    description: Production
security: []
tags:
  - name: decisions
    description: 'Decide on a context with typed questions: choice, noul, score'
  - name: feedback
    description: Report whether a decision was correct
  - name: models
    description: Available models
  - name: health
    description: Liveness and readiness
paths:
  /v1/feedback:
    post:
      tags:
        - feedback
      summary: Feedback
      description: >-
        Report whether one answer of a previous decision was correct.
        `request_id` is the `X-Request-ID` of a `/v1/decide` call made by the
        same project, and `question_id` names the answer being reviewed.
        `expected` is the correct answer, typed like the question (`choice`:
        option id, `noul`: boolean, `score`: level index); `expected_decision`
        is still accepted for choice.
      operationId: create
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeedbackRequest'
        required: true
      responses:
        '201':
          description: Feedback stored
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeedbackResponse'
        '400':
          description: INVALID_REQUEST
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '401':
          description: UNAUTHORIZED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '404':
          description: 'NOT_FOUND: no decision with this request_id in this project'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '429':
          description: RATE_LIMITED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
      security:
        - api_key: []
      x-codeSamples:
        - lang: python
          label: Python SDK
          source: |
            from krun import Krun

            client = Krun()

            client.feedback(
                request_id="req_0cf5441281f640ffbf0111c5a3ed9e50",
                question_id="needs_human",
                correct=False,
                expected={"type": "noul", "value": False},  # or {"type": "choice", "value": "billing"}
            )
components:
  schemas:
    FeedbackRequest:
      type: object
      required:
        - request_id
        - question_id
        - correct
      properties:
        request_id:
          type: string
          description: '`X-Request-ID` of a `/v1/decide` call made by the same project.'
        question_id:
          type: string
          description: >-
            Key of the answer being reviewed (the question id from the request).
            Always required, also for single-question

            requests, so every feedback row names exactly one answer.
        correct:
          type: boolean
          description: Whether the decision was right.
        expected:
          oneOf:
            - $ref: '#/components/schemas/ExpectedAnswer'
              description: >-
                The correct answer, typed like the question: `{"type": "choice",
                "value": "billing"}`,

                `{"type": "noul", "value": true}` or `{"type": "score", "value":
                2}`.
            - type: 'null'
        expected_decision:
          type:
            - string
            - 'null'
          description: >-
            Choice only, kept for compatibility: the option id that should have
            been chosen (≤ 200 characters). Same as

            `expected: {"type": "choice", "value": ...}`; if both are sent they
            must agree.
        metadata:
          type:
            - object
            - 'null'
          description: >-
            Optional JSON object (≤ 8 KiB serialized). Do not put personal data
            here.
      additionalProperties: false
      example:
        request_id: req_0b7f7c5e9a3d4a8c9f1e2d3c4b5a6978
        question_id: needs_human
        correct: false
        expected:
          type: noul
          value: true
    FeedbackResponse:
      type: object
      required:
        - id
        - object
        - request_id
        - question_id
        - created_at
      properties:
        id:
          type: string
        object:
          type: string
          description: Always `feedback`.
        request_id:
          type: string
        question_id:
          type: string
        created_at:
          type: string
          format: date-time
    ErrorBody:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
    ExpectedAnswer:
      oneOf:
        - type: object
          description: The option id that should have been chosen (1–200 characters).
          required:
            - value
            - type
          properties:
            value:
              type: string
              description: The option id that should have been chosen (1–200 characters).
            type:
              type: string
              enum:
                - choice
        - type: object
          description: Whether the proposition actually holds.
          required:
            - value
            - type
          properties:
            value:
              type: boolean
              description: Whether the proposition actually holds.
            type:
              type: string
              enum:
                - noul
        - type: object
          description: The correct level index (0 = first level).
          required:
            - value
            - type
          properties:
            value:
              type: integer
              format: int32
              description: The correct level index (0 = first level).
              minimum: 0
            type:
              type: string
              enum:
                - score
      description: >-
        The answer that should have been given, typed like the question
        (KRUN-011).
    ErrorDetail:
      type: object
      required:
        - code
        - message
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
          description: Stable machine-readable code.
        message:
          type: string
        request_id:
          type:
            - string
            - 'null'
          example: req_0b7f7c5e9a3d4a8c9f1e2d3c4b5a6978
    ErrorCode:
      type: string
      enum:
        - INVALID_REQUEST
        - INVALID_OPTIONS
        - PAYLOAD_TOO_LARGE
        - UNAUTHORIZED
        - FORBIDDEN
        - SIGNUP_RESTRICTED
        - NOT_FOUND
        - CONFLICT
        - INSUFFICIENT_CREDITS
        - RATE_LIMITED
        - QUOTA_EXCEEDED
        - UPSTREAM_TIMEOUT
        - UPSTREAM_UNAVAILABLE
        - INFERENCE_FAILED
        - INTERNAL_ERROR
  securitySchemes:
    api_key:
      type: http
      scheme: bearer
      bearerFormat: krun_live_...

````