vLLM chat-template error: diagnose the failing layer
Distinguish missing tokenizer templates, wrong endpoints, content-format mismatches, and tool-parser failures without inventing a universal chat template.
Sources are linked in the guide. Read our editorial policy.
On this page 5 sections
A vLLM chat-template error usually requires fixing the tokenizer/template/request combination—not changing model weights. First establish whether you need chat or raw completion, whether the served tokenizer has the correct template, and whether the failure appears only with content arrays or tools. Do not paste a universal Jinja template into every model.
A reachable /v1/models endpoint proves model discovery works, not that chat rendering works. The local-AI hub covers the surrounding setup decisions.
Classify the failure before restarting
| Observation | Inspect first | Appropriate direction |
|---|---|---|
| Error says a chat template is missing | Exact checkpoint, tokenizer, and revision | Use the model’s documented chat template, or raw completion for a base model |
Request sends messages to /v1/completions |
Endpoint and request body | Chat uses messages; completion uses prompt |
| Jinja syntax or unsupported-role error | Reviewed template and full conversation roles | Correct syntax or model-incompatible conversation structure |
| Plain text works, content arrays fail | Template content format | Check detection; override only to the format the template expects |
| Chat works, adding tools fails | Tool-compatible template, parser, and tool history | Follow the exact model’s tool-calling recipe |
| Minimal direct request works, application fails | Gateway and client-transformed payload | Compare the actual serialized request |
Keep the original HTTP status, response body, server traceback, startup arguments, and package versions. Remove credentials and sensitive prompts before sharing them. Error wording and available flags differ across releases.
Establish a minimal endpoint baseline
These are unexecuted instructional examples for an existing vLLM OpenAI-compatible server on loopback, with Bash and curl. Set MODEL to an exact ID returned by the first request. Add your deployment’s authorization header if required; do not remove authentication to debug.
curl --silent --show-error --max-time 10 http://127.0.0.1:8000/v1/models
MODEL='your-served-model-id'
curl --silent --show-error --max-time 60 \
http://127.0.0.1:8000/v1/chat/completions \
-H 'Content-Type: application/json' \
--data-binary "{\"model\":\"$MODEL\",\"messages\":[{\"role\":\"user\",\"content\":\"Reply with one greeting.\"}],\"max_tokens\":32,\"stream\":false}"
Expect either a JSON chat response with choices, or an actionable error. Read the body: curl without --fail can exit successfully even when HTTP reports failure.
For a base text-generation model intended for raw continuation, compare the documented completion interface:
curl --silent --show-error --max-time 60 \
http://127.0.0.1:8000/v1/completions \
-H 'Content-Type: application/json' \
--data-binary "{\"model\":\"$MODEL\",\"prompt\":\"The capital of France is\",\"max_tokens\":16,\"stream\":false}"
Successful completion with failed chat narrows the investigation toward chat preprocessing. Switching endpoints is not a fix for an application that actually requires conversational roles or tools. The vLLM serving documentation defines both interfaces.
Inspect the tokenizer actually served
Record vllm --version and, in the server’s Python environment, python -m pip show vllm transformers. Check startup arguments for a tokenizer override, tokenizer revision, model revision, and explicit template. Looking at a similarly named Hugging Face repository is insufficient if the deployment uses a local snapshot.
For Hugging Face tokenizers, inspect tokenizer_config.json and any separately saved chat_template.jinja or named templates in that snapshot. A missing JSON field alone does not establish that no template exists.
If Transformers is already installed, this unexecuted Python example loads only a local tokenizer, not weights. Replace the directory with the exact tokenizer snapshot; local_files_only=True prevents a download:
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained(
'/srv/models/reviewed-tokenizer',
local_files_only=True,
trust_remote_code=False,
)
print(tokenizer.chat_template)
print(tokenizer.apply_chat_template(
[{'role': 'user', 'content': 'Hello'}],
tokenize=False,
add_generation_prompt=True,
))
Expected observation: a template and a model-specific rendered conversation, or an exception that helps locate the failure. This does not run generation. Compare control tokens, role handling, and the assistant-generation boundary with the model publisher’s prompt-format documentation. Transformers explains why different checkpoints need different control tokens.
If no appropriate template ships with an instruction model, obtain one from its publisher or a matching, reviewed example in your pinned vLLM release. After reviewing the model-specific file, the documented startup form is:
# Existing supported vLLM installation; paths must exist and match.
# Loopback diagnostic instance; do not start over an occupied port.
vllm serve /srv/models/reviewed-model --host 127.0.0.1 \
--chat-template /srv/templates/reviewed-model-chat.jinja
An explicit template changes prompt serialization; it does not turn a base model into a chat-trained model. Do not enable arbitrary trust_remote_code or modify weights to resolve missing metadata.
Separate content format from tool parsing
Start with string content, one user message, and no tools. Then compare this documented text-part shape in the otherwise identical request:
{"role":"user","content":[{"type":"text","text":"Reply with one greeting."}]}
vLLM documents automatic detection between string and openai template content formats. Check the detection in your own logs. Use --chat-template-content-format string or openai only when inspection establishes the expected format; neither flag repairs an absent or syntactically broken template. Role restrictions and unsupported multimodal parts are separate problems.
If ordinary chat succeeds but tool requests fail, follow the model-specific tool-calling documentation. Automatic tool selection requires --enable-auto-tool-choice and a compatible --tool-call-parser; some checkpoints also need a tool-aware template. Do not treat a parser name from another model as universal. Preserve valid tool-call IDs and matching tool-result messages when replaying history.
Verify progressively, not just with HTTP 200
Retest plain chat, the original role history, content arrays if needed, then tools. Inspect rendered behavior and returned tool arguments before allowing execution. Record the final template source/revision and tokenizer identity alongside startup flags. For memory failures rather than rendering failures, use the VRAM calculator and context sizing guide.
Evidence boundary: sources checked 2026-11-07 UTC. The stable vLLM serving page displayed October 24, 2026 and linked v0.33.0 examples; the live Transformers page linked v5.22.2 APIs. These are source versions, not tested installations. Python 3.10.0 package discovery found neither vllm nor transformers; a curl probe of http://127.0.0.1:8000/v1/models failed to connect. No tokenizer rendering, model loading, CUDA setup, or generation was executed. The closed March 2025 template-loading issue is historical context, not evidence that its bug persists in current releases.
Related: Ollama versus vLLM serving and MCP connected but no tools, which addresses discovery before any model can select a tool.