You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: document tool calling on vLLM and MLX backends
openai-functions.md used to claim LocalAI tool calling worked only on
llama.cpp-compatible models. That was true when it was written; it's
not true now — vLLM (since PR #9328) and MLX/MLX-VLM both extract
structured tool calls from model output.
- openai-functions.md: new 'Supported backends' matrix covering
llama.cpp, vllm, vllm-omni, mlx, mlx-vlm, with the key distinction
that vllm needs an explicit tool_parser: option while mlx auto-
detects from the chat template. Reasoning content (think tags) is
extracted on the same set of backends. Added setup snippets for
both the vllm and mlx paths, and noted the gallery importer
pre-fills tool_parser:/reasoning_parser: for known families.
- compatibility-table.md: fix the stale 'Streaming: no' for vllm,
vllm-omni, mlx, mlx-vlm (all four support streaming now). Add
'Functions' to their capabilities. Also widen the MLX Acceleration
column to reflect the CPU/CUDA/Jetson L4T backends that already
exist in backend/index.yaml — 'Metal' on its own was misleading.
LocalAI supports running the OpenAI [functions and tools API](https://platform.openai.com/docs/api-reference/chat/create#chat-create-tools)across multiple backends. The OpenAI request shape is the same regardless of which backend runs your model — LocalAI is responsible for extracting structured tool calls from the model's output before returning the response.
To learn more about OpenAI functions, see also the [OpenAI API blog post](https://openai.com/blog/function-calling-and-other-api-updates).
14
14
15
-
LocalAI is also supporting[JSON mode](https://platform.openai.com/docs/guides/text-generation/json-mode) out of the box with llama.cpp-compatible models.
15
+
LocalAI also supports[JSON mode](https://platform.openai.com/docs/guides/text-generation/json-mode) out of the box on llama.cpp-compatible models.
16
16
17
-
💡 Check out also [LocalAGI](https://github.com/mudler/LocalAGI) for an example on how to use LocalAI functions.
17
+
💡 Check out [LocalAGI](https://github.com/mudler/LocalAGI) for an example on how to use LocalAI functions.
18
+
19
+
## Supported backends
20
+
21
+
| Backend | How tool calls are extracted |
22
+
|---------|------------------------------|
23
+
|`llama.cpp`| C++ incremental parser; any `ggml`/`gguf` model works out of the box, no configuration needed |
24
+
|`vllm`| vLLM's native `ToolParserManager` — select a parser with `tool_parser:<name>` in the model `options`. Auto-set by the gallery importer for known families |
25
+
|`vllm-omni`| Same as vLLM |
26
+
|`mlx`|`mlx_lm.tool_parsers` — **auto-detected from the chat template**, no configuration needed |
27
+
|`mlx-vlm`|`mlx_vlm.tool_parsers` (with fallback to mlx-lm parsers) — **auto-detected from the chat template**, no configuration needed |
28
+
29
+
Reasoning content (`<think>...</think>` blocks from DeepSeek R1, Qwen3, Gemma 4, etc.) is returned in the OpenAI `reasoning_content` field on the same backends.
18
30
19
31
## Setup
20
32
21
-
OpenAI functions are available only with `ggml` or `gguf` models compatible with `llama.cpp`.
33
+
### llama.cpp
34
+
35
+
No configuration required — the autoparser detects the tool call format for any `ggml`/`gguf` model that was trained with tool support.
36
+
37
+
### vLLM / vLLM Omni
38
+
39
+
The parser must be specified explicitly because vLLM itself doesn't auto-detect one. Pass it via the model `options`:
40
+
41
+
```yaml
42
+
name: qwen3-8b
43
+
backend: vllm
44
+
parameters:
45
+
model: Qwen/Qwen3-8B
46
+
options:
47
+
- tool_parser:hermes
48
+
- reasoning_parser:qwen3
49
+
template:
50
+
use_tokenizer_template: true
51
+
```
52
+
53
+
When you import a vLLM model through the LocalAI gallery, the importer looks up the model family and pre-fills `tool_parser:` and `reasoning_parser:` for you — you only need to override them for non-standard model names.
54
+
55
+
Available tool parsers include `hermes`, `llama3_json`, `llama4_pythonic`, `mistral`, `qwen3_xml`, `deepseek_v3`, `granite4`, `kimi_k2`, `glm45`, and more. Available reasoning parsers include `deepseek_r1`, `qwen3`, `mistral`, `gemma4`, `granite`. See the upstream vLLM documentation for the full list.
56
+
57
+
### MLX / MLX-VLM
58
+
59
+
MLX backends **auto-detect** the right tool parser by inspecting the model's chat template — you don't need to set anything. Just load an MLX-quantized model that was trained with tool support:
60
+
61
+
```yaml
62
+
name: qwen2.5-0.5b-mlx
63
+
backend: mlx
64
+
parameters:
65
+
model: mlx-community/Qwen2.5-0.5B-Instruct-4bit
66
+
template:
67
+
use_tokenizer_template: true
68
+
```
69
+
70
+
The gallery importer will still append `tool_parser:` and `reasoning_parser:` entries to the YAML for visibility and consistency with the other backends, but those are informational — the runtime auto-detection in the MLX backend ignores them and uses the parser matched to the chat template.
22
71
23
-
You don't need to do anything specific - just use `ggml` or `gguf` models.
|[ik_llama.cpp](https://github.com/ikawrakow/ik_llama.cpp)| Hard fork of llama.cpp optimized for CPU/hybrid CPU+GPU with IQK quants, custom quant mixes, and MLA for DeepSeek | GPT | yes | yes | CPU (AVX2+) |
23
-
|[vLLM](https://github.com/vllm-project/vllm)| Fast LLM serving with PagedAttention | GPT| no |no | CUDA 12, ROCm, Intel |
24
-
|[vLLM Omni](https://github.com/vllm-project/vllm)| Unified multimodal generation (text, image, video, audio) | Multimodal GPT| no |no| CUDA 12, ROCm |
23
+
|[vLLM](https://github.com/vllm-project/vllm)| Fast LLM serving with PagedAttention | GPT, Functions | no |yes | CPU, CUDA 12, ROCm, Intel |
24
+
|[vLLM Omni](https://github.com/vllm-project/vllm)| Unified multimodal generation (text, image, video, audio) | Multimodal GPT, Functions | no |yes| CUDA 12, ROCm |
25
25
|[transformers](https://github.com/huggingface/transformers)| HuggingFace Transformers framework | GPT, Embeddings, Multimodal | yes | yes*| CPU, CUDA 12/13, ROCm, Intel, Metal |
26
-
|[MLX](https://github.com/ml-explore/mlx-lm)| Apple Silicon LLM inference | GPT| no |no| Metal |
27
-
|[MLX-VLM](https://github.com/Blaizzy/mlx-vlm)| Vision-Language Models on Apple Silicon | Multimodal GPT| no |no| Metal |
26
+
|[MLX](https://github.com/ml-explore/mlx-lm)| Apple Silicon LLM inference | GPT, Functions | no |yes| Metal, CPU, CUDA 12/13, Jetson L4T|
27
+
|[MLX-VLM](https://github.com/Blaizzy/mlx-vlm)| Vision-Language Models on Apple Silicon | Multimodal GPT, Functions | no |yes| Metal, CPU, CUDA 12/13, Jetson L4T|
28
28
|[MLX Distributed](https://github.com/ml-explore/mlx-lm)| Distributed LLM inference across multiple Apple Silicon Macs | GPT | no | no | Metal |
0 commit comments