# How can I determine which specific stop token triggered the termination?

**URL:** <https://discuss.vllm.ai/t/how-can-i-determine-which-specific-stop-token-triggered-the-termination/2103>\
**Category:** General\
**Created:** [December 10, 2025, 10:08am UTC](https://discuss.vllm.ai/t/how-can-i-determine-which-specific-stop-token-triggered-the-termination/2103 "2025-12-10T10:08:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Septemberlemon](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.vllm.ai/septemberlemon/32/915_2.png) [@Septemberlemon](https://discuss.vllm.ai/u/Septemberlemon)\
**Post date:** [December 10, 2025, 10:08am UTC](https://discuss.vllm.ai/t/how-can-i-determine-which-specific-stop-token-triggered-the-termination/2103/1 "2025-12-10T10:08:34Z")

</div>

I’m using multiple stop tokens, is there a way to identify which one actually stopped the generation?

---

<div class="post-metadata">

**Author:** ![RunLLM](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.vllm.ai/runllm/32/233_2.png) [@RunLLM](https://discuss.vllm.ai/u/RunLLM)\
**Post date:** [December 10, 2025, 10:08am UTC](https://discuss.vllm.ai/t/how-can-i-determine-which-specific-stop-token-triggered-the-termination/2103/2 "2025-12-10T10:08:54Z")

</div>

Yes, vLLM provides a way to identify which stop token (string or token ID) caused the generation to stop. The output includes a stop\_reason field, which will be set to the matched stop string or stop token ID that triggered the stop. This is demonstrated in both the API and tests, where stop\_reason reflects the specific stop condition encountered during generation, whether it is a string or token ID, and works with multiple stop tokens or strings in the stop or stop\_token\_ids parameters of SamplingParams. See [test\_stop\_strings.py](https://github.com/vllm-project/vllm/blob/main/tests/detokenizer/test_stop_strings.py) and [test\_stop\_reason.py](https://github.com/vllm-project/vllm/blob/main/tests/detokenizer/test_stop_reason.py) for examples.

Would you like more detail or a code example?

Sources:

- [test\_stop\_strings.py](https://github.com/vllm-project/vllm/blob/main/tests/detokenizer/test_stop_strings.py)
- [test\_stop\_reason.py](https://github.com/vllm-project/vllm/blob/main/tests/detokenizer/test_stop_reason.py)

Hint: Mention @RunLLM in the post for followups.

---

<div class="post-metadata">

**Author:** ![Septemberlemon](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.vllm.ai/septemberlemon/32/915_2.png) [@Septemberlemon](https://discuss.vllm.ai/u/Septemberlemon)\
**Post date:** [December 10, 2025, 10:58am UTC](https://discuss.vllm.ai/t/how-can-i-determine-which-specific-stop-token-triggered-the-termination/2103/3 "2025-12-10T10:58:09Z")

</div>

@RunLLM how get get it in openai client

---

<div class="post-metadata">

**Author:** ![RunLLM](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.vllm.ai/runllm/32/233_2.png) [@RunLLM](https://discuss.vllm.ai/u/RunLLM)\
**Post date:** [December 10, 2025, 10:58am UTC](https://discuss.vllm.ai/t/how-can-i-determine-which-specific-stop-token-triggered-the-termination/2103/4 "2025-12-10T10:58:28Z")

</div>

When using the OpenAI client with vLLM, the stop\_reason is returned in the API response as the stop string or token ID that caused the stop. You can access it via completion.choices[0].stop\_reason in the response object after making a request with multiple stop tokens or stop\_token\_ids in extra\_body. This works for both completions and chat completions APIs, as shown in vLLM’s [OpenAI-compatible server documentation](https://docs.vllm.ai/en/latest/serving/openai_compatible_server/#chat-template).

Would you like a code example?

Sources:

- [OpenAI-compatible server documentation](https://docs.vllm.ai/en/latest/serving/openai_compatible_server/#chat-template)

Hint: Mention @RunLLM in the post for followups.
