LocalAI Router API

The router API from LocalAI — 3 operation(s) for router.

Operations 4

POST /api/router/decide Classify a prompt against a router model's policies (decision oracle) #
POST /api/router/{name}/corpus Seed the KNN routing corpus with labelled example prompts #
DELETE /api/router/{name}/corpus Clear a router's KNN corpus #
GET /api/router/{name}/corpus/stats Inspect a router's KNN corpus (label counts only, never texts) #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/localai-router-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

localai-router-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  description: The LocalAI Rest API.
  title: LocalAI Router API
  contact:
    name: LocalAI
    url: https://localai.io
  license:
    name: MIT
    url: https://raw.githubusercontent.com/mudler/LocalAI/master/LICENSE
  version: 2.0.0
servers:
- url: /
tags:
- name: Router
paths:
  /api/router/decide:
    post:
      tags:
      - Router
      summary: Classify a prompt against a router model's policies (decision oracle)
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/schema.RouterDecideResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: string
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: string
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: string
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/schema.RouterDecideRequest'
        description: decide params
        required: true
      operationId: postApiRouterDecide
      x-operation-id-source: derived
  /api/router/{name}/corpus:
    post:
      tags:
      - Router
      summary: Seed the KNN routing corpus with labelled example prompts
      parameters:
      - description: router model name
        name: name
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/schema.RouterCorpusAddResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: string
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: string
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/schema.RouterCorpusAddRequest'
        description: labelled exemplars
        required: true
      operationId: postApiRouterByNameCorpus
      x-operation-id-source: derived
    delete:
      tags:
      - Router
      summary: Clear a router's KNN corpus
      parameters:
      - description: router model name
        name: name
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/schema.RouterCorpusClearResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: string
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: string
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: string
      operationId: deleteApiRouterByNameCorpus
      x-operation-id-source: derived
  /api/router/{name}/corpus/stats:
    get:
      tags:
      - Router
      summary: Inspect a router's KNN corpus (label counts only, never texts)
      parameters:
      - description: router model name
        name: name
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/schema.RouterCorpusStatsResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: string
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: string
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: string
      operationId: getApiRouterByNameCorpusStats
      x-operation-id-source: derived
components:
  schemas:
    schema.RouterDecideRequest:
      type: object
      properties:
        input:
          description: 'Input is the user-visible prompt text to classify. Required.

            Schema-shape extraction (chat-message concatenation, etc.) is

            the caller''s responsibility — matches the Probe contract used

            by the in-band middleware.'
          type: string
        router:
          description: 'Router is the name of the router model (a ModelConfig with a

            `router:` block). Required.'
          type: string
    schema.RouterDecideResponse:
      type: object
      properties:
        cache_similarity:
          description: 'CacheSimilarity carries the cosine similarity of the cache hit

            (0 when not cached).'
          type: number
        cached:
          description: 'Cached is true when the decision came from the L2 embedding

            cache rather than a fresh classifier run.'
          type: boolean
        candidate:
          description: 'Candidate is the model that would be routed to. Empty when no

            candidate covers Labels AND no fallback is configured.'
          type: string
        classifier:
          description: 'Classifier is the classifier name that produced the decision

            (e.g. "score").'
          type: string
        fallback:
          description: 'Fallback is true when Candidate is the router''s configured

            fallback because no candidate covered Labels. Lets callers

            distinguish "matched" from "fell back" without comparing names.'
          type: boolean
        labels:
          description: Labels is the set of active policy labels.
          type: array
          items:
            type: string
        latency_ms:
          description: LatencyMs is the classifier's wall-clock cost.
          type: integer
        nearest_similarity:
          description: 'NearestSimilarity is the cosine similarity of the closest KNN

            corpus entry — populated by the knn classifier even when the

            decision fell back because the probe was out of corpus range.

            0 for other classifiers.'
          type: number
        neighbors:
          description: 'Neighbors lists the corpus entries the knn classifier retrieved,

            by descending similarity, including ones below the similarity

            gate. Empty for other classifiers.'
          type: array
          items:
            $ref: '#/components/schemas/schema.RouterDecideNeighbor'
        router:
          description: Router echoes the requested router model.
          type: string
        score:
          description: 'Score is the top label''s softmax probability (the

            classifier-side confidence signal).'
          type: number
    schema.RouterDecideNeighbor:
      type: object
      properties:
        id:
          type: string
        labels:
          type: array
          items:
            type: string
        similarity:
          type: number
    schema.RouterCorpusClearResponse:
      type: object
      properties:
        cleared:
          type: integer
        router:
          type: string
    schema.RouterCorpusAddResponse:
      type: object
      properties:
        added:
          description: Added is how many entries were embedded, persisted, and indexed.
          type: integer
        label_counts:
          description: LabelCounts is the per-label exemplar count after the call.
          type: object
          additionalProperties:
            type: integer
        router:
          type: string
        skipped:
          description: 'Skipped counts entries whose text was already in the corpus —

            duplicates are rejected rather than double-weighted.'
          type: integer
        total:
          description: Total is the corpus size after the call.
          type: integer
    schema.RouterCorpusEntry:
      type: object
      properties:
        labels:
          type: array
          items:
            type: string
        text:
          type: string
    schema.RouterCorpusStatsResponse:
      type: object
      properties:
        embedding_model:
          type: string
        embedding_models:
          description: 'EmbeddingModels lists the embedder fingerprints present in the

            persisted corpus; more than one means part of the corpus is

            pending re-embedding on the next load.'
          type: array
          items:
            type: string
        label_counts:
          type: object
          additionalProperties:
            type: integer
        router:
          type: string
        store_name:
          type: string
        total:
          type: integer
    schema.RouterCorpusAddRequest:
      type: object
      properties:
        entries:
          type: array
          items:
            $ref: '#/components/schemas/schema.RouterCorpusEntry'
  securitySchemes:
    BearerAuth:
      type: apiKey
      name: Authorization
      in: header