---
title: "Tool Use, Unified"
description: "Hugging Face Transformers extends Jinja chat templates to cover tool use, giving a single portable API for passing tools to Mistral, Cohere, NousResearch and Llama models."
url: "https://swe.quest/articles/tool-use-unified-117f148d6f2c2374"
canonical: "https://huggingface.co/blog/unified-tool-use"
source: "Hugging Face"
published: "2024-08-12"
difficulty: "medium"
kind: "How-to"
reading_minutes: 11
tags: ["llms","ai-agents","python","api-design"]
---

# Tool Use, Unified

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2024-08-12, 11 min read, How-to. Original: [https://huggingface.co/blog/unified-tool-use](https://huggingface.co/blog/unified-tool-use)

## Summary

Hugging Face Transformers extends Jinja chat templates to cover tool use, giving a single portable API for passing tools to Mistral, Cohere, NousResearch and Llama models. Tools are defined as JSON schema, or as Python functions whose type hints and docstrings are converted automatically via get\_json\_schema. Tool calls go into the chat as a tool\_calls field on assistant messages, and results are added as separate tool-role messages. A full walkthrough with Hermes-2-Pro-Llama-3-8B shows the loop end to end. Parsing the model's emitted tool-call text is still model-specific and needs a little json.loads or regex work.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [AI agents](https://swe.quest/tags/ai-agents.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)
- [API design](https://swe.quest/tags/api-design.md) (Backend & APIs)

## Prerequisites

- LLM chat models ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- Python ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- JSON Schema

## Keywords

Hugging Face Transformers, chat templates, Jinja, tool calling, Hermes-2-Pro-Llama-3-8B, JSON Schema

## Related posts

- [Tiny Agents in Python: a MCP-powered agent in ~70 lines of code](https://swe.quest/articles/tiny-agents-in-python-a-mcp-powered-agent-in-70-lines-of-code-ec89d52eb52d9576.md): Hugging Face · 2025-05-23 · Medium · 16 min read · AI agents, LLMs, Python
  Hugging Face's huggingface\_hub Python SDK now includes an MCP client and a minimal Agent class, letting an LLM pull tools from MCP servers (stdio, SSE or streamable HTTP) and call them during inference.
- [From OpenAI to Open LLMs with Messages API on Hugging Face](https://swe.quest/articles/from-openai-to-open-llms-with-messages-api-on-hugging-face-98058f09a7d2acc1.md): Hugging Face · 2024-02-08 · Medium · 7 min read · Inference & serving, LLMs, API design, RAG & retrieval
  Text Generation Inference 1.4.0 adds a Messages API compatible with OpenAI's Chat Completion API, so open LLMs on Inference Endpoints can be called from existing OpenAI client code by changing the base URL and token.
- [Hugging Face x LangChain : A new partner package](https://swe.quest/articles/hugging-face-x-langchain-a-new-partner-package-4a05b92542fbd2d8.md): Hugging Face · 2024-05-14 · Medium · 4 min read · LLMs, Python, Inference & serving, RAG & retrieval
  langchain-huggingface is a new Python partner package jointly maintained by Hugging Face and LangChain, replacing community-written integrations that had drifted out of date.
- [Chat Templates: An End to the Silent Performance Killer](https://swe.quest/articles/chat-templates-an-end-to-the-silent-performance-killer-56e4408eee347f2d.md): Hugging Face · 2023-10-03 · Medium · 9 min read · LLMs, Python, Inference & serving, Model training
  Chat models are trained with incompatible formats for flattening role/content message lists into a single string, and feeding a model a different format than it was trained on causes severe but silent performance degradation.
- [ToolGrad: Efficient tool-use dataset generation with textual "gradients"](https://swe.quest/articles/toolgrad-efficient-tool-use-dataset-generation-with-textual-gradients-6d6804c563cc5125.md): Google Research · 2026-09-10 · Hard · 6 min read · Model training, AI agents, LLMs, Evaluation
  ToolGrad generates synthetic tool-use training data answer-first: it builds a verified API chain iteratively, then has an LLM write the matching user query, instead of inventing a query and searching for a solution with a DFS agent as ToolBench and ToolACE do.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
