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

# Run an inference query (streaming SSE)



## OpenAPI

````yaml /api-reference/openapi.json post /api/v1/user/inference
openapi: 3.1.0
info:
  title: 4MINDS API
  version: v1
  description: >-
    OpenAPI spec for the 4MINDS-native API (`/api/v1`), generated from the
    Python client's request/response definitions. Successful responses use the
    envelope `{"status":"success","data": ...}`; errors use
    `{"status":"error","message": ...}`.
servers:
  - url: https://api.4minds.ai
security:
  - bearerAuth: []
tags:
  - name: Models
  - name: Conversations
  - name: Datasets
  - name: Evaluations
  - name: Inference
paths:
  /api/v1/user/inference:
    post:
      tags:
        - Inference
      summary: Run an inference query (streaming SSE)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InferenceRequest'
      responses:
        '200':
          description: >-
            Server-Sent Events stream of `data: {...}` chunks, terminated by
            `data: [DONE]`. The client assembles the text chunks into a single
            InferenceResult.
          content:
            text/event-stream:
              schema:
                $ref: '#/components/schemas/InferenceResult'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '401':
          description: Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '429':
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
components:
  schemas:
    InferenceRequest:
      type: object
      required:
        - query
        - model_id
      properties:
        query:
          type: string
        model_id:
          type: integer
        conversation_id:
          type: string
          format: uuid
        thread_id:
          type: string
        enable_web_search:
          type: boolean
        max_tokens:
          type: integer
        temperature:
          type: number
        image_generation:
          type: boolean
        image_parameters:
          type: object
        persona:
          type: object
        base_model:
          type: boolean
        session_id:
          type: string
        user_id:
          type: string
        tenant_id:
          type: string
        top_k:
          type: integer
        top_p:
          type: number
        response_length_preference:
          type: string
          enum:
            - concise
            - balanced
            - detailed
        creativity_level:
          type: number
        factual_precision:
          type: number
    InferenceResult:
      additionalProperties: true
      description: |-
        The generated response return signature envelope matching inference
        queries.
      properties:
        response:
          default: ''
          description: >-
            The core text answer generation string payload generated by the
            model.
          title: Response
          type: string
        conversation_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            The unique identification tracking string if part of a continued
            conversation.
          title: Conversation Id
        thread_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: Thread tracking identifier reference index.
          title: Thread Id
        tokens_used:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          title: Tokens Used
        latency_ms:
          anyOf:
            - type: number
            - type: 'null'
          default: null
          title: Latency Ms
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          default: null
          title: Metadata
      title: InferenceResult
      type: object
    ErrorEnvelope:
      type: object
      required:
        - status
        - message
      properties:
        status:
          type: string
          enum:
            - error
        message:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Static, non-expiring API key: `Authorization: Bearer
        <FOURMINDS_API_KEY>`.

````