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

# Generate chat completion (deprecated)

> Deprecated compatibility proxy. New integrations should call https://openrouter.ai/api/v1/chat/completions directly with the provisioned OpenRouter key.



## OpenAPI

````yaml https://raw.githubusercontent.com/InsForge/InsForge/main/openapi/ai.yaml post /api/ai/chat/completion
openapi: 3.0.3
info:
  title: Insforge AI API
  version: 1.0.0
  description: >-
    Model Gateway helper APIs for OpenRouter key provisioning, model discovery,
    and deprecated compatibility proxy routes
servers: []
security: []
paths:
  /api/ai/chat/completion:
    post:
      tags:
        - Client
      summary: Generate chat completion (deprecated)
      description: >-
        Deprecated compatibility proxy. New integrations should call
        https://openrouter.ai/api/v1/chat/completions directly with the
        provisioned OpenRouter key.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatRequest'
      responses:
        '200':
          description: Chat completion response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
            text/event-stream:
              schema:
                type: string
                description: Server-sent events stream for streaming responses
        '400':
          description: Invalid request - missing model or messages
        '401':
          description: Unauthorized
        '500':
          description: Failed to get response
      deprecated: true
      security:
        - bearerAuth: []
components:
  schemas:
    ChatRequest:
      type: object
      required:
        - model
        - messages
      properties:
        model:
          type: string
          description: OpenRouter model identifier
          example: openai/gpt-4
        messages:
          type: array
          description: >-
            Array of messages for conversation (supports text, images, audio,
            and files/PDFs)
          items:
            $ref: '#/components/schemas/ChatMessage'
        stream:
          type: boolean
          default: false
          description: Enable streaming response via Server-Sent Events
        temperature:
          type: number
          minimum: 0
          maximum: 2
          description: Controls randomness in generation
        maxTokens:
          type: integer
          description: Maximum number of tokens to generate
        topP:
          type: number
          minimum: 0
          maximum: 1
          description: Nucleus sampling parameter
        webSearch:
          $ref: '#/components/schemas/WebSearchPlugin'
        fileParser:
          $ref: '#/components/schemas/FileParserPlugin'
        thinking:
          type: boolean
          description: >-
            Enable extended reasoning capabilities (appends :thinking to model
            ID if not already present). Not every model supports this, only
            works with Anthropic models with the :thinking suffix.
        tools:
          type: array
          description: Tool definitions for function calling
          items:
            $ref: '#/components/schemas/Tool'
        toolChoice:
          description: 'Controls tool usage: auto, none, required, or a specific function'
          oneOf:
            - type: string
              enum:
                - auto
                - none
                - required
            - type: object
              required:
                - type
                - function
              properties:
                type:
                  type: string
                  enum:
                    - function
                function:
                  type: object
                  required:
                    - name
                  properties:
                    name:
                      type: string
        parallelToolCalls:
          type: boolean
          description: Allow the model to call multiple tools in parallel
    ChatCompletionResponse:
      type: object
      properties:
        text:
          type: string
          description: AI model response content
        tool_calls:
          type: array
          description: >-
            Tool calls requested by the model (present when the model invokes
            tools)
          items:
            $ref: '#/components/schemas/ToolCall'
        annotations:
          type: array
          description: >-
            URL citations from web search results (present when webSearch is
            enabled)
          items:
            $ref: '#/components/schemas/UrlCitationAnnotation'
        metadata:
          type: object
          properties:
            model:
              type: string
            usage:
              $ref: '#/components/schemas/TokenUsage'
    ChatMessage:
      type: object
      required:
        - role
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
            - system
            - tool
          description: Role of the message sender
        content:
          type: string
          nullable: true
          description: Message content (nullable for assistant messages with tool_calls)
        tool_calls:
          type: array
          description: Tool calls made by the assistant (assistant messages only)
          items:
            $ref: '#/components/schemas/ToolCall'
        tool_call_id:
          type: string
          description: ID of the tool call being responded to (tool messages only)
    WebSearchPlugin:
      type: object
      required:
        - enabled
      properties:
        enabled:
          type: boolean
          description: Enable web search integration
        engine:
          type: string
          enum:
            - native
            - exa
          description: >
            Search engine selection:

            - native: Use provider's built-in web search (OpenAI, Anthropic,
            Perplexity, xAI)

            - exa: Use Exa's search API

            - undefined: Auto-select (native if available, otherwise Exa)
        maxResults:
          type: integer
          minimum: 1
          maximum: 10
          default: 5
          description: Maximum number of search results to include
        searchPrompt:
          type: string
          description: Custom prompt for attaching search results to the message
    FileParserPlugin:
      type: object
      required:
        - enabled
      properties:
        enabled:
          type: boolean
          description: Enable file parsing for PDFs in messages
        pdf:
          type: object
          properties:
            engine:
              type: string
              enum:
                - pdf-text
                - mistral-ocr
                - native
              description: >
                PDF processing engine:

                - pdf-text: Best for well-structured PDFs with clear text
                content (Free)

                - mistral-ocr: Best for scanned documents or PDFs with images
                ($2 per 1,000 pages)

                - native: Only for models with native file support (charged as
                input tokens)

                If not specified, defaults to native if available, otherwise
                mistral-ocr
    Tool:
      type: object
      required:
        - type
        - function
      properties:
        type:
          type: string
          enum:
            - function
        function:
          $ref: '#/components/schemas/FunctionDefinition'
    ToolCall:
      type: object
      required:
        - id
        - type
        - function
      properties:
        id:
          type: string
          description: Unique identifier for this tool call
        type:
          type: string
          enum:
            - function
        function:
          type: object
          required:
            - name
            - arguments
          properties:
            name:
              type: string
              description: The name of the function called
            arguments:
              type: string
              description: JSON string of the function arguments
    UrlCitationAnnotation:
      type: object
      properties:
        type:
          type: string
          enum:
            - url_citation
        urlCitation:
          type: object
          properties:
            url:
              type: string
              description: URL of the cited source
            title:
              type: string
              description: Title of the cited page
            content:
              type: string
              description: Relevant content snippet from the source
            startIndex:
              type: integer
              description: Start character index in response text where citation applies
            endIndex:
              type: integer
              description: End character index in response text where citation applies
    TokenUsage:
      type: object
      properties:
        promptTokens:
          type: integer
        completionTokens:
          type: integer
        totalTokens:
          type: integer
    FunctionDefinition:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          description: The name of the function to call
        description:
          type: string
          description: A description of what the function does
        parameters:
          type: object
          description: JSON Schema describing the function parameters
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````