TensorFlow Inference API

Model inference operations including classify, regress, and predict

OpenAPI Specification

tensorflow-inference-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: TensorFlow Serving REST Inference API
  description: A flexible, high-performance serving system for machine learning models designed for production environments. TensorFlow ModelServer supports REST APIs for model status checks, metadata retrieval, classification, regression, and prediction inference. All requests and responses use JSON format.
  version: '2.0'
  contact:
    name: TensorFlow Team
    url: https://www.tensorflow.org/
  license:
    name: Apache 2.0
    url: https://github.com/tensorflow/serving/blob/master/LICENSE
servers:
- url: http://{host}:{port}
  description: TensorFlow ModelServer
  variables:
    host:
      default: localhost
      description: ModelServer hostname
    port:
      default: '8501'
      description: REST API port (default 8501)
tags:
- name: Inference
  description: Model inference operations including classify, regress, and predict
paths:
  /v1/models/{model_name}:classify:
    post:
      operationId: classifyModel
      summary: Classify With Model
      description: Runs classification inference using the specified model. The request follows the PredictionService.Classify gRPC API semantics. Returns classification labels and scores.
      tags:
      - Inference
      parameters:
      - name: model_name
        in: path
        required: true
        description: The name of the model
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ClassifyRequest'
      responses:
        '200':
          description: Classification completed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClassifyResponse'
        '400':
          description: Invalid request format
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /v1/models/{model_name}/versions/{version}:classify:
    post:
      operationId: classifyModelVersion
      summary: Classify With Model Version
      description: Runs classification inference using a specific version of the model.
      tags:
      - Inference
      parameters:
      - name: model_name
        in: path
        required: true
        description: The name of the model
        schema:
          type: string
      - name: version
        in: path
        required: true
        description: The specific version number of the model
        schema:
          type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ClassifyRequest'
      responses:
        '200':
          description: Classification completed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClassifyResponse'
        '400':
          description: Invalid request format
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /v1/models/{model_name}:regress:
    post:
      operationId: regressModel
      summary: Regress With Model
      description: Runs regression inference using the specified model. The request follows the PredictionService.Regress gRPC API semantics. Returns regression values for each input example.
      tags:
      - Inference
      parameters:
      - name: model_name
        in: path
        required: true
        description: The name of the model
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RegressRequest'
      responses:
        '200':
          description: Regression completed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RegressResponse'
        '400':
          description: Invalid request format
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /v1/models/{model_name}/versions/{version}:regress:
    post:
      operationId: regressModelVersion
      summary: Regress With Model Version
      description: Runs regression inference using a specific version of the model.
      tags:
      - Inference
      parameters:
      - name: model_name
        in: path
        required: true
        description: The name of the model
        schema:
          type: string
      - name: version
        in: path
        required: true
        description: The specific version number of the model
        schema:
          type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RegressRequest'
      responses:
        '200':
          description: Regression completed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RegressResponse'
        '400':
          description: Invalid request format
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /v1/models/{model_name}:predict:
    post:
      operationId: predictModel
      summary: Predict With Model
      description: Runs prediction inference using the specified model. Supports both row format (instances array) and column format (inputs object). Returns predictions in the corresponding format.
      tags:
      - Inference
      parameters:
      - name: model_name
        in: path
        required: true
        description: The name of the model
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PredictRequest'
      responses:
        '200':
          description: Prediction completed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PredictResponse'
        '400':
          description: Invalid request format
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /v1/models/{model_name}/versions/{version}:predict:
    post:
      operationId: predictModelVersion
      summary: Predict With Model Version
      description: Runs prediction inference using a specific version of the model.
      tags:
      - Inference
      parameters:
      - name: model_name
        in: path
        required: true
        description: The name of the model
        schema:
          type: string
      - name: version
        in: path
        required: true
        description: The specific version number of the model
        schema:
          type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PredictRequest'
      responses:
        '200':
          description: Prediction completed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PredictResponse'
        '400':
          description: Invalid request format
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    PredictRequest:
      type: object
      description: Request body for prediction inference. Supports row format (instances) or column format (inputs).
      properties:
        signature_name:
          type: string
          description: Optional name of the signature to use
        instances:
          description: Row format input - an array of individual prediction inputs. Each element can be a scalar, list, or object with named inputs.
          oneOf:
          - type: array
            items:
              type: string
          - type: array
            items:
              type: number
          - type: array
            items:
              type: object
              additionalProperties: true
        inputs:
          type: object
          description: Column format input - a map of input tensor names to arrays of values for each input across all instances.
          additionalProperties: true
    RegressResponse:
      type: object
      description: Response from regression inference
      properties:
        result:
          type: array
          description: Regression result values, one per input example
          items:
            type: number
    ErrorResponse:
      type: object
      description: Error response returned when a request fails
      properties:
        error:
          type: string
          description: Human-readable error message describing what went wrong
    ClassifyRequest:
      type: object
      description: Request body for classification inference
      properties:
        signature_name:
          type: string
          description: Optional name of the signature to use
        context:
          type: object
          description: Context features shared across all examples
          additionalProperties: true
        examples:
          type: array
          description: List of input examples for classification
          items:
            type: object
            additionalProperties: true
    ClassifyResponse:
      type: object
      description: Response from classification inference
      properties:
        result:
          type: array
          description: Classification results per example, each being a list of label-score pairs
          items:
            type: array
            items:
              type: array
              items:
                oneOf:
                - type: string
                - type: number
    RegressRequest:
      type: object
      description: Request body for regression inference
      properties:
        signature_name:
          type: string
          description: Optional name of the signature to use
        context:
          type: object
          description: Context features shared across all examples
          additionalProperties: true
        examples:
          type: array
          description: List of input examples for regression
          items:
            type: object
            additionalProperties: true
    PredictResponse:
      type: object
      description: Response from prediction inference. Returns predictions in row format or outputs in column format depending on the request.
      properties:
        predictions:
          description: Row format predictions - one prediction per input instance
          oneOf:
          - type: array
            items: {}
          - type: number
          - type: string
        outputs:
          type: object
          description: Column format outputs - a map of output tensor names to value arrays
          additionalProperties: true
externalDocs:
  description: TensorFlow Serving REST API Documentation
  url: https://www.tensorflow.org/tfx/serving/api_rest