Triton-sdk
Python SDK for NVIDIA Triton Inference Server, focused on LLM workloads
(TensorRT-LLM and vLLM backends). One public API — generate / stream / chat,
with backend and transport (HTTP / gRPC) differences hidden inside.
Key features:
- One LLM API across supported backends:
generate,stream, andchatadapt vLLM and TensorRT-LLM model schemas, including backend-specific inputs and outputs. - OpenAI-style interface for native Triton endpoints: use
chat.completionsandcompletionsover HTTP or gRPC without deploying Triton's OpenAI frontend. Compatibility is partial; see the limitations below.
Quick start
Clone the repository:
git clone https://github.com/Shubin-vadim/triron_sdk.git
cd triron_sdk
Python 3.12 or newer is required. If uv is not installed, install it with pip:
python -m pip install uv
Install the SDK, optional dependencies, and development dependencies in one command:
uv sync --all-extras --dev
This installs the triton-inference-sdk distribution into the project's .venv; import it
in Python as triton_sdk. It does not install Triton Inference Server or vLLM: the
SDK is a client, and it sends requests to a Triton server where a model is already
running. You do not need Triton or vLLM installed on the computer running the SDK.
Prepare Triton and an LLM model
If you do not already have a Triton deployment, follow NVIDIA's Triton Server Quickstart to install and start the server. A running Triton process alone is not enough: it must also have an LLM backend installed and a compatible model configured and loaded in its model repository. The SDK cannot install or load these server-side components for you.
Choose the backend you plan to use and follow its setup guide:
- vLLM: NVIDIA's Triton vLLM backend guide covers the backend-enabled container and sample model repository.
- TensorRT-LLM: NVIDIA's TensorRT-LLM backend Getting Started guide covers the compatible container, model configuration, and server launch. Match the container and NVIDIA driver to your GPU; gated Hugging Face models may require a token.
After following the backend guide, confirm the model is loaded and ready in Triton. Then use its server address and Triton model name in the example below. The model's input schema must be supported by this SDK.
Connect to your Triton server
Once a Triton server is prepared, connect to it and pass the Triton model name configured on that server. This can be a vLLM model or a TensorRT-LLM ensemble/BLS model with a supported text-input schema; it is not necessarily the Hugging Face model ID.
from triton_sdk import SamplingParams, TritonLLMClient
with TritonLLMClient("your-triton-host:8001", protocol="grpc") as client:
response = client.generate(
"The capital of France is",
SamplingParams(max_tokens=32),
model="your-triton-model-name",
)
print(response.text)
for chunk in client.stream(
"Tell me a short story.",
SamplingParams(max_tokens=64),
model="your-triton-model-name",
):
print(chunk.text, end="", flush=True)
To run the repository's end-to-end example, set TRITON_DEFAULT_MODEL to your Triton
model name and run:
PowerShell:
$env:TRITON_DEFAULT_MODEL = "your-triton-model-name"
uv run python examples/quickstart.py
On Linux/macOS:
export TRITON_DEFAULT_MODEL=your-triton-model-name
uv run python examples/quickstart.py
The example uses HTTP at localhost:8000 and gRPC at localhost:8001 by default; set
TRITON_URL and TRITON_GRPC_URL to override them. Set TRITON_OPENAI_URL to the
address of an OpenAI-compatible Triton frontend to exercise that protocol too; otherwise,
that part of the example is skipped. The example requires both native HTTP and gRPC
endpoints, and a model configured for streaming (HTTP streaming also requires Triton's
generate extension). It uses the Qwen2.5-0.5B-Instruct tokenizer by default for chat;
set TRITON_CHAT_TEMPLATE_MODEL to a tokenizer matching your model. The first run may
download the tokenizer from Hugging Face.
The SDK reads model configuration from the server to select an adapter.
The SDK does not install or launch Triton, backends, or models.
OpenAI-compatible interface
Code written for openai is ported by swapping the constructor:
from triton_sdk.openai import OpenAICompatClient
client = OpenAICompatClient("localhost:8001", protocol="grpc", tokenizer="Qwen/Qwen2.5-0.5B-Instruct")
resp = client.chat.completions.create(model="vllm_model", messages=[{"role": "user", "content": "Hello"}])
resp.choices[0].message.content, resp.usage.total_tokens
for chunk in client.chat.completions.create(model="vllm_model", messages=[...], stream=True):
chunk.choices[0].delta.content
Two engines behind one interface:
protocol="http" | "grpc"— native KServe v2, works with any Triton; the chat template andusageare computed on the client.protocol="openai"— Triton's OpenAI frontend (/v1/chat/completions, port 9000); the template andusageare handled by the server,nativeis unavailable.usageis computed by the tokenizer fromtokenizer=(without it —None).tools,response_format,n > 1are not supported and raiseUnsupportedParameterError;extra_body={"top_k": ...}forwards backend-specific parameters.
To run the standalone example against an already-running OpenAI-compatible Triton frontend
(defaults to localhost:9000, model vllm_model):
uv run --with openai python examples/openai_sdk.py
Set TRITON_OPENAI_URL and TRITON_DEFAULT_MODEL first if your frontend or model uses a
different address or name.
Structure
| Path | Role |
|---|---|
triton_sdk/client/ |
Public API: TritonLLMClient (sync) and AsyncTritonLLMClient |
triton_sdk/transport/ |
Network layer: TransportInterface + HttpTransport / GrpcTransport, SSE parser, protobuf stubs |
triton_sdk/backends/ |
Input/output schema adapters: tensorrt_llm, vllm, generic (generate endpoint) |
triton_sdk/chat/ |
Chat templates: message list → raw prompt, token counting |
triton_sdk/openai/ |
OpenAI-compatible facade: chat.completions, completions, models with types mirroring openai |
triton_sdk/core/models/ |
Pydantic models for requests, responses, metadata, tensors |
triton_sdk/core/constants/ |
Protocols, KServe v2 paths, error codes, retry statuses |
triton_sdk/settings.py |
TritonSettings (pydantic-settings, TRITON_ prefix) |
triton_sdk/exceptions.py |
TritonError hierarchy |
triton_sdk/tests/ |
unit/ (transport mocks), integration/ (live Triton, integration marker) |
examples/ |
Ready-made usage scenarios |
model_repository/ |
Example vLLM model configuration for a Triton deployment |
Local development and integration tests
uv sync --all-extras --dev
cp triton_sdk/config/environment/env.sh.template env.sh && source env.sh
./code_quality_check.sh # ruff + mypy + pytest (unit)
Integration tests require a separately running Triton server and a vLLM model named
vllm_model, with native HTTP and gRPC endpoints. Configure the HTTP server address in
env.sh, then run pytest -m integration. The template sets the model name to
vllm_model; change it if your server uses another name. Set TRITON_GRPC_URL and
TRITON_OPENAI_URL when those endpoints use non-default addresses. Tests for Triton's
OpenAI frontend are skipped when the frontend is unavailable.
License
This project is licensed under the MIT License.
Metadata
Release files for triton-inference-sdk 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| triton_inference_sdk-0.1.0.tar.gz | 83.7 kB | Without provenance | Details for triton_inference_sdk-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| triton_inference_sdk-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for triton_inference_sdk-0.1.0-py3-none-any.whl |
Total release size: 195.5 kB
Release files / triton_inference_sdk-0.1.0.tar.gz
| Download URL | triton_inference_sdk-0.1.0.tar.gz |
|---|---|
| Size | 83.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7530e942912cd4eee9ac23f5a0d3b057c0153fb98c07aec71d294a31a59b0f47
|
|
BLAKE2b-256 checksum How to use checksums |
e06a8df506428a43d76c43c113908cff9a05053abeeeef27e48ed6f45643566d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / triton_inference_sdk-0.1.0-py3-none-any.whl
| Download URL | triton_inference_sdk-0.1.0-py3-none-any.whl |
|---|---|
| Size | 111.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2b13e5d123710dfa1540d8967f837c5dde79278e1de80fbc878065a16073642b
|
|
BLAKE2b-256 checksum How to use checksums |
32e38045ff2d9fc7b505ac2bc0f12fa1f1650e65b2418ff1050dde2a41510175
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for triton-inference-sdk 0.1.0
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.