# Xinference

> Serve LLM, embedding, and multimodal models behind one OpenAI-compatible API

- Category: Models & Inference / Serving & Deployment
- Language: Python
- Repository: https://github.com/xorbitsai/inference
- Website: https://inference.readthedocs.io
- Canonical page: https://ai-tldr.dev/tools/xinference/

## In short

Xinference (Xorbits Inference) is an open-source platform for serving language, speech, embedding, and multimodal models. You launch a built-in or custom model with a single command, and it exposes that model over an OpenAI-compatible REST API, plus RPC, a CLI, and a web UI. It sits in the Serving & Deployment category of the Models & Inference tools and is open-source, written in Python.

## Overview

Xinference (Xorbits Inference) is an open-source platform for serving language, speech, embedding, and multimodal models. You launch a built-in or custom model with a single command, and it exposes that model over an OpenAI-compatible REST API, plus RPC, a CLI, and a web UI.

It is aimed at developers and data teams who want to run open models on their own hardware instead of calling a hosted API. Under the hood it can use different inference engines, including vLLM, llama.cpp, and Hugging Face Transformers, and it can spread work across GPUs and CPUs on one machine or several.

As a model-serving tool, it sits between your models and your application code. Because the API matches the OpenAI format, existing clients and libraries such as LangChain, LlamaIndex, and Dify can talk to it with little change.

## What it does

- OpenAI-compatible RESTful API, including a Function Calling API, plus RPC, CLI, and a web UI for managing models
- Multiple inference backends: vLLM, llama.cpp (via xllamacpp), Transformers, SGLang, and MLX
- Built-in catalog of open models covering chat, embeddings, speech, and multimodal tasks, each launchable with one command
- Runs on heterogeneous hardware, using GPUs and CPUs, with CPU and Metal support
- Distributed deployment that spreads model inference across multiple devices or machines
- Integrations with LangChain, LlamaIndex, Dify, FastGPT, RAGFlow, and Chatbox

## Getting started

Install Xinference, start a local server, then launch a model and call it from the Python client.

1. Install Xinference

   Install the full package with all backends. You can also install a single backend extra such as xinference[vllm], xinference[llama_cpp], or xinference[transformers].

```bash
pip install "xinference[all]"
```

2. Start the local server

   Run the local server, which serves the API and web UI on the chosen host and port.

```bash
xinference-local --host 0.0.0.0 --port 9997
```

3. Launch a model

   Launch a built-in model from the CLI, choosing the inference engine, name, size, and format.

```bash
xinference launch --model-engine vllm -n qwen2.5-instruct -s 0_5 -f pytorch
```

4. Call the model from Python

   Connect with the RESTful client, get the running model, and send a chat message.

```python
from xinference.client import RESTfulClient

client = RESTfulClient("http://127.0.0.1:9997")
model = client.get_model("qwen2.5-instruct")
model.chat(
    messages=[
        {"role": "user", "content": "Who won the world series in 2020?"}
    ]
)
```

## When to use it

- Self-host open chat models behind an OpenAI-compatible endpoint so existing OpenAI client code keeps working
- Serve embedding models for a RAG pipeline alongside chat and reranking models from one platform
- Run inference across several GPUs or machines for larger models or higher throughput
- Connect a serving backend to tools like Dify, LangChain, or LlamaIndex without writing a custom API layer
