Registry / llm-agents / xinference-client

xinference-client

JSON →
library2.10.0pypypi✓ verified 84d ago

Xinference-client is the official Python client library for interacting with a Xinference server. It allows users to manage and deploy various AI models (LLMs, embedding models, speech models, etc.) and perform inference. The library is actively maintained with frequent minor releases, often bi-weekly or monthly, reflecting updates in the broader Xinference ecosystem.

pip install xinference-client
INSTALL
IMPORT
SIG · XINFERENCE-CLIENT
X
xinference-client
llm-agentspythonv2.10.0
Install
6.1s avg
Import
Disk
39MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
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
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 39.9MB
glibc
py 3.103.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
Debug
Known issues
breakingThe chat completions API within `xinference-client` underwent a significant change around v2.0.0 (or Xinference server v1.0.0). Newer versions align with OpenAI's API (`client.chat.completions.create`), while older versions or backward compatibility might require `client.v1.chat.completions.create`.
fix
If you encounter `AttributeError: 'Client' object has no attribute 'chat'`, try `client.v1.chat.completions.create`. If using `client.v1` fails, ensure your Xinference server is updated to a compatible version (>=1.0.0 for v2 API) and your client library is also up-to-date.
affects: >=2.0.0
gotchaXinference models must be explicitly launched on the Xinference server before they can be used by the client. Simply having the server running is not enough; models need to be loaded into memory.
fix
Use `client.launch_model(model_name=..., model_type=...)` to load a model onto the server. Verify launched models with `client.list_models()` before attempting inference.
affects: All
gotchaThe Xinference client connects to a running Xinference server via HTTP. If the server is not running or the `base_url` provided to the `Client` constructor is incorrect, all client operations will fail with connection errors.
fix
Ensure your Xinference server is running. By default, it runs on `http://127.0.0.1:9997`. Double-check the `base_url` parameter, especially if running on a different host or port.
affects: All
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.
Agent activity
58 hits · last 30 days
node
52
Perplexity
1
OpenAI (training)
1
Resources
xinference-client — pip install xinference-client · libregistry