需先注册 Baseten 账号并 truss login,BASETEN_API_KEY 不能替代登录;TRT-LLM 部署不支持 --watch 热重载;FP8 量化编译阶段显存需求高于推理阶段,单张 L4 可能编译失败
truss
basetenlabsMIT活跃维护把 AI/ML 模型打包成可直接上线的推理服务,省去手写 Docker 和部署脚本的麻烦,一条命令就能跑起来。
The simplest way to serve AI/ML models in production
pip install --upgrade truss
uvx truss login
uvx truss init qwen-2.5-3b && cd qwen-2.5-3b
uvx truss pushREADME 示例用 L4 GPU(24 GB 显存)跑 3B 模型;FP8 量化编译阶段需 2 张 GPU(num_builder_gpus: 2),单卡可能编译时 OOM;README 未说明 CPU 运行与其它 GPU 厂商支持情况
把模型打包成可部署服务的 CLI,省掉 Docker 和 K8s 配置,直接推到 Baseten 上线
把 AI/ML 模型打包成可直接上线的推理服务,省去手写 Docker 和部署脚本的麻烦,一条命令就能跑起来。
核心能力
- 用 config.yaml 声明模型、硬件与推理引擎
- 支持 vLLM、SGLang、TensorRT-LLM、transformers 等框架
- 自动处理容器化、依赖管理与 GPU 配置
- 部署后暴露 OpenAI 兼容的推理 API
- config.yaml 带 JSON schema,编辑器可补全校验
容易踩的坑
- v0.18.39rc0pre-release2026-11-05 · 2026-11-05 22:12 UTC
查看更新说明
- v0.18.38最新正式版2026-11-05 · 2026-11-05 16:57 UTC
What's Changed
- Add persistent_home to training CacheConfig by @johnnt849 in https://github.com/basetenlabs/truss/pull/2743
- feat(training): Add optional project accelerator by @johnnt849 in https://github.com/basetenlabs/truss/pull/2744
- feat(train): Name non-spot capacity standard by @spal1 in https://github.com/basetenlabs/truss/pull/2745
- chore: align checkpoint-restore example with default training base image by @sp3nx0r in https://github.com/basetenlabs/truss/pull/2750
- Release 0.18.38 by @basetenbot in https://github.com/basetenlabs/truss/pull/2751
New Contributors
- @sp3nx0r made their first contribution in https://github.com/basetenlabs/truss/pull/2750
Full Changelog: https://github.com/basetenlabs/truss/compare/v0.18.37...v0.18.38
- v0.18.372026-10-29 · 2026-10-29 20:12 UTC
查看更新说明
What's Changed
- Route base image builds through Build Platform by @amyhu-b10 in https://github.com/basetenlabs/truss/pull/2715
- feat: Reject install fields when docker_server.rebuild_free is set by @ndeepak-baseten in https://github.com/basetenlabs/truss/pull/2714
- Accept list form for truss config secrets by @cretz in https://github.com/basetenlabs/truss/pull/2721
- feat: Use a FROM-only image when docker_server.rebuild_free is set by @ndeepak-baseten in https://github.com/basetenlabs/truss/pull/2722
- Release 0.18.37 by @basetenbot in https://github.com/basetenlabs/truss/pull/2728
Full Changelog: https://github.com/basetenlabs/truss/compare/v0.18.36...v0.18.37
- v0.18.37rc0pre-release2026-10-27 · 2026-10-27 21:32 UTC
查看更新说明
What's Changed
- Fix Chains reference generation and refresh curated output by @pat-baseten in https://github.com/basetenlabs/truss/pull/2692
- feat(performance-client): add batch System One API by @michaelfeil in https://github.com/basetenlabs/truss/pull/2701
- feat(train): resolve
train init --examplesthrough ml-cookbook's examples index by @rcano-baseten in https://github.com/basetenlabs/truss/pull/2706 - feat(cli/train): show pending job messages on push and add --availability-model to train update by @yorhodes in https://github.com/basetenlabs/truss/pull/2707
- Add periodic banner recommending the Baseten CLI by @cretz in https://github.com/basetenlabs/truss/pull/2713
- fix: return 503 for model not ready on draft/watch deployments by @devtyagi3909 in https://github.com/basetenlabs/truss/pull/2682
- Raise certifi and Rust TLS deps for the emSign CA fix by @cretz in https://github.com/basetenlabs/truss/pull/2717
New Contributors
- @yorhodes made their first contribution in https://github.com/basetenlabs/truss/pull/2707
- @devtyagi3909 made their first contribution in https://github.com/basetenlabs/truss/pull/2682
Full Changelog: https://github.com/basetenlabs/truss/compare/v0.18.35...v0.18.37rc0
- v0.18.362026-10-21 · 2026-10-21 18:18 UTC
查看更新说明
What's Changed
- Fix Chains reference generation and refresh curated output by @pat-baseten in https://github.com/basetenlabs/truss/pull/2692
- feat(performance-client): add batch System One API by @michaelfeil in https://github.com/basetenlabs/truss/pull/2701
- feat(train): resolve
train init --examplesthrough ml-cookbook's examples index by @rcano-baseten in https://github.com/basetenlabs/truss/pull/2706 - feat(cli/train): show pending job messages on push and add --availability-model to train update by @yorhodes in https://github.com/basetenlabs/truss/pull/2707
- Add periodic banner recommending the Baseten CLI by @cretz in https://github.com/basetenlabs/truss/pull/2713
- fix: return 503 for model not ready on draft/watch deployments by @devtyagi3909 in https://github.com/basetenlabs/truss/pull/2682
- Raise certifi and Rust TLS deps for the emSign CA fix by @cretz in https://github.com/basetenlabs/truss/pull/2717
- Release 0.18.36 by @basetenbot in https://github.com/basetenlabs/truss/pull/2718
New Contributors
- @yorhodes made their first contribution in https://github.com/basetenlabs/truss/pull/2707
- @devtyagi3909 made their first contribution in https://github.com/basetenlabs/truss/pull/2682
Full Changelog: https://github.com/basetenlabs/truss/compare/v0.18.35...v0.18.36
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Truss
The simplest way to serve AI/ML models in production
Truss is the CLI for deploying and serving ML models on Baseten. Package your model's serving logic in Python, launch training jobs, and deploy to production—Truss handles containerization, dependency management, and GPU configuration.
Truss lets you serve models with the Baseten Inference Stack as well as deploy models from any open-source framework: vLLM, SGLang, TensorRT-LLM, transformers, diffusers, PyTorch, TensorFlow, and more.
Get started | 100+ examples | Documentation
Why Truss?
- Write once, run anywhere: Package model code, weights, and dependencies with a model server that behaves the same in development and production.
- Fast developer loop: Iterate with live reload, skip Docker and Kubernetes configuration, and use a batteries-included serving environment.
- Support for all Python frameworks: From
transformersanddiffusersto PyTorch and TensorFlow to vLLM, SGLang, and TensorRT-LLM, Truss supports models created and served with any framework. - Production-ready: Built-in support for GPUs, secrets, caching, and autoscaling when deployed to Baseten or your own infrastructure.
Installation
Install Truss with:
pip install --upgrade truss
Quickstart
Deploying a model to Baseten via Truss turns a Hugging Face model into a production-ready API endpoint. You write a config.yaml that specifies the model, the hardware, and the engine, then uvx truss push builds a TensorRT-optimized container and deploys it. No Python code, no Dockerfile, no container management.
This guide walks through deploying Qwen 2.5 3B Instruct, a small but capable LLM, from a config file to a production API. You'll set up Truss, write a config, deploy to Baseten, and call the model's OpenAI-compatible endpoint.
Set up your environment
Before you begin:
- Sign up or sign in to Baseten.
- Install uv, a fast Python package manager. This guide uses
uvxto run Truss commands without a separate install step.
Authenticate with Baseten
Log in:
uvx truss login
The CLI asks how you want to authenticate. Generate an API key from Settings > API keys if you pick the paste path:
💻 Let's add a Baseten remote!
How would you like to authenticate?
Paste an API key
Log in via browser (OAuth)
🤫 Quietly paste your API_KEY:
Skip the picker with --browser or --api-key:
uvx truss login --browser
uvx truss login --api-key "paste-your-api-key-here"
BASETEN_API_KEY is what the OpenAI client uses later to call the model. It does not skip truss login.
Create a Truss project
Scaffold a new project:
uvx truss init qwen-2.5-3b && cd qwen-2.5-3b
When prompted, name the model Qwen 2.5 3B.
? 📦 Name this model: Qwen 2.5 3B
Truss Qwen 2.5 3B was created in ~/qwen-2.5-3b
This creates a directory with a config.yaml, a model/ directory, and supporting files. For engine-based deployments like this one, you only need config.yaml. The model/ directory is for custom Python code when you need custom preprocessing, postprocessing, or unsupported model architectures.
Write the config
Replace the contents of config.yaml with:
model_metadata:
tags:
- openai-compatible
model_name: Qwen-2.5-3B
resources:
accelerator: L4
use_gpu: true
trt_llm:
build:
base_model: decoder
checkpoint_repository:
source: HF
repo: "Qwen/Qwen2.5-3B-Instruct"
max_seq_len: 8192
quantization_type: fp8
tensor_parallel_count: 1
num_builder_gpus: 2
That's the entire deployment specification.
model_nameidentifies the model in your Baseten dashboard.resourcesselects an L4 GPU (24 GB VRAM), which is plenty for a 3B parameter model.trt_llmtells Baseten to use Engine-Builder-LLM, which compiles the model with TensorRT-LLM for optimized inference.checkpoint_repositorypoints to the model weights on Hugging Face. Qwen 2.5 3B Instruct is ungated, so no access token is needed.quantization_type: fp8compresses weights to 8-bit floating point, cutting memory usage roughly in half with negligible quality loss.max_seq_len: 8192sets the maximum context length for requests.num_builder_gpus: 2uses two GPUs during the build phase. FP8 quantization needs more GPU memory at compile time than at inference. The first-model guide says a single L4 can run out of memory during compilation without this.
Deploy
Push the model to Baseten. A default push is a published deployment. --watch (development mode with live reload) is not supported for TRT-LLM. For custom Python models, see Customize a model.
uvx truss push
You should see:
Deploying as a published deployment. Use --watch for a development deployment.
✨ Model Qwen 2.5 3B was successfully pushed ✨
Model ID: abc1d2ef
Deployment ID: xyz123
Endpoint: https://model-abc1d2ef.api.baseten.co
Logs: https://app.baseten.co/models/abc1d2ef/logs/xyz123
You'll need the model ID to call the model's API. You can also find it in your Baseten dashboard.
Baseten now downloads the model weights from Hugging Face, compiles them with TensorRT-LLM, and deploys the resulting container to an L4 GPU. You can watch progress in the logs linked above.
Call the model
Engine-based deployments serve an OpenAI-compatible API. Once the deployment shows "Active" in the dashboard, call it using the OpenAI SDK or cURL. Replace {model_id} with your model ID from the deployment output.
Install the OpenAI SDK if you don't have it, and export the API key the client will send:
uv pip install openai
export BASETEN_API_KEY="paste-your-api-key-here"
Create a chat completion:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["BASETEN_API_KEY"],
base_url="https://model-{model_id}.api.baseten.co/environments/production/sync/v1",
)
response = client.chat.completions.create(
model="Qwen-2.5-3B",
messages=[
{"role": "user", "content": "What is machine learning?"}
],
)
print(response.choices[0].message.content)
You should see a response like:
Machine learning is a branch of artificial intelligence where systems learn
patterns from data to make predictions or decisions without being explicitly
programmed for each task...
Any code that works with the OpenAI SDK works with your deployment. Just point the base_url at your model's endpoint.
Your model ID is the string after /models/ in the logs URL from uvx truss push. You can also find it in your Baseten dashboard.
IDE support
Truss ships a JSON schema for config.yaml. Projects created with truss init include a schema reference automatically, giving you autocompletion, hover docs, and validation in any editor that supports the YAML language server (VS Code, JetBrains, Neovim, and others).
To add schema support to an existing config.yaml, add this comment as the first line:
# yaml-language-server: $schema=https://raw.githubusercontent.com/basetenlabs/truss/main/truss/config.schema.json