Typesense Conversation Models API

Create and manage conversation models that define which LLM provider and configuration to use for generating conversational answers from search results.

OpenAPI Specification

typesense-conversation-models-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Typesense Analytics Analytics Events Conversation Models API
  description: The Typesense Analytics API allows developers to track and analyze search behavior by recording click, conversion, and visit events. It provides endpoints for creating analytics rules, logging events with metadata tags, and retrieving popular queries and queries with no results. This data can be used to improve search relevance through query suggestions, curations, and understanding user search patterns.
  version: '30.1'
  contact:
    name: Typesense Support
    url: https://typesense.org/support
  license:
    name: GPL-3.0
    url: https://www.gnu.org/licenses/gpl-3.0.html
  termsOfService: https://typesense.org/terms
servers:
- url: '{protocol}://{hostname}:{port}'
  description: Typesense Server
  variables:
    protocol:
      default: http
      enum:
      - http
      - https
    hostname:
      default: localhost
    port:
      default: '8108'
security:
- api_key_header: []
tags:
- name: Conversation Models
  description: Create and manage conversation models that define which LLM provider and configuration to use for generating conversational answers from search results.
paths:
  /conversations/models:
    get:
      operationId: listConversationModels
      summary: List All Conversation Models
      description: Retrieves all conversation models configured in the Typesense instance. Conversation models define the LLM provider and parameters used for generating answers in conversational search.
      tags:
      - Conversation Models
      responses:
        '200':
          description: List of conversation models
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ConversationModel'
        '401':
          description: Unauthorized
    post:
      operationId: createConversationModel
      summary: Create A Conversation Model
      description: Creates a new conversation model that specifies the LLM provider, model name, API key, and system prompt for generating conversational answers from search results.
      tags:
      - Conversation Models
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConversationModelCreateSchema'
      responses:
        '201':
          description: Conversation model created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationModel'
        '400':
          description: Bad request - invalid model configuration
        '401':
          description: Unauthorized
  /conversations/models/{modelId}:
    parameters:
    - $ref: '#/components/parameters/modelId'
    get:
      operationId: getConversationModel
      summary: Retrieve A Conversation Model
      description: Retrieves a specific conversation model by ID.
      tags:
      - Conversation Models
      responses:
        '200':
          description: Conversation model retrieved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationModel'
        '401':
          description: Unauthorized
        '404':
          description: Conversation model not found
    put:
      operationId: updateConversationModel
      summary: Update A Conversation Model
      description: Updates an existing conversation model configuration including the LLM provider, model name, and system prompt.
      tags:
      - Conversation Models
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConversationModelUpdateSchema'
      responses:
        '200':
          description: Conversation model updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationModel'
        '400':
          description: Bad request
        '401':
          description: Unauthorized
        '404':
          description: Conversation model not found
    delete:
      operationId: deleteConversationModel
      summary: Delete A Conversation Model
      description: Deletes a conversation model by ID.
      tags:
      - Conversation Models
      responses:
        '200':
          description: Conversation model deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: ID of the deleted conversation model.
        '401':
          description: Unauthorized
        '404':
          description: Conversation model not found
components:
  schemas:
    ConversationModelUpdateSchema:
      type: object
      properties:
        model_name:
          type: string
          description: Updated LLM model name.
        api_key:
          type: string
          description: Updated API key for the LLM provider.
        system_prompt:
          type: string
          description: Updated system prompt.
        max_bytes:
          type: integer
          description: Updated maximum context bytes.
    ConversationModel:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier of the conversation model.
        model_name:
          type: string
          description: Name of the LLM model.
        system_prompt:
          type: string
          description: System prompt for the model.
        max_bytes:
          type: integer
          description: Maximum context bytes.
        history_collection:
          type: string
          description: Collection storing conversation history.
        ttl:
          type: integer
          description: TTL for conversation history.
    ConversationModelCreateSchema:
      type: object
      required:
      - model_name
      - api_key
      - system_prompt
      properties:
        model_name:
          type: string
          description: Name of the LLM model to use, such as gpt-4o, claude-3-opus, or a model hosted on a compatible endpoint.
        api_key:
          type: string
          description: API key for authenticating with the LLM provider.
        account_id:
          type: string
          description: Account ID for the LLM provider if required.
        system_prompt:
          type: string
          description: System prompt that instructs the LLM how to generate answers from the search results context. This prompt is prepended to every conversation.
        max_bytes:
          type: integer
          description: Maximum number of bytes of search context to send to the LLM.
        history_collection:
          type: string
          description: Name of the collection to store conversation history.
        ttl:
          type: integer
          description: Time-to-live in seconds for conversation history entries.
  parameters:
    modelId:
      name: modelId
      in: path
      required: true
      description: ID of the conversation model.
      schema:
        type: string
  securitySchemes:
    api_key_header:
      type: apiKey
      in: header
      name: X-TYPESENSE-API-KEY
      description: API key for authenticating requests to the Typesense server.
externalDocs:
  description: Typesense Analytics Documentation
  url: https://typesense.org/docs/30.1/api/analytics-query-suggestions.html