Klu

Klu Sessions API

Stores and retrieves session memory across multiple Action generations, enabling multi-turn conversational experiences such as copilots and coaches that retain context between requests via a session GUID.

OpenAPI Specification

klu-ai-openapi.yml Raw ↑
openapi: 3.0.1
info:
  title: Klu API
  description: >-
    REST API for the Klu (klu.ai) LLM app platform. The Klu Engine runs Actions -
    each encapsulating a prompt template, model config, context (RAG), and output
    parsing - against input variables to generate completions, and manages the data,
    feedback, sessions, models, apps, and workspaces around them. Authentication is
    via a Bearer API key obtained from the workspace API Keys settings.

    NOTE - Endpoints under the Actions, Context, and Apps/Workspaces paths reflect
    the publicly documented Klu API reference and SDK surface. Where the public docs
    document a capability via the SDK but do not publish the exact REST path, this
    spec models the conventional resource path used by the Klu Engine; see review.yml
    for which operations are documented verbatim versus inferred from the SDK.
  termsOfService: https://klu.ai/terms
  contact:
    name: Klu Support
    url: https://help.klu.ai/
  version: '1.0'
servers:
  - url: https://api.klu.ai/v1
    description: Klu Engine production API
security:
  - bearerAuth: []
tags:
  - name: Actions
    description: Run Actions to generate completions.
  - name: Context
    description: Manage Context libraries and documents for retrieval-augmented generation.
  - name: Data
    description: Data points produced by Action generations.
  - name: Feedback
    description: Ratings, corrections, and issues attached to data points.
  - name: Sessions
    description: Session memory for multi-turn conversations.
  - name: Models
    description: LLM providers and models available in the workspace.
  - name: Apps
    description: Apps (projects) grouping Actions, context, and experiments.
  - name: Workspaces
    description: Workspace administration.
paths:
  /actions:
    post:
      operationId: runAction
      tags:
        - Actions
      summary: Run an Action
      description: >-
        Executes a Klu Action by GUID against the provided input, returning the
        generated completion and a feedback URL containing the data point GUID.
        Supports streaming, async execution, response caching, session memory,
        context metadata filtering, and experiments.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunActionRequest'
      responses:
        '200':
          description: Generation result.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunActionResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/RateLimited'
  /context:
    post:
      operationId: createContext
      tags:
        - Context
      summary: Create a Context library
      description: >-
        Creates a new Context library. Klu automatically builds a vector index and
        performs retrieval-augmented generation via similarity search over its
        documents.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateContextRequest'
      responses:
        '200':
          description: Context library created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Context'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /context/{guid}/documents:
    post:
      operationId: addContextDocument
      tags:
        - Context
      summary: Add a document to a Context library
      description: Adds app data as a Context document with optional metadata.
      parameters:
        - $ref: '#/components/parameters/Guid'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddContextDocumentRequest'
      responses:
        '200':
          description: Document added.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContextDocument'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /context/{guid}/add_files:
    post:
      operationId: addContextFiles
      tags:
        - Context
      summary: Add files to a Context library
      description: Adds one or more files to an existing Context library.
      parameters:
        - $ref: '#/components/parameters/Guid'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddContextFilesRequest'
      responses:
        '200':
          description: Files added.
        '401':
          $ref: '#/components/responses/Unauthorized'
  /data/{guid}:
    get:
      operationId: getDataPoint
      tags:
        - Data
      summary: Get a data point
      description: >-
        Retrieves a data point by GUID, including its prompt, completion, and
        metadata. The data point GUID is returned in the feedback URL of an Action
        run.
      parameters:
        - $ref: '#/components/parameters/Guid'
      responses:
        '200':
          description: Data point.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataPoint'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /feedback:
    post:
      operationId: createFeedback
      tags:
        - Feedback
      summary: Submit feedback on a data point
      description: >-
        Submits feedback - a rating, correction, or issue - for a generation. For
        ratings, Klu uses 1 for negative and 2 for positive.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateFeedbackRequest'
      responses:
        '200':
          description: Feedback recorded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Feedback'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /sessions:
    post:
      operationId: createSession
      tags:
        - Sessions
      summary: Create a session
      description: Creates a session used to store and retrieve memory across Action generations.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSessionRequest'
      responses:
        '200':
          description: Session created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Session'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /sessions/{guid}:
    get:
      operationId: getSession
      tags:
        - Sessions
      summary: Get a session
      parameters:
        - $ref: '#/components/parameters/Guid'
      responses:
        '200':
          description: Session.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Session'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /models:
    get:
      operationId: listModels
      tags:
        - Models
      summary: List models
      description: Lists the LLM providers and models available in the workspace.
      responses:
        '200':
          description: Model list.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Model'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /models/{guid}:
    get:
      operationId: getModel
      tags:
        - Models
      summary: Get a model
      parameters:
        - $ref: '#/components/parameters/Guid'
      responses:
        '200':
          description: Model.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Model'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /apps:
    get:
      operationId: listApps
      tags:
        - Apps
      summary: List apps
      description: Lists the Apps (projects) in the workspace.
      responses:
        '200':
          description: App list.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/App'
        '401':
          $ref: '#/components/responses/Unauthorized'
    post:
      operationId: createApp
      tags:
        - Apps
      summary: Create an app
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAppRequest'
      responses:
        '200':
          description: App created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/App'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /apps/{guid}:
    get:
      operationId: getApp
      tags:
        - Apps
      summary: Get an app
      parameters:
        - $ref: '#/components/parameters/Guid'
      responses:
        '200':
          description: App.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/App'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /workspaces:
    get:
      operationId: listWorkspaces
      tags:
        - Workspaces
      summary: List workspaces
      responses:
        '200':
          description: Workspace list.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Workspace'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Klu API key passed as a Bearer token in the Authorization header.
  parameters:
    Guid:
      name: guid
      in: path
      required: true
      description: GUID of the resource.
      schema:
        type: string
  responses:
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: Too many requests.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    RunActionRequest:
      type: object
      required:
        - action
        - input
      properties:
        action:
          type: string
          description: GUID of the Action to run.
        input:
          description: Input string, or an object of key-value variable pairs for the prompt template.
          oneOf:
            - type: string
            - type: object
              additionalProperties: true
        streaming:
          type: boolean
          description: Stream the response token by token.
          default: false
        async_mode:
          type: boolean
          description: Execute asynchronously and return a generation GUID to retrieve results later.
          default: false
        cache:
          type: boolean
          description: Return a cached response when an equivalent generation is available.
          default: false
        session:
          type: string
          description: Session GUID to use for conversational context.
        metadata_filter:
          type: object
          additionalProperties: true
          description: Filter Context documents by metadata attributes.
        experiment:
          type: string
          description: Experiment GUID for A/B testing.
    RunActionResponse:
      type: object
      properties:
        msg:
          type: string
          description: The generated completion text.
        feedback_url:
          type: string
          description: URL containing the data point GUID for submitting feedback on this generation.
        stream_url:
          type: string
          description: Token streaming endpoint, present when streaming is enabled.
        data_guid:
          type: string
          description: GUID of the data point recorded for this generation.
    CreateContextRequest:
      type: object
      required:
        - name
        - description
        - type
      properties:
        name:
          type: string
        description:
          type: string
        type:
          type: string
          enum:
            - Files
            - Custom
        files:
          type: array
          items:
            type: string
    Context:
      type: object
      properties:
        guid:
          type: string
        name:
          type: string
        description:
          type: string
        type:
          type: string
    AddContextDocumentRequest:
      type: object
      required:
        - text
      properties:
        text:
          type: string
        meta_data:
          type: object
          additionalProperties: true
    ContextDocument:
      type: object
      properties:
        guid:
          type: string
        text:
          type: string
        meta_data:
          type: object
          additionalProperties: true
    AddContextFilesRequest:
      type: object
      required:
        - files
      properties:
        files:
          type: array
          items:
            type: string
    DataPoint:
      type: object
      properties:
        guid:
          type: string
        prompt:
          type: string
        completion:
          type: string
        meta_data:
          type: object
          additionalProperties: true
        created_at:
          type: string
          format: date-time
    CreateFeedbackRequest:
      type: object
      required:
        - data_guid
        - type
      properties:
        data_guid:
          type: string
          description: GUID of the data point being rated.
        type:
          type: string
          description: Feedback type - rating, correction, or issue.
          enum:
            - rating
            - correction
            - issue
        value:
          description: For a rating, 1 (negative) or 2 (positive); for a correction, the corrected text.
          oneOf:
            - type: integer
            - type: string
    Feedback:
      type: object
      properties:
        guid:
          type: string
        data_guid:
          type: string
        type:
          type: string
        value:
          oneOf:
            - type: integer
            - type: string
    CreateSessionRequest:
      type: object
      properties:
        action:
          type: string
          description: GUID of the Action this session is associated with.
        name:
          type: string
    Session:
      type: object
      properties:
        guid:
          type: string
        action:
          type: string
        name:
          type: string
    Model:
      type: object
      properties:
        guid:
          type: string
        llm:
          type: string
          description: Model identifier.
        provider:
          type: string
          description: Provider name, e.g. OpenAI or Anthropic.
        key:
          type: string
    App:
      type: object
      properties:
        guid:
          type: string
        name:
          type: string
        description:
          type: string
        app_type:
          type: string
    CreateAppRequest:
      type: object
      required:
        - name
      properties:
        name:
          type: string
        description:
          type: string
        app_type:
          type: string
    Workspace:
      type: object
      properties:
        guid:
          type: string
        name:
          type: string
        slug:
          type: string
    Error:
      type: object
      properties:
        error:
          type: string
        message:
          type: string