Overview
Tools enable models to interact with the external world — querying databases, calling APIs, performing calculations — breaking through the limitations of training data.
Tools are the bridge between models and the external world in deepseek-kit. Models can only generate text based on training data, but through tools, they can query real-time weather, search databases, execute code — anything you can implement in JavaScript can be encapsulated as a tool for the model to use. When the model determines that a tool call is needed, it generates a tool call request; your code executes the tool and returns the result, and the model continues reasoning based on the result.
Defining Tools
Use the tool() function to define a tool. Each tool consists of four core parts: name, description, parameter schema, and execute function:
name— Unique identifier for the tool. The model uses the name to choose which tool to calldescription— Functional description of the tool, helping the model understand when it should call this toolschema— Parameter schema defined with Zod, used both to describe the parameter structure to the model and to validate the parameters generated by the modelexecute— Async execution function that receives schema-validated parameters and returns the tool execution result
Using Tools in Agents
Pass tools to createAgent, and the agent will autonomously decide when to call tools based on user input:
You can also use tools directly with generateText:

