published fresh until

vLLM: Enable Llama 3.1 automatic tool calls

Summary As of November 2026, serve Llama 3.1 with automatic tool selection, the llama3_json parser and its matching chat template. Start the server with vllm serve

Not for connecting a basic chat client; see vllm-connect-openai-python-chat-client.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: Run vllm serve meta-llama/Llama-3.1-8B-Instruct --enable-auto-tool-choice --tool-call-parser llama3_json --chat-template examples/tool_chat_template_llama3.1_json.jinja.

When you need it

The quickstart pairs Llama 3.1 with a JSON tool-call parser and chat template. The client supplies a weather function, allows automatic selection, then handles the returned function name and arguments.

Steps

1. Start the server with the quickstart's model and flags:

vllm serve meta-llama/Llama-3.1-8B-Instruct \
    --enable-auto-tool-choice \
    --tool-call-parser llama3_json \
    --chat-template examples/tool_chat_template_llama3.1_json.jinja

2. Set up the client and the example handler. The page's example also passes an api_key argument to OpenAI (shown there as <key>); add your own value there:

from openai import OpenAI
import json
client = OpenAI(base_url="http://localhost:8000/v1")
def get_weather(location: str, unit: str):
    return f"Getting the weather for {location} in {unit}..."
tool_functions = {"get_weather": get_weather}

3. Define tools with the page's function schema. Formatting below is compacted:

tools = [{"type": "function", "function": {
    "name": "get_weather",
    "description": "Get the current weather in a given location",
    "parameters": {"type": "object", "properties": {
        "location": {"type": "string", "description": "City and state, e.g., 'San Francisco, CA'"},
        "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
    }, "required": ["location", "unit"]}
}}]

4. Request automatic tool selection and handle the response:

response = client.chat.completions.create(
    model=client.models.list().data[0].id,
    messages=[{"role": "user", "content": "What's the weather like in San Francisco?"}],
    tools=tools,
    tool_choice="auto",
)
tool_call = response.choices[0].message.tool_calls[0].function
print(f"Function called: {tool_call.name}")
print(f"Arguments: {tool_call.arguments}")
print(f"Result: {tool_functions[tool_call.name](**json.loads(tool_call.arguments))}")

Check it worked

The page shows Function called: get_weather, arguments containing location and unit, and Result: Getting the weather for San Francisco, CA in fahrenheit.... This is the example handler output, rather than weather fetched from a service.

Limits

The caller must define tools, provide relevant messages and handle calls in application logic. Llama 3 does not support parallel tool calls in this parser; parameters can arrive in an incorrect format. This parser supports JSON-based calling rather than built-in Python or custom formats. The page does not name a version that introduced this Llama 3.1 setup.

Not for: connecting a basic chat client; see vllm-connect-openai-python-chat-client.

Sources

Checked

2026-11-24; read <https://raw.githubusercontent.com/vllm-project/vllm/main/docs/features/tool_calling.md#quickstart>; no command was run.

Started from a post by @vLLM, packaged by the editor. Original post

Subjects

More in local models

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# vLLM: Enable Llama 3.1 automatic tool calls
Summary: As of November 2026, serve Llama 3.1 with automatic tool selection, the llama3_json parser and its matching chat template. Start the server with vllm serve
Copy for agent
get the whatworks thread vllm-enable-llama-3-1-automatic-tool-calls and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread vllm-enable-llama-3-1-automatic-tool-calls
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp