Skip to main content

UniServe

English | 中文

UniServe is a model serving framework built on top of LitServe, designed to simplify the deployment and serving of machine learning models.

Features

  • Easy deployment of machine learning models with minimal code
  • Support for both simple APIs and file-based APIs
  • Built-in support for batching and multi-device inference
  • Extensible base classes for custom model APIs
  • CLI tool for launching model servers
  • Compatible with OpenAI API format for easy client integration

Installation

pip install uniserve

Or install from source:

pip install -e .

Quick Start

Run example

# Run with a simple API example
uniserve --api-list example.simple_api.api_list --port 8000
# Run with a simple API example in the no installed source code
uv run uniserve --api-list example.simple_api.api_list --port 8000

Create your own API

Create a custom API by extending the BaseLitAPI class:

from uniserve import BaseLitAPI

class MyModelAPI(BaseLitAPI):
    def load_model(self):
        # Load your model here
        model = MyModel()
        return model

    def decode_request(self, request):
        # Decode the incoming request
        return request.get("input")

    def predict(self, x):
        # Run model inference
        return self.model(x)

    def encode_response(self, output):
        # Encode the output into a response
        return {"result": output}

# Create an instance
my_api = MyModelAPI()
api_list = [my_api]

Then run your API:

uniserve --api-list my_module.api_list --port 8000

Debug Without Request

UniServe provides a convenient way to debug your API implementation without sending actual HTTP requests. This is especially useful during development to quickly test your model logic.

You can use the built-in debug method in your API class:

# Directly test your API methods without HTTP requests
api = MyModelAPI()
result = api.debug(request={"input": "test_data"}, device="cpu")
print(result)

See example/uni_api_debug.py for a complete example of how to debug your API implementation.

CLI Options

  • --api-list: Fully qualified name of the API list object to serve (required)
  • --port: Port to run the server on (default: 8000)
  • --host: Host to run the server on (default: 127.0.0.1)
  • --accelerator: Accelerator to use (e.g., 'cuda', 'cpu', 'auto') (default: auto)
  • --devices: Devices to use (e.g., 'auto', '[0]', '[0,1]') (default: auto)
  • --api-path: API endpoint path (default: None)

Base Classes

  • BaseLitAPI: Base class for simple APIs, extends LitAPI with a setup method
  • RequestLitAPI: Base class for handling file uploads with additional parameters
  • MultiFileLitAPI: Alternative base class for handling multiple file uploads
  • NNRequestLitAPI: Specialized base class for neural network inference with structured preprocessing and postprocessing steps

Examples

Check the example/ directory for more detailed examples of how to use UniServe with different types of models.

License

This project is licensed under the GPL-3.0 License - see the LICENSE file for details.

Metadata

Release files for uniserve 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for uniserve 0.0.6
File Actions
uniserve-0.0.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details for uniserve-0.0.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
uniserve-0.0.6-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for uniserve-0.0.6-cp313-cp313-macosx_11_0_arm64.whl
uniserve-0.0.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for uniserve-0.0.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
uniserve-0.0.6-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for uniserve-0.0.6-cp312-cp312-macosx_11_0_arm64.whl
uniserve-0.0.6-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for uniserve-0.0.6-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
uniserve-0.0.6-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for uniserve-0.0.6-cp311-cp311-macosx_11_0_arm64.whl
uniserve-0.0.6-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details for uniserve-0.0.6-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
uniserve-0.0.6-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details for uniserve-0.0.6-cp310-cp310-macosx_11_0_arm64.whl

Total release size: 5.1 MB

Release files / uniserve-0.0.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL uniserve-0.0.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 1.4 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
65f31fc0878cef1ec3b3fb53543c5a35c203cd33be4404dd10ec11d6ed6a03b4
BLAKE2b-256 checksum
How to use checksums
337125096e555f50d53761d1ec0c36b776d5c1f3de640e35c3c960b0929f1094
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / uniserve-0.0.6-cp313-cp313-macosx_11_0_arm64.whl

Download URL uniserve-0.0.6-cp313-cp313-macosx_11_0_arm64.whl
Size 691.4 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
88857dafa0d463bca2e8bbfc66e5b5f9369828532979b488bb138c8b38692c4d
BLAKE2b-256 checksum
How to use checksums
77cf9c90cc126a57b89489fa3c1f4a109d335b2da8888a706e39cca7762241bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / uniserve-0.0.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL uniserve-0.0.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 1.0 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a91557ca0b24bc7954924670b7c24d33c801c8efb6a91f6d4de5bd93c9cb56a4
BLAKE2b-256 checksum
How to use checksums
f845096279159cc970779efd100b5c5b9757785255ac12b828c23405cd3133cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / uniserve-0.0.6-cp312-cp312-macosx_11_0_arm64.whl

Download URL uniserve-0.0.6-cp312-cp312-macosx_11_0_arm64.whl
Size 518.4 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a55df5d78a72214b4cb9e4a15cbbaa3555e01fb65ef87c5f9588b2355753c383
BLAKE2b-256 checksum
How to use checksums
8a6c47bb6e5f77a35c2673bf6dd192b2d6d01fad634e42d8bc2e844330b8b6dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / uniserve-0.0.6-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL uniserve-0.0.6-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 650.8 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
b63fec9a61a13e0b736098ca9133cb8861327d1bba879ed3150ba7bd30c60be5
BLAKE2b-256 checksum
How to use checksums
d8efbbc42b2c1178ddabf13a66c5b6f5e2c563f6c39bb106a94efc5fd53a9d50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / uniserve-0.0.6-cp311-cp311-macosx_11_0_arm64.whl

Download URL uniserve-0.0.6-cp311-cp311-macosx_11_0_arm64.whl
Size 348.2 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ef557f63a3fb1c81be6509d5cf6a5078bfa2243d83de85264e1776f08defa648
BLAKE2b-256 checksum
How to use checksums
c94729ccaf1f17112a5fca853f03b362a56c10c4ce6f0fa136bc2394277aef49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / uniserve-0.0.6-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL uniserve-0.0.6-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 328.7 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
4436124e642b7e64064ea5801b53916c8090e49d05e89754193c717603a26055
BLAKE2b-256 checksum
How to use checksums
fa4d47d5db18fbaec2e1489e8196640d8f5fe6d382fb2f37f71918c4942b9ce3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / uniserve-0.0.6-cp310-cp310-macosx_11_0_arm64.whl

Download URL uniserve-0.0.6-cp310-cp310-macosx_11_0_arm64.whl
Size 177.7 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c03e00f491976533586c93569dcb790ea28eb3aae88351408da714eeb38b31ea
BLAKE2b-256 checksum
How to use checksums
4415a779c72d1238b4b6d60eb16196d2373adbb628ffac20e3425d97e6e382b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Security for uniserve 0.0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page