!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}return t}()||function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}(),document.documentElement.setAttribute("data-announcement-bar-initially-dismissed",function(){try{return"true"===localStorage.getItem("docusaurus.announcement.dismiss")}catch(t){}return!1}())

[Skip to main content](#__docusaurus_skipToContent_fallback)

You are viewing the **preview** v0.2 docs. View the **stable** v0.1 docs [here](/v0.1/docs/get_started/introduction/). Leave feedback on the v0.2 docs [here](https://github.com/langchain-ai/langchainjs/discussions/5386).

[

![🦜️🔗 Langchain](/v0.2/img/brand/wordmark.png)![🦜️🔗 Langchain](/v0.2/img/brand/wordmark-dark.png)

](/v0.2/)[Integrations](/v0.2/docs/integrations/platforms/)[API Reference](https://v02.api.js.langchain.com)

[More](#)

*   [People](/v0.2/docs/people/)
*   [Community](/v0.2/docs/community)
*   [Tutorials](/v0.2/docs/additional_resources/tutorials)
*   [Contributing](/v0.2/docs/contributing)

[v0.2](#)

*   [v0.2](/v0.2/docs/introduction)
*   [v0.1](https://js.langchain.com/v0.1/docs/get_started/introduction)

[🦜🔗](#)

*   [LangSmith](https://smith.langchain.com)
*   [LangSmith Docs](https://docs.smith.langchain.com)
*   [LangChain Hub](https://smith.langchain.com/hub)
*   [LangServe](https://github.com/langchain-ai/langserve)
*   [Python Docs](https://python.langchain.com/)

[Chat](https://chatjs.langchain.com)[](https://github.com/langchain-ai/langchainjs)

Search

*   [Introduction](/v0.2/docs/introduction)
*   [Tutorials](/v0.2/docs/tutorials/)
    
    *   [Build a Question Answering application over a Graph Database](/v0.2/docs/tutorials/graph)
    *   [Tutorials](/v0.2/docs/tutorials/)
    *   [Build a Simple LLM Application](/v0.2/docs/tutorials/llm_chain)
    *   [Build a Query Analysis System](/v0.2/docs/tutorials/query_analysis)
    *   [Build a Chatbot](/v0.2/docs/tutorials/chatbot)
    *   [Build an Agent](/v0.2/docs/tutorials/agents)
    *   [Build an Extraction Chain](/v0.2/docs/tutorials/extraction)
    *   [Summarize Text](/v0.2/docs/tutorials/summarization)
    *   [Tagging](/v0.2/docs/tutorials/classification)
    *   [Build a Local RAG Application](/v0.2/docs/tutorials/local_rag)
    *   [Conversational RAG](/v0.2/docs/tutorials/qa_chat_history)
    *   [Build a Retrieval Augmented Generation (RAG) App](/v0.2/docs/tutorials/rag)
    *   [Build a Question/Answering system over SQL data](/v0.2/docs/tutorials/sql_qa)
*   [How-to guides](/v0.2/docs/how_to/)
    
    *   [How-to guides](/v0.2/docs/how_to/)
    *   [How to use example selectors](/v0.2/docs/how_to/example_selectors)
    *   [Installation](/v0.2/docs/how_to/installation)
    *   [How to stream responses from an LLM](/v0.2/docs/how_to/streaming_llm)
    *   [How to stream chat model responses](/v0.2/docs/how_to/chat_streaming)
    *   [How to embed text data](/v0.2/docs/how_to/embed_text)
    *   [How to use few shot examples in chat models](/v0.2/docs/how_to/few_shot_examples_chat)
    *   [How to cache model responses](/v0.2/docs/how_to/llm_caching)
    *   [How to cache chat model responses](/v0.2/docs/how_to/chat_model_caching)
    *   [How to create a custom LLM class](/v0.2/docs/how_to/custom_llm)
    *   [How to use few shot examples](/v0.2/docs/how_to/few_shot_examples)
    *   [How to use output parsers to parse an LLM response into structured format](/v0.2/docs/how_to/output_parser_structured)
    *   [How to return structured data from a model](/v0.2/docs/how_to/structured_output)
    *   [How to add ad-hoc tool calling capability to LLMs and Chat Models](/v0.2/docs/how_to/tools_prompting)
    *   [How to create a custom chat model class](/v0.2/docs/how_to/custom_chat)
    *   [How to do per-user retrieval](/v0.2/docs/how_to/qa_per_user)
    *   [How to track token usage](/v0.2/docs/how_to/chat_token_usage_tracking)
    *   [How to track token usage](/v0.2/docs/how_to/llm_token_usage_tracking)
    *   [How to pass through arguments from one step to the next](/v0.2/docs/how_to/passthrough)
    *   [How to compose prompts together](/v0.2/docs/how_to/prompts_composition)
    *   [How to use legacy LangChain Agents (AgentExecutor)](/v0.2/docs/how_to/agent_executor)
    *   [How to add values to a chain's state](/v0.2/docs/how_to/assign)
    *   [How to attach runtime arguments to a Runnable](/v0.2/docs/how_to/binding)
    *   [How to cache embedding results](/v0.2/docs/how_to/caching_embeddings)
    *   [How to split by character](/v0.2/docs/how_to/character_text_splitter)
    *   [How to manage memory](/v0.2/docs/how_to/chatbots_memory)
    *   [How to do retrieval](/v0.2/docs/how_to/chatbots_retrieval)
    *   [How to use tools](/v0.2/docs/how_to/chatbots_tools)
    *   [How to split code](/v0.2/docs/how_to/code_splitter)
    *   [How to do retrieval with contextual compression](/v0.2/docs/how_to/contextual_compression)
    *   [How to write a custom retriever class](/v0.2/docs/how_to/custom_retriever)
    *   [How to create custom Tools](/v0.2/docs/how_to/custom_tools)
    *   [How to debug your LLM apps](/v0.2/docs/how_to/debugging)
    *   [How to load CSV data](/v0.2/docs/how_to/document_loader_csv)
    *   [How to write a custom document loader](/v0.2/docs/how_to/document_loader_custom)
    *   [How to load data from a directory](/v0.2/docs/how_to/document_loader_directory)
    *   [How to load PDF files](/v0.2/docs/how_to/document_loader_pdf)
    *   [How to load JSON data](/v0.2/docs/how_to/document_loaders_json)
    *   [How to select examples by length](/v0.2/docs/how_to/example_selectors_length_based)
    *   [How to select examples by similarity](/v0.2/docs/how_to/example_selectors_similarity)
    *   [How to use reference examples](/v0.2/docs/how_to/extraction_examples)
    *   [How to handle long text](/v0.2/docs/how_to/extraction_long_text)
    *   [How to do extraction without using function calling](/v0.2/docs/how_to/extraction_parse)
    *   [Fallbacks](/v0.2/docs/how_to/fallbacks)
    *   [Few Shot Prompt Templates](/v0.2/docs/how_to/few_shot)
    *   [How to run custom functions](/v0.2/docs/how_to/functions)
    *   [How to construct knowledge graphs](/v0.2/docs/how_to/graph_constructing)
    *   [How to map values to a database](/v0.2/docs/how_to/graph_mapping)
    *   [How to improve results with prompting](/v0.2/docs/how_to/graph_prompting)
    *   [How to add a semantic layer over the database](/v0.2/docs/how_to/graph_semantic)
    *   [How to reindex data to keep your vectorstore in-sync with the underlying data source](/v0.2/docs/how_to/indexing)
    *   [How to get log probabilities](/v0.2/docs/how_to/logprobs)
    *   [How to add message history](/v0.2/docs/how_to/message_history)
    *   [How to generate multiple embeddings per document](/v0.2/docs/how_to/multi_vector)
    *   [How to generate multiple queries to retrieve data for](/v0.2/docs/how_to/multiple_queries)
    *   [How to parse JSON output](/v0.2/docs/how_to/output_parser_json)
    *   [How to retry when output parsing errors occur](/v0.2/docs/how_to/output_parser_retry)
    *   [How to parse XML output](/v0.2/docs/how_to/output_parser_xml)
    *   [How to invoke runnables in parallel](/v0.2/docs/how_to/parallel)
    *   [How to retrieve the whole document for a chunk](/v0.2/docs/how_to/parent_document_retriever)
    *   [How to partially format prompt templates](/v0.2/docs/how_to/prompts_partial)
    *   [How to add chat history to a question-answering chain](/v0.2/docs/how_to/qa_chat_history_how_to)
    *   [How to return citations](/v0.2/docs/how_to/qa_citations)
    *   [How to return sources](/v0.2/docs/how_to/qa_sources)
    *   [How to stream from a question-answering chain](/v0.2/docs/how_to/qa_streaming)
    *   [How to construct filters](/v0.2/docs/how_to/query_constructing_filters)
    *   [How to add examples to the prompt](/v0.2/docs/how_to/query_few_shot)
    *   [How to deal with high cardinality categorical variables](/v0.2/docs/how_to/query_high_cardinality)
    *   [How to handle multiple queries](/v0.2/docs/how_to/query_multiple_queries)
    *   [How to handle multiple retrievers](/v0.2/docs/how_to/query_multiple_retrievers)
    *   [How to handle cases where no queries are generated](/v0.2/docs/how_to/query_no_queries)
    *   [How to recursively split text by characters](/v0.2/docs/how_to/recursive_text_splitter)
    *   [How to reduce retrieval latency](/v0.2/docs/how_to/reduce_retrieval_latency)
    *   [How to route execution within a chain](/v0.2/docs/how_to/routing)
    *   [How to chain runnables](/v0.2/docs/how_to/sequence)
    *   [How to split text by tokens](/v0.2/docs/how_to/split_by_token)
    *   [How to deal with large databases](/v0.2/docs/how_to/sql_large_db)
    *   [How to use prompting to improve results](/v0.2/docs/how_to/sql_prompting)
    *   [How to do query validation](/v0.2/docs/how_to/sql_query_checking)
    *   [How to stream](/v0.2/docs/how_to/streaming)
    *   [How to create a time-weighted retriever](/v0.2/docs/how_to/time_weighted_vectorstore)
    *   [How to use a chat model to call tools](/v0.2/docs/how_to/tool_calling)
    *   [How to call tools with multi-modal data](/v0.2/docs/how_to/tool_calls_multi_modal)
    *   [How to use LangChain tools](/v0.2/docs/how_to/tools_builtin)
    *   [How use a vector store to retrieve data](/v0.2/docs/how_to/vectorstore_retriever)
    *   [How to create and query vector stores](/v0.2/docs/how_to/vectorstores)
*   [Conceptual guide](/v0.2/docs/concepts)
*   Ecosystem
    
    *   [🦜🛠️ LangSmith](/v0.2/docs/langsmith/)
        
    *   [🦜🕸️LangGraph.js](/v0.2/docs/langgraph)
*   Versions
    
    *   [Overview](/v0.2/docs/versions/overview)
    *   [v0.2](/v0.2/docs/versions/v0_2)
    *   [Release Policy](/v0.2/docs/versions/release_policy)
    *   [Packages](/v0.2/docs/versions/packages)
*   [Security](/v0.2/docs/security)

*   [](/v0.2/)
*   [How-to guides](/v0.2/docs/how_to/)
*   How to use a chat model to call tools

On this page

How to use a chat model to call tools
=====================================

Prerequisites

This guide assumes familiarity with the following concepts:

*   [Chat models](/v0.2/docs/concepts/#chat-models)
*   [LangChain Tools](/v0.2/docs/concepts/#tools)

info

We use the term tool calling interchangeably with function calling. Although function calling is sometimes meant to refer to invocations of a single function, we treat all models as though they can return multiple tool or function calls in each message.

Tool calling allows a chat model to respond to a given prompt by “calling a tool”. While the name implies that the model is performing some action, this is actually not the case! The model generates the arguments to a tool, and actually running the tool (or not) is up to the user. For example, if you want to [extract output matching some schema](/v0.2/docs/how_to/structured_output/) from unstructured text, you could give the model an “extraction” tool that takes parameters matching the desired schema, then treat the generated output as your final result.

However, tool calling goes beyond [structured output](/v0.2/docs/how_to/structured_output/) since you can pass responses to caled tools back to the model to create longer interactions. For instance, given a search engine tool, an LLM might handle a query by first issuing a call to the search engine with arguments. The system calling the LLM can receive the tool call, execute it, and return the output to the LLM to inform its response. LangChain includes a suite of [built-in tools](/v0.2/docs/integrations/tools/) and supports several methods for defining your own [custom tools](/v0.2/docs/how_to/custom_tools).

Tool calling is not universal, but many popular LLM providers, including [Anthropic](https://www.anthropic.com/), [Cohere](https://cohere.com/), [Google](https://cloud.google.com/vertex-ai), [Mistral](https://mistral.ai/), [OpenAI](https://openai.com/), and others, support variants of a tool calling feature.

LangChain implements standard interfaces for defining tools, passing them to LLMs, and representing tool calls. This guide will show you how to use them.

Passing tools to LLMs[​](#passing-tools-to-llms "Direct link to Passing tools to LLMs")
---------------------------------------------------------------------------------------

Chat models that support tool calling features implement a [`.bindTools()`](https://v02.api.js.langchain.com/classes/langchain_core_language_models_chat_models.BaseChatModel.html#bindTools) method, which receives a list of LangChain [tool objects](https://v02.api.js.langchain.com/classes/langchain_core_tools.StructuredTool.html) and binds them to the chat model in its expected format. Subsequent invocations of the chat model will include tool schemas in its calls to the LLM.

Let’s walk through a few examples:

### Pick your chat model:

*   Anthropic
*   OpenAI
*   MistralAI
*   FireworksAI

#### Install dependencies

tip

See [this section for general instructions on installing integration packages](/docs/get_started/installation#installing-integration-packages).

*   npm
*   yarn
*   pnpm

    npm i @langchain/anthropic @langchain/core

    yarn add @langchain/anthropic @langchain/core

    pnpm add @langchain/anthropic @langchain/core

#### Add environment variables

    ANTHROPIC_API_KEY=your-api-key

#### Instantiate the model

    import { ChatAnthropic } from "@langchain/anthropic";const llm = new ChatAnthropic({  model: "claude-3-sonnet-20240229",  temperature: 0});

#### Install dependencies

tip

See [this section for general instructions on installing integration packages](/docs/get_started/installation#installing-integration-packages).

*   npm
*   yarn
*   pnpm

    npm i @langchain/openai @langchain/core

    yarn add @langchain/openai @langchain/core

    pnpm add @langchain/openai @langchain/core

#### Add environment variables

    OPENAI_API_KEY=your-api-key

#### Instantiate the model

    import { ChatOpenAI } from "@langchain/openai";const llm = new ChatOpenAI({  model: "gpt-3.5-turbo",  temperature: 0});

#### Install dependencies

tip

See [this section for general instructions on installing integration packages](/docs/get_started/installation#installing-integration-packages).

*   npm
*   yarn
*   pnpm

    npm i @langchain/mistralai @langchain/core

    yarn add @langchain/mistralai @langchain/core

    pnpm add @langchain/mistralai @langchain/core

#### Add environment variables

    MISTRAL_API_KEY=your-api-key

#### Instantiate the model

    import { ChatMistralAI } from "@langchain/mistralai";const llm = new ChatMistralAI({  model: "mistral-large-latest",  temperature: 0});

#### Install dependencies

tip

See [this section for general instructions on installing integration packages](/docs/get_started/installation#installing-integration-packages).

*   npm
*   yarn
*   pnpm

    npm i @langchain/community @langchain/core

    yarn add @langchain/community @langchain/core

    pnpm add @langchain/community @langchain/core

#### Add environment variables

    FIREWORKS_API_KEY=your-api-key

#### Instantiate the model

    import { ChatFireworks } from "@langchain/community/chat_models/fireworks";const llm = new ChatFireworks({  model: "accounts/fireworks/models/firefunction-v1",  temperature: 0});

A number of models implement helper methods that will take care of formatting and binding different function-like objects to the model. Let’s take a look at how we might take the following Zod function schema and get different models to invoke it:

    import { z } from "zod";/** * Note that the descriptions here are crucial, as they will be passed along * to the model along with the class name. */const calculatorSchema = z.object({  operation: z    .enum(["add", "subtract", "multiply", "divide"])    .describe("The type of operation to execute."),  number1: z.number().describe("The first number to operate on."),  number2: z.number().describe("The second number to operate on."),});

We can use the `.bindTools()` method to handle the conversion from LangChain tool to our model provider’s specific format and bind it to the model (i.e., passing it in each time the model is invoked). Let’s create a `DynamicStructuredTool` implementing a tool based on the above schema, then bind it to the model:

    import { ChatOpenAI } from "@langchain/openai";import { DynamicStructuredTool } from "@langchain/core/tools";const calculatorTool = new DynamicStructuredTool({  name: "calculator",  description: "Can perform mathematical operations.",  schema: calculatorSchema,  func: async ({ operation, number1, number2 }) => {    // Functions must return strings    if (operation === "add") {      return `${number1 + number2}`;    } else if (operation === "subtract") {      return `${number1 - number2}`;    } else if (operation === "multiply") {      return `${number1 * number2}`;    } else if (operation === "divide") {      return `${number1 / number2}`;    } else {      throw new Error("Invalid operation.");    }  },});const llmWithTools = llm.bindTools([calculatorTool]);

Now, let’s invoke it! We expect the model to use the calculator to answer the question:

    const res = await llmWithTools.invoke("What is 3 * 12");console.log(res.tool_calls);

    [  {    name: "calculator",    args: { operation: "multiply", number1: 3, number2: 12 },    id: "call_Ri9s27J17B224FEHrFGkLdxH"  }]

tip

See a LangSmith trace for the above [here](https://smith.langchain.com/public/14e4b50c-c6cf-4c53-b3ef-da550edb6d66/r).

We can see that the response message contains a `tool_calls` field when the model decides to call the tool. This will be in LangChain’s standardized format.

The `.tool_calls` attribute should contain valid tool calls. Note that on occasion, model providers may output malformed tool calls (e.g., arguments that are not valid JSON). When parsing fails in these cases, the message will contain instances of of [InvalidToolCall](https://v02.api.js.langchain.com/types/langchain_core_messages_tool.InvalidToolCall.html) objects in the `.invalid_tool_calls` attribute. An `InvalidToolCall` can have a name, string arguments, identifier, and error message.

### Streaming[​](#streaming "Direct link to Streaming")

When tools are called in a streaming context, [message chunks](https://v02.api.js.langchain.com/classes/langchain_core_messages.BaseMessageChunk.html) will be populated with [tool call chunk](https://v02.api.js.langchain.com/types/langchain_core_messages_tool.ToolCallChunk.html) objects in a list via the `.tool_call_chunks` attribute. A `ToolCallChunk` includes optional string fields for the tool `name`, `args`, and `id`, and includes an optional integer field `index` that can be used to join chunks together. Fields are optional because portions of a tool call may be streamed across different chunks (e.g., a chunk that includes a substring of the arguments may have null values for the tool name and id).

Because message chunks inherit from their parent message class, an [AIMessageChunk](https://v02.api.js.langchain.com/classes/langchain_core_messages.AIMessageChunk.html) with tool call chunks will also include `.tool_calls` and `.invalid_tool_calls` fields. These fields are parsed best-effort from the message’s tool call chunks.

Note that not all providers currently support streaming for tool calls. If this is the case for your specific provider, the model will yield a single chunk with the entire call when you call `.stream()`.

    const stream = await llmWithTools.stream("What is 308 / 29");for await (const chunk of stream) {  console.log(chunk.tool_call_chunks);}

    [  {    name: "calculator",    args: "",    id: "call_rGqPR1ivppYUeBb0iSAF8HGP",    index: 0  }][ { name: undefined, args: '{"', id: undefined, index: 0 } ][ { name: undefined, args: "operation", id: undefined, index: 0 } ][ { name: undefined, args: '":"', id: undefined, index: 0 } ][ { name: undefined, args: "divide", id: undefined, index: 0 } ][ { name: undefined, args: '","', id: undefined, index: 0 } ][ { name: undefined, args: "number", id: undefined, index: 0 } ][ { name: undefined, args: "1", id: undefined, index: 0 } ][ { name: undefined, args: '":', id: undefined, index: 0 } ][ { name: undefined, args: "308", id: undefined, index: 0 } ][ { name: undefined, args: ',"', id: undefined, index: 0 } ][ { name: undefined, args: "number", id: undefined, index: 0 } ][ { name: undefined, args: "2", id: undefined, index: 0 } ][ { name: undefined, args: '":', id: undefined, index: 0 } ][ { name: undefined, args: "29", id: undefined, index: 0 } ][ { name: undefined, args: "}", id: undefined, index: 0 } ][]

Note that using the `concat` method on message chunks will merge their corresponding tool call chunks. This is the principle by which LangChain’s various [tool output parsers](/v0.2/docs/how_to/output_parser_structured/) support streaming.

For example, below we accumulate tool call chunks:

    const streamWithAccumulation = await llmWithTools.stream(  "What is 32993 - 2339");let final;for await (const chunk of streamWithAccumulation) {  if (!final) {    final = chunk;  } else {    final = final.concat(chunk);  }}console.log(final.tool_calls);

    [  {    name: "calculator",    args: { operation: "subtract", number1: 32993, number2: 2339 },    id: "call_WMhL5X0fMBBZPNeyUZY53Xuw"  }]

Few shotting with tools[​](#few-shotting-with-tools "Direct link to Few shotting with tools")
---------------------------------------------------------------------------------------------

You can give the model examples of how you would like tools to be called in order to guide generation by inputting manufactured tool call turns. For example, given the above calculator tool, we could define a new operator, `🦜`. Let’s see what happens when we use it naively:

    const res = await llmWithTools.invoke("What is 3 🦜 12");console.log(res.content);console.log(res.tool_calls);

    It seems like you've used an emoji (🦜) in your expression, which I'm not familiar with in a mathematical context. Could you clarify what operation you meant by using the parrot emoji? For example, did you mean addition, subtraction, multiplication, or division?[]

It doesn’t quite know how to interpret `🦜` as an operation. Now, let’s try giving it an example in the form of a manufactured messages to steer it towards `divide`:

    import { HumanMessage, AIMessage, ToolMessage } from "@langchain/core/messages";const res = await llmWithTools.invoke([  new HumanMessage("What is 333382 🦜 1932?"),  new AIMessage({    content: "",    tool_calls: [      {        id: "12345",        name: "calulator",        args: {          number1: 333382,          number2: 1932,          operation: "divide",        },      },    ],  }),  new ToolMessage({    tool_call_id: "12345",    content: "The answer is 172.558.",  }),  new AIMessage("The answer is 172.558."),  new HumanMessage("What is 3 🦜 12"),]);console.log(res.tool_calls);

    [  {    name: "calculator",    args: { operation: "divide", number1: 3, number2: 12 },    id: "call_BDuJv8QkDZ7N7Wsd6v5VDeVa"  }]

Binding model-specific formats (advanced)[​](#binding-model-specific-formats-advanced "Direct link to Binding model-specific formats (advanced)")
-------------------------------------------------------------------------------------------------------------------------------------------------

Providers adopt different conventions for formatting tool schemas. For instance, OpenAI uses a format like this:

*   `type`: The type of the tool. At the time of writing, this is always “function”.
*   `function`: An object containing tool parameters.
*   `function.name`: The name of the schema to output.
*   `function.description`: A high level description of the schema to output.
*   `function.parameters`: The nested details of the schema you want to extract, formatted as a [JSON schema](https://json-schema.org/) object.

We can bind this model-specific format directly to the model if needed. Here’s an example:

    import { ChatOpenAI } from "@langchain/openai";const model = new ChatOpenAI({ model: "gpt-4o" });const modelWithTools = model.bind({  tools: [    {      type: "function",      function: {        name: "calculator",        description: "Can perform mathematical operations.",        parameters: {          type: "object",          properties: {            operation: {              type: "string",              description: "The type of operation to execute.",              enum: ["add", "subtract", "multiply", "divide"],            },            number1: { type: "number", description: "First integer" },            number2: { type: "number", description: "Second integer" },          },          required: ["number1", "number2"],        },      },    },  ],});await modelWithTools.invoke(`Whats 119 times 8?`);

    AIMessage {  lc_serializable: true,  lc_kwargs: {    content: "",    tool_calls: [      {        name: "calculator",        args: { operation: "multiply", number1: 119, number2: 8 },        id: "call_pBlKOPNMRN4AAMkPaOKLLcyj"      }    ],    invalid_tool_calls: [],    additional_kwargs: {      function_call: undefined,      tool_calls: [        {          id: "call_pBlKOPNMRN4AAMkPaOKLLcyj",          type: "function",          function: [Object]        }      ]    },    response_metadata: {}  },  lc_namespace: [ "langchain_core", "messages" ],  content: "",  name: undefined,  additional_kwargs: {    function_call: undefined,    tool_calls: [      {        id: "call_pBlKOPNMRN4AAMkPaOKLLcyj",        type: "function",        function: {          name: "calculator",          arguments: '{"operation":"multiply","number1":119,"number2":8}'        }      }    ]  },  response_metadata: {    tokenUsage: { completionTokens: 24, promptTokens: 85, totalTokens: 109 },    finish_reason: "tool_calls"  },  tool_calls: [    {      name: "calculator",      args: { operation: "multiply", number1: 119, number2: 8 },      id: "call_pBlKOPNMRN4AAMkPaOKLLcyj"    }  ],  invalid_tool_calls: []}

This is functionally equivalent to the `bind_tools()` calls above.

Next steps[​](#next-steps "Direct link to Next steps")
------------------------------------------------------

Now you’ve learned how to bind tool schemas to a chat model and to call those tools. Next, check out some more specific uses of tool calling:

*   [Building tool-using chains and agents](/v0.2/docs/how_to/#tools)
*   [Getting structured outputs from models](/v0.2/docs/how_to/structured_output/)

* * *

#### Was this page helpful?

  

#### You can leave detailed feedback [on GitHub](https://github.com/langchain-ai/langchainjs/issues/new?assignees=&labels=03+-+Documentation&projects=&template=documentation.yml&title=DOC%3A+%3CPlease+write+a+comprehensive+title+after+the+%27DOC%3A+%27+prefix%3E).

[

Previous

How to create a time-weighted retriever

](/v0.2/docs/how_to/time_weighted_vectorstore)[

Next

How to call tools with multi-modal data

](/v0.2/docs/how_to/tool_calls_multi_modal)

*   [Passing tools to LLMs](#passing-tools-to-llms)
    *   [Streaming](#streaming)
*   [Few shotting with tools](#few-shotting-with-tools)
*   [Binding model-specific formats (advanced)](#binding-model-specific-formats-advanced)
*   [Next steps](#next-steps)

Community

*   [Discord](https://discord.gg/cU2adEyC7w)
*   [Twitter](https://twitter.com/LangChainAI)

GitHub

*   [Python](https://github.com/langchain-ai/langchain)
*   [JS/TS](https://github.com/langchain-ai/langchainjs)

More

*   [Homepage](https://langchain.com)
*   [Blog](https://blog.langchain.dev)

Copyright © 2024 LangChain, Inc.