Why vLLM rejects chat requests for models without a chat template and how to fix it
A model loads, /v1/completions returns text, but /v1/chat/completions fails because the checkpoint ships no chat template. vLLM's documentation states that a model must provide a chat template, or be given one with --chat-template, before it can serve the chat completions API. The chat endpoint has to turn a list of role-tagged messages into the single prompt string the model was trained on, and without a template vLLM has no defined way to do that. This affects self-hosted open-weight models that were published as base or raw checkpoints, fine-tuned checkpoints where the tokenizer configuration was not carried over, and any OpenAI-compatible client that sends chat requests to a model that was never set up for them.
The fix is configuration and testing work, not a change to the model weights. Before you edit the serving command, confirm which template the checkpoint expects by reading its tokenizer configuration and model card, and check whether the upstream model publisher documents a template for the version you deployed. If the model ships a template, it may be missing from your local copy because of how the files were downloaded or staged, so compare your model directory with the source. If no template exists, you will need to write or obtain one that matches the model's turn markers, system prompt handling and stop tokens, and pass it with --chat-template. Ask the model owner or your platform team who will own that file, because a template that looks correct but mismatches the training format will produce fluent but wrong answers rather than a clear error.
Test the template end to end before any client depends on it. Send a simple system and user exchange to /v1/chat/completions, then a multi-turn conversation, and compare the rendered prompt with the format the model documentation describes. Check that stop tokens end generation where expected, and record the vLLM version and template file hash so an upgrade can be re-tested. If you plan to use tool calling, the template has additional requirements covered in the tool-aware section of this page. Your team should confirm these checks in its own environment with its chosen model and vLLM release, and keep the test prompts in version control so they run again after each change.
Configuration options for supplying a chat template
This table compares the three ways to give vLLM a chat template: the model's own tokenizer template, a template file passed at startup, and a tool-aware template for auto tool choice. Read each row as a decision point, checking when the option fits, what it changes for each chat request, and what to verify before users depend on it. The main takeaway is that a template only helps if it matches the model's expected message format, so every option needs a test with real chat and tool-call requests.
| Option | When it fits | What it changes in the request path | What to verify |
|---|---|---|---|
| Model's own tokenizer template | The checkpoint ships a chat template in its tokenizer configuration and the model is served as published | vLLM renders chat messages with the template bundled in the model files, so no extra startup flag is needed | Confirm the template exists in the model files, then send a plain chat request and check the rendered answer has no leaked role markers |
| Template file passed with the chat template option | The model ships no template, or the bundled template is wrong for your use case and you have a reviewed Jinja template | Chat messages are rendered with the supplied file instead of the bundled template, for every chat completions request on that server | Confirm the flag name for your vLLM release, then test system prompts, multi-turn history and assistant turns against the expected format |
| Tool-aware template for auto tool choice | You serve function calling with automatic tool selection and the model needs tool-role and tool-call messages in its prompt | Tool definitions, tool results and assistant tool calls are rendered in the format the model was trained to read, alongside auto tool choice | Confirm the flag names for your release, then run a full round trip: tool definition, tool call, tool result and final answer |
| Template supplied by the application | The calling application builds its own prompt text and sends completions requests rather than chat messages | The server does not apply a chat template to those requests, so the template gap does not affect them | Confirm the application uses the completions endpoint and that prompt formatting is tested in the application itself |
| Template chosen by model family documentation | The model family publishes a recommended template or serving recipe for vLLM | Settings follow the vendor's recommended template and parser choices for that family | Check the recipe matches your vLLM version and model revision, since templates can change between revisions |
| Template left unset after failure | Not a supported production choice, only a diagnostic state | Chat completions requests fail when no template is available, which confirms the gap | Use this state only to reproduce the error and record the exact message for your ticket |
Steps to add a chat template and verify it
This sequence confirms the missing template is the cause, supplies a Jinja chat template that matches the model's prompt format, and proves the chat completions API works for single-turn and multi-turn conversations. The result is a server you can hand to applications with a recorded set of passing checks.
Confirm the template error in server logs
Start from the failing deployment and read the vLLM server logs for the error that the model has no chat template. Then send a minimal request to
/v1/chat/completionswith one user message using curl or the OpenAI client pointed at your endpoint. The step is done when you can reproduce the same failure on demand and record the exact error text and the model name or path it refers to. If the error is different, such as an authentication or memory failure, stop here and work from that error instead.Check whether the tokenizer already carries a template
Inspect the model repository and its tokenizer files for a chat template, usually stored in the tokenizer configuration under the chat template key, or in a separate Jinja file. Confirm you are looking at the same revision that vLLM loads, since a pinned or local copy can differ from the latest upstream files. If a template exists, the problem is more likely a wrong or stale model path than a missing template. If none exists, record that the model needs one supplied before serving.
Obtain or write a template that matches the prompt format
Take the template from the model's official documentation or model card if the publisher provides one, and check it against the prompt format the model was trained on. Confirm the role names it expects, such as system, user and assistant, and the special tokens that mark turn boundaries and the generation prompt. Write a Jinja file only when no trusted template exists, and keep it in version control with the model revision it was built for. Templates with the wrong roles or tokens still render, but the model answers poorly, so review the rendered output for one sample conversation before moving on.
Start vllm serve with the chat template
Restart the server with
vllm serveand pass the template file with--chat-templatepointing to the Jinja file, keeping the model name and the other flags from the working configuration. Check the startup log to confirm the server loaded the model and reports the API routes, including/v1/chat/completions, without errors. Use the same model identifier in client requests as the one the server reports. The step is done when the server is ready and the log shows no template error.Send a single-turn chat request
Send the same minimal request from the first step, with one user message and a small
max_tokensvalue so the test is quick. Check that the HTTP response is successful, the message content is a coherent reply, and the response shows the expected finish reason and token counts. If the reply contains stray role labels or special tokens such as turn markers, the template is wrong for this model and needs revision. Save the request and response as your baseline test.Send a multi-turn request with a system message
Send a conversation with a system message, a user message, an assistant reply and a follow-up user question, so the template must render several turns in order. Check that the model uses context from the earlier turns and that the rendered prompt does not repeat, drop or misplace any role. Where your server supports it, compare the rendered prompt with the template output for the same messages to confirm the boundaries are correct. The step is done when the follow-up answer depends on earlier turns and the test passes consistently across a few repeated runs.
Test tool messages and record the passing configuration
If your applications use function calling, send a request with tools and a tool result message, because the template must handle tool-role and tool-call messages correctly. Confirm the tool call output parses as expected for your server configuration, and consult the vLLM tool calling documentation for any additional flags your model needs. Then record the vLLM version, model revision, template file hash, startup flags and the passing test outputs in your runbook so a future upgrade or restart can be checked against the same evidence.
How tool-aware templates support function calling
Tool calling in auto mode can take an optional --chat-template argument, and the vLLM tool calling docs describe that template as the place where tool-role and tool-call messages are handled. A chat template is the piece that turns the OpenAI-style message list into the prompt text the model actually sees. For a function calling workflow, the template must render more than plain user and assistant turns. It needs to render the system message, which often carries tool guidance, the user message, the assistant message that requests a tool call, and the tool message that carries the result back to the model. If any of these roles is dropped or flattened into ordinary text, the model never sees its own call or the answer it is waiting for.
A template that ignores the tool role breaks agent loops in a specific way. The client sends a request, the model returns a tool call, the application runs the function and appends a tool result, then sends the whole history again. If the template silently discards the tool result, the model repeats the call, asks for the same information again, or answers without the data it needed. The failure is often quiet: the endpoint returns HTTP 200 and well-formed JSON, so the error only shows up as wrong answers or looping agents. Tool-call output also depends on the model's own parser requirements, so confirm with the model card and the tool calling docs which parser and template pairing your model needs before you rely on it in production.
Test the round trip before any agent goes live. Send a chat completion request that includes a tools definition and a user prompt that should trigger it, then confirm the response contains a tool_calls entry. Append an assistant message with that call and a tool message with a known result, send the history again, and check that the model uses the result in its final answer. Run the same sequence against each model version you plan to serve, and record the template file and parser settings with the test. Ask your implementation partner or internal team to keep these cases in a regression suite, since a template change or a vLLM upgrade can alter rendering without any error message.
How a chat request becomes a prompt in vLLM
The request starts at the client, which posts messages to /v1/chat/completions on the vLLM server. The server looks for a chat template, first in the model's tokenizer configuration and then in a file passed with --chat-template, and renders the messages into a single prompt, including any tool-role and tool-call messages. If no template is found, the request fails before the engine generates anything, which is the branch to check first. Confirm the template source and render a test prompt before debugging the engine.
Chat requests render through a template before the engine generates any tokens.
Security and operational considerations for template changes
A chat template is part of how your vLLM server builds every prompt, so it carries the same review, versioning and exposure concerns as other serving configuration. The cards below cover the controls that connect the template fix to data handling, endpoint protection and repeatable operations.
Treat templates as serving configuration
A template file supplied with --chat-template changes what the model receives on every chat request, so it belongs in the same review path as launch flags and container images. Store it in version control, require a second reviewer for edits, and record which template file each running server loaded. Ask your team who owns the template after the initial fix, because an unowned file tends to drift from the model it was written for.
Templates shape prompts and data handling
A template decides how system prompts, user turns, tool results and retrieved documents are joined into the text the model sees. A template that inserts content into the wrong role, or that echoes system text back in output, can change what sensitive data reaches the model and what users read. Review a template against sample conversations that contain representative data classes before it reaches users, and rerun that review after any change.
Keep test endpoints behind the proxy
The --api-key option protects paths under /v1 but not /health, /metrics or /invocations. Test prompts that exercise a new template should go through the same reverse proxy as production traffic, so that operational endpoints are not reachable from user networks. Confirm the proxy allowlist with a request to each path that should be blocked, and keep the probe endpoints reachable only from the cluster or monitoring network.
Allowlist only user-facing endpoints
The vLLM security guidance recommends a reverse proxy that passes only the endpoints meant for users. For chat template work, that usually means the chat completions and tool-calling paths, with everything else denied by default. Record the allowlist as configuration, test it after each proxy or vLLM upgrade, and ask your security team to confirm that administrative paths such as pause, resume and abort are not exposed through the gateway.
Pin templates and model revisions together
A template written for one model revision can produce wrong turn boundaries or tool-call formatting after the weights or tokenizer config change. Pin the model revision, the tokenizer files and the template file together in one deployment record, and promote them as a unit. Ask whether your vLLM version also needs a matching template update, since the release notes for each minor release should be checked before you upgrade.
Log and audit every template change
Record who changed a template, when, which commit it came from, and which deployments loaded it. Keep the server startup logs that show the template path in use, so an incident responder can tell whether a behavior change followed a template edit or a model update. Retain these records under the same policy as other change evidence, and confirm with your auditors how long they expect to see them.
Questions teams ask before fixing chat template errors
How much effort does fixing missing chat template errors take?
The effort depends mainly on how many models you serve, how complex each template has to be, and whether tool calling is in scope. A single model that needs one template supplied with --chat-template is a small change to the serve command and a test pass. Effort grows when several models share a server, when each model family uses a different prompt format, or when applications send tool-role messages and expect structured tool calls back. Each additional model needs its own template check, its own test prompts and its own sign-off on the output. Ask any partner to break the quote into per-model work, template authoring, tool-aware template work and end-to-end testing, so you can see which part drives the total.
Can our own team fix chat template errors using the vLLM docs?
Often yes, if one engineer can read a model's tokenizer configuration, understand the role and message format the model was trained on, and test responses against it. The vLLM online serving documentation explains that a model must provide a chat template, or be given one with --chat-template, before the chat completions API works. Tool calling adds more detail, because the tool calling documentation describes an optional --chat-template for auto mode that handles tool-role and tool-call messages. Teams that have no one comfortable with prompt formats, or that must prove the fix to a security or compliance reviewer, often find an outside partner speeds up the work. Decide that after a short internal trial on one model.
What does the work need from our team before it starts?
The work needs four things from your side. First, access to the model files or the model repository, so the correct template and tokenizer settings can be read. Second, a list of the prompts and conversations your applications really send, including any function calling flows, because generic test prompts miss format problems that appear in production. Third, a named owner who can approve the expected behavior for each model. Fourth, rules for endpoint exposure. The vLLM security documentation says the --api-key option does not cover every route, and it recommends a reverse proxy that allowlists only the endpoints meant for users. Testing needs away to reach the server that matches those rules, so confirm the test path before work begins.
Does vLLM have a license cost for fixing chat templates?
vLLM has no paid edition. The project is licensed under Apache-2.0 according to its GitHub repository, and the cost of running it comes from other sources. The main costs are the GPU or other accelerator capacity that serves the model, the surrounding infrastructure, the implementation work and the people who operate the server afterward. A chat template fix adds implementation and testing time, and it may add some ongoing review whenever a model or template changes. Ask any quote to separate one-time work, such as writing and testing templates, from recurring work, such as retesting after model updates or vLLM upgrades.
How long does a chat template fix take?
The duration depends on the same drivers as effort: the number of models, how many template variants they need, the amount of tool calling behavior to validate, and how quickly your owners review the test results. A single model with a standard template can be checked quickly, while a set of models with tool-aware templates needs more review cycles. Because each engagement is scoped to its own models and applications, no fixed duration applies across all cases. Ask for a timeline in the written scope that lists the models, the test prompts, the review points and the points where your team must respond.
What changes when a new vLLM release ships?
vLLM ships new minor releases about every two weeks, for example v0.30.0 on September 22 and v0.31.0 on October 5, 2026, according to the vLLM GitHub releases page. A template that worked on one release can behave differently after an upgrade, so each release that you adopt needs a regression run against your test prompts. Check the release notes for changes to chat handling or tool calling, rerun the end-to-end tests on a staging server, and then roll the change to production. Build this into your upgrade plan rather than treating it as a one-time fix. Confirm with your partner whether retesting after each release is part of the scope or part of an ongoing support arrangement.
Which engineering checks should we run after the template is in place?
Run a repeatable set of checks on every model after the template is set. Send a standard chat conversation to the /v1/chat/completions endpoint, then a multi-turn conversation, then a request that includes a tool definition and a tool result, and compare each response with the expected output. Keep the test prompts under version control, record the vLLM version and model revision used for each run, and store the results with the change record. Watch the server logs for template rendering errors during startup and early requests. Repeat the same checks whenever the model, the template file or the vLLM version changes. Some teams also track request errors through the /metrics endpoint, which exposes request counts that can reveal a spike in failures after a change.
Testing prompts end to end before users depend on them
Test the chat template path through the same route users take, not only by calling the engine directly. Build a fixed test set that covers plain chat (one user message), multi-turn history (several alternating user and assistant turns), system prompts (a system message that sets behavior), tool definitions (a tools array in the request with tool_choice set to auto), and tool results (a tool role message returned after a model tool call). Each case should fail in a different way if the template is wrong: a missing template produces an error on any chat request, while a template that ignores tool-role messages usually produces replies that never use the tool result. Confirm with your model's documentation which roles and tool-call formats its template expects before you write expected outputs.
Record the expected outputs for each case, along with the vLLM version, the model revision or commit, the template file and its checksum, and the exact flags used to start vllm serve. Exact text will vary, so store the expected behavior as structural checks: the response parses, the tool_calls field appears when a tool is needed, the tool arguments are valid JSON, and the reply reflects a tool result when one is supplied. Run the set through the reverse proxy that allowlists /v1/chat/completions for users, using the same API key and routes your applications use. Testing only against an internal port can miss proxy body size limits, header rewriting or blocked fields.
Rerun the full set after every vLLM upgrade, every change to the model revision and every change to the template, and keep the results with the change record. Upstream releases ship about every two weeks, so a regression can arrive without any change on your side. Ask your engineers to confirm whether the tool-calling parser and template handling for your model changed in the release notes before accepting a new version. The vLLM tool calling documentation is the reference to check against when a test starts failing.
How DeployOpen scopes and supports vLLM template fixes
DeployOpen treats a missing chat template as a configuration and testing problem inside your own infrastructure. We agree the model, serving path and client applications in writing, then build, test and document the template fix so your team can repeat it on later model versions.
How we scope
- Inventory the models that fail chat completions and confirm which of them ship no chat template.
- Agree which endpoints, client applications and tool-calling features the template fix must support.
- Record the vLLM version, host and access model in a fixed-scope written agreement before work starts.
How we build
- Write or adapt a chat template for the model and supply it with the chat-template option.
- Add a tool-aware template only when function calling is in scope, and test tool-role and tool-call messages.
- Run end-to-end prompt tests through the chat completions endpoint, covering system, user and assistant turns.
How we hand over
- Deliver the template file, startup configuration and a test script your team can rerun after changes.
- Document the template source, the vLLM version tested and the known limits of each model variant.
- Walk your platform and application teams through the failure modes and how to confirm a fix.
How we support
- Retest templates when you move to a newer vLLM release or change the model checkpoint.
- Offer ongoing support and continuous testing as a retainer if your model catalog keeps changing.
- Ask any quote to itemize scoping, template work, testing and handover so the cost components are clear.

