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

# Create inference result

> Create a new inference result. Identify the session with exactly one of `sessionId` or `sessionCustomId`. With `sessionCustomId` (your own conversation id) an existing session with that custom id is found and appended to: provide either `versionId` or `productId` as the anchor (if both are given, `versionId` wins). The session must already exist — create it first through the sessions API with that `custom_id`. If no matching session exists, the call is rejected with a 400. See [Inference Results](https://docs.galtea.ai/concepts/product/version/session/inference-result).




## OpenAPI

````yaml https://api.galtea.ai/openapi.json post /inferenceResults
openapi: 3.0.0
info:
  version: 1.0.0
  title: Product Management Service API
  description: API documentation for Product Management Service
  contact:
    name: Galtea AI
servers:
  - url: https://api.galtea.ai
security:
  - bearerAuth: []
tags: []
externalDocs:
  description: Galtea Platform Documentation
  url: https://docs.galtea.ai
paths:
  /inferenceResults:
    post:
      tags:
        - inference-results
      summary: Create inference result
      description: >
        Create a new inference result. Identify the session with exactly one of
        `sessionId` or `sessionCustomId`. With `sessionCustomId` (your own
        conversation id) an existing session with that custom id is found and
        appended to: provide either `versionId` or `productId` as the anchor (if
        both are given, `versionId` wins). The session must already exist —
        create it first through the sessions API with that `custom_id`. If no
        matching session exists, the call is rejected with a 400. See [Inference
        Results](https://docs.galtea.ai/concepts/product/version/session/inference-result).
      operationId: createInferenceResult
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                sessionId:
                  type: string
                  description: ID of the session. Provide this or `sessionCustomId`.
                  example: session_123
                sessionCustomId:
                  type: string
                  description: >
                    Your own conversation id. An existing session with this
                    custom id is found and appended to; if none matches the call
                    returns a 400, so create the session first through the
                    sessions API. Requires `versionId` or `productId`. Provide
                    this or `sessionId`.
                  example: my-conversation-42
                versionId:
                  type: string
                  description: >
                    Version anchor for the `sessionCustomId` lookup. Provide
                    this or `productId`; if both are given, `versionId` wins.
                  example: ver_123
                productId:
                  type: string
                  description: >
                    Product anchor for the `sessionCustomId` lookup when no
                    `versionId` is given: the existing session with that custom
                    id is found across the product's versions.
                  example: prod_123
                userId:
                  type: string
                  nullable: true
                  description: ID of the user
                  example: user_123
                index:
                  type: integer
                  description: Index of the inference result
                  example: 0
                status:
                  type: string
                  enum:
                    - PENDING
                    - GENERATED
                    - FAILED
                    - SKIPPED
                  description: Status of the inference result
                error:
                  type: string
                  nullable: true
                  description: >-
                    Error message explaining why this inference result failed or
                    was skipped
                input:
                  type: object
                  nullable: true
                  description: >-
                    Structured input data. For plain text, use { user_message:
                    "..." }
                actualOutput:
                  oneOf:
                    - type: string
                    - type: object
                  nullable: true
                  description: >-
                    Agent output. Plain text by default (the scored scalar); for
                    voice, an envelope { assistant_message, content: [{ type,
                    uri, transcript }] } carrying audio parts. An audio part
                    without a transcript is rejected with a 400.
                  example: Model response text
                retrievalContext:
                  type: string
                  nullable: true
                  description: Retrieval context information
                  example: Retrieved context document
                latency:
                  type: number
                  nullable: true
                  description: Latency in milliseconds
                inputTokens:
                  type: integer
                  nullable: true
                  description: Number of input tokens
                outputTokens:
                  type: integer
                  nullable: true
                  description: Number of output tokens
                cacheReadInputTokens:
                  type: integer
                  nullable: true
                  description: Number of cache read input tokens
                tokens:
                  type: integer
                  nullable: true
                  description: Total number of tokens
                costPerInputToken:
                  type: number
                  nullable: true
                  description: Cost per input token
                costPerOutputToken:
                  type: number
                  nullable: true
                  description: Cost per output token
                costPerCacheReadInputToken:
                  type: number
                  nullable: true
                  description: Cost per cache read input token
                cost:
                  type: number
                  nullable: true
                  description: Total cost
                conversationSimulatorVersion:
                  type: string
                  nullable: true
                  description: Version of the conversation simulator
      responses:
        '201':
          description: Inference result created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InferenceResult'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    InferenceResult:
      type: object
      properties:
        id:
          type: string
          example: ir_123
        sessionId:
          type: string
          example: session_123
        userId:
          type: string
          nullable: true
          example: user_123
        index:
          type: integer
          example: 0
          description: Order index within the session
        status:
          type: string
          enum:
            - PENDING
            - GENERATED
            - FAILED
            - SKIPPED
          example: PENDING
        error:
          type: string
          nullable: true
          description: >-
            Error message explaining why this inference result failed or was
            skipped
          example: null
        input:
          type: object
          nullable: true
          description: >-
            Structured input data. For plain text input, format is {
            user_message: "..." }
          example:
            user_message: User input text
        actualOutput:
          oneOf:
            - type: string
            - type: object
          nullable: true
          description: >-
            The agent turn output. Plain text by default (the scored scalar).
            For voice turns, an envelope { assistant_message, content: [{ type,
            uri, transcript }] } carrying audio parts — the scored scalar stays
            the canonical transcript.
          example: Model response
        latency:
          type: integer
          nullable: true
          example: 150
        inputTokens:
          type: integer
          nullable: true
          example: 100
        outputTokens:
          type: integer
          nullable: true
          example: 50
        cacheReadInputTokens:
          type: integer
          nullable: true
          example: 20
        tokens:
          type: integer
          nullable: true
          example: 150
          description: Total tokens
        costPerInputToken:
          type: number
          nullable: true
          example: 0.00001
        costPerOutputToken:
          type: number
          nullable: true
          example: 0.00003
        costPerCacheReadInputToken:
          type: number
          nullable: true
          example: 0.000005
        cost:
          type: number
          nullable: true
          example: 0.001
        creditsUsed:
          type: integer
          nullable: true
          example: 1
        conversationSimulatorVersion:
          type: string
          nullable: true
          example: 1.0.0
        traceId:
          type: string
          nullable: true
          example: a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4
          description: >-
            W3C trace ID for the root span created during direct inference. The
            same trace ID is propagated to the user endpoint via the traceparent
            header.
        createdAt:
          type: string
          format: date-time
        deletedAt:
          type: string
          format: date-time
          nullable: true
    Error:
      type: object
      properties:
        error:
          type: string
          example: Error type
        message:
          type: string
          example: Error message description
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authorization. Pass your API key in the Authorization header as
        a Bearer token. Both new (`gsk_*`) and legacy (`gsk-`) API keys are
        accepted, e.g. `Authorization: Bearer gsk_...` or `Authorization: Bearer
        gsk-...`.

````