Inworld LLM Router API

Inworld LLM Router — OpenAI-and-Anthropic-compatible chat-completions endpoint that routes prompts across hundreds of provider models (OpenAI, Anthropic, Google, Meta, Mistral, DeepSeek, Groq, etc.). Reusable named routers, conditional routing, provider routing, A/B traffic splitting, prompt compression, caching, web search, and a Claude-Code-compatible mode let teams consolidate model spend behind one API.

Documentation

Specifications

Schemas & Data

OpenAPI Specification

inworld-router-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Inworld LLM Router API
  description: >
    OpenAI- and Anthropic-compatible chat completions plus named-router lifecycle
    management. Routes prompts across hundreds of third-party LLMs (OpenAI,
    Anthropic, Google, Meta, Mistral, DeepSeek, Groq, etc.) behind one API and one
    billing relationship. Includes conditional routing, A/B traffic splitting,
    provider routing, prompt caching, prompt compression, integrated web search,
    and a Claude-Code-compatible mode.
  version: v1
  contact:
    name: Inworld Support
    url: https://docs.inworld.ai/tts/resources/support
  license:
    name: Inworld Terms of Service
    url: https://inworld.ai/legal/terms-of-service
servers:
  - url: https://api.inworld.ai
    description: Inworld Production API
security:
  - BasicAuth: []
tags:
  - name: Chat Completions
    description: OpenAI-compatible chat completions through the LLM Router.
  - name: Routers
    description: Named reusable routers with provider, conditional, and split rules.
paths:
  /v1/chat/completions:
    post:
      summary: Create Chat Completion
      description: >
        OpenAI-compatible chat completions. The `model` field accepts a specific
        model id, a `provider/model` id (e.g. `openai/gpt-4o`), `auto` for the
        router's default selection, or `inworld/<router-name>` to invoke a named
        router. Anthropic-compatible request shapes are supported via the
        Anthropic-compat header set documented at `/router/anthropic-compatibility`.
      operationId: createChatCompletion
      tags: [Chat Completions]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
      responses:
        '200':
          description: Chat completion returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
            text/event-stream:
              schema:
                $ref: '#/components/schemas/ChatCompletionStreamEvent'
        '4XX':
          $ref: '#/components/responses/ErrorResponse'
  /v1/models:
    get:
      summary: List Models
      description: List models available via the Router and first-party Inworld services.
      operationId: listRouterModels
      tags: [Chat Completions]
      responses:
        '200':
          description: Models returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListModelsResponse'
        '4XX':
          $ref: '#/components/responses/ErrorResponse'
  /v1/routers:
    get:
      summary: List Routers
      operationId: listRouters
      tags: [Routers]
      responses:
        '200':
          description: Routers returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListRoutersResponse'
        '4XX':
          $ref: '#/components/responses/ErrorResponse'
    post:
      summary: Create Router
      operationId: createRouter
      tags: [Routers]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Router'
      responses:
        '200':
          description: Created router.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Router'
        '4XX':
          $ref: '#/components/responses/ErrorResponse'
  /v1/routers/{routerId}:
    parameters:
      - name: routerId
        in: path
        required: true
        schema:
          type: string
    get:
      summary: Get Router
      operationId: getRouter
      tags: [Routers]
      responses:
        '200':
          description: Router returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Router'
        '4XX':
          $ref: '#/components/responses/ErrorResponse'
    patch:
      summary: Update Router
      operationId: updateRouter
      tags: [Routers]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Router'
      responses:
        '200':
          description: Updated router returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Router'
        '4XX':
          $ref: '#/components/responses/ErrorResponse'
    delete:
      summary: Delete Router
      operationId: deleteRouter
      tags: [Routers]
      responses:
        '204':
          description: Router deleted.
        '4XX':
          $ref: '#/components/responses/ErrorResponse'
components:
  securitySchemes:
    BasicAuth:
      type: http
      scheme: basic
  schemas:
    ChatCompletionRequest:
      type: object
      required: [model, messages]
      properties:
        model:
          type: string
          description: Model id, provider/model, `auto`, or `inworld/<router-name>`.
        messages:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
        stream:
          type: boolean
        temperature:
          type: number
        top_p:
          type: number
        max_tokens:
          type: integer
        max_completion_tokens:
          type: integer
        presence_penalty:
          type: number
        frequency_penalty:
          type: number
        seed:
          type: integer
        stop:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        logit_bias:
          type: object
          additionalProperties:
            type: number
        reasoning_effort:
          type: string
        user:
          type: string
        web_search:
          type: boolean
        web_search_options:
          type: object
        modalities:
          type: array
          items:
            type: string
        image_config:
          type: object
        extra_body:
          type: object
    ChatMessage:
      type: object
      required: [role, content]
      properties:
        role:
          type: string
          enum: [system, user, assistant, tool, developer]
        content:
          oneOf:
            - type: string
            - type: array
              items:
                type: object
        name:
          type: string
        tool_calls:
          type: array
          items:
            type: object
        tool_call_id:
          type: string
    ChatCompletionResponse:
      type: object
      properties:
        id:
          type: string
        object:
          type: string
          enum: [chat.completion]
        created:
          type: integer
        model:
          type: string
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              message:
                $ref: '#/components/schemas/ChatMessage'
              finish_reason:
                type: string
        usage:
          type: object
          properties:
            prompt_tokens:
              type: integer
            completion_tokens:
              type: integer
            total_tokens:
              type: integer
        metadata:
          type: object
          description: Router metadata — attempts, providers tried, reasoning.
    ChatCompletionStreamEvent:
      type: object
      description: Server-sent event stream — `data: <json>` chunks; final `data: [DONE]`.
    Router:
      type: object
      required: [name]
      properties:
        id:
          type: string
        name:
          type: string
        description:
          type: string
        rules:
          type: array
          items:
            type: object
            description: Provider, conditional, or split rule.
        defaultModel:
          type: string
        cache:
          type: object
          properties:
            enabled:
              type: boolean
            ttlSeconds:
              type: integer
        promptCompression:
          type: object
          properties:
            enabled:
              type: boolean
        webSearch:
          type: object
          properties:
            enabled:
              type: boolean
    ListRoutersResponse:
      type: object
      properties:
        routers:
          type: array
          items:
            $ref: '#/components/schemas/Router'
    ListModelsResponse:
      type: object
      properties:
        data:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              object:
                type: string
                enum: [model]
              provider:
                type: string
              capabilities:
                type: array
                items:
                  type: string
              pricing:
                type: object
    Error:
      type: object
      properties:
        code:
          type: integer
        message:
          type: string
  responses:
    ErrorResponse:
      description: Error response.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'