Install & Compatibility
Where this runs
tested against v2.9.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 39.9MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 6.1s · import 0.000s · 41MB
39MB installed
● package 39MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
RESTfulClient
✓ from xinference_client import RESTfulClient
✗ from xinference.client import Client
AsyncRESTfulClient
✓ from xinference_client import AsyncRESTfulClient
✗ from xinference.client import Client
client
✓ from xinference_client import client
✗ from xinference.client import Client
This quickstart demonstrates how to connect to a running Xinference server, verify model availability, and perform a chat completion using the `Client` object. It assumes a Xinference server is running and a Large Language Model (LLM) is already launched on it.
import os
from xinference.client import Client
# Ensure a Xinference server is running, e.g., using 'xinference-local' command.
# Ensure an LLM (e.g., 'llama-2-chat') is launched on it.
XINFERENCE_SERVER_URL = os.environ.get("XINFERENCE_SERVER_URL", "http://127.0.0.1:9997")
# Use a model name known to be available on your Xinference server
LLM_MODEL_NAME = os.environ.get("XINFERENCE_LLM_MODEL", "llama-2-chat")
try:
client = Client(base_url=XINFERENCE_SERVER_URL)
# Verify connection and model availability
available_models = client.list_models()
if LLM_MODEL_NAME not in available_models:
raise ValueError(
f"Model '{LLM_MODEL_NAME}' not found on the Xinference server. "
"Please launch it first using `client.launch_model()` or select an available model from: "
f"{list(available_models.keys())}"
)
print(f"Successfully connected to Xinference server at {XINFERENCE_SERVER_URL}")
print(f"Using model: {LLM_MODEL_NAME}")
# Perform a chat completion using the v2 OpenAI-compatible API
messages = [{"role": "user", "content": "Hello, what is Xinference and what can it do?"}]
response = client.chat.completions.create(
model=LLM_MODEL_NAME,
messages=messages,
max_tokens=100
)
print("\nChat Completion Response:")
print(response.choices[0].message.content)
except Exception as e:
print(f"An error occurred: {e}")
print("Please ensure your Xinference server is running, accessible, and the specified LLM is launched.")
xinference --version
Upgrade
Version history
2.10.0latest on PyPI · released Jun 6, 2026
Audit
Dependencies
numpyrequiredNumerical operations, often used in model outputs (e.g., embeddings).
requestsrequiredHTTP client for communication with the Xinference server.
packagingrequiredUsed for version comparisons and managing package metadata.
msgpackrequiredEfficient binary serialization format used for data transfer.