Kimi Open Platform has specially launched official tools, you can freely integrate these official tools into your own applications to create your intelligent business products! (Currently, Kimi open platform official tools are temporarily free to use. When the tool load reaches capacity limits, temporary rate limiting measures may be applied) This section will guide you through how to easily call and execute these official tools in your applications.Documentation Index
Fetch the complete documentation index at: https://platform.kimi.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
Official Tools List
| Tool Name | Tool Description |
|---|---|
convert | Unit conversion tool, supporting length, mass, volume, temperature, area, time, energy, pressure, speed, and currency conversions |
web-search | Real-time information and internet search tool. For pricing and availability details, see Web Search Price |
rethink | Intelligent reasoning tool |
random-choice | Random selection tool |
mew | Random cat meowing and blessing tool |
memory | Memory storage and retrieval system tool, supporting persistent storage of conversation history and user preferences |
excel | Excel and CSV file analysis tool |
date | Date and time processing tool |
base64 | Base64 encoding and decoding tool |
fetch | URL content extraction Markdown formatting tool |
quickjs | Quick JS engine security execution JavaScript code tool |
code_runner | Python code execution tool |
An Example of Using Official Tools
Here is a Python example, using the web_search official tool as an example, showing how to call official tools through Kimi API: You can also interactively experience the capabilities of Kimi models and tools through Kimi Development Workbench, go to Development Workbench Here are the Kimi official tools you can use, you can experience them by adding the formula URI to the demo example below:moonshot/convert:latest, moonshot/web-search:latest, moonshot/rethink:latest, moonshot/random-choice:latest, moonshot/mew:latest, moonshot/memory:latest, moonshot/excel:latest, moonshot/date:latest, moonshot/base64:latest, moonshot/fetch:latest, moonshot/quickjs:latest, moonshot/code_runner:latest
Official Tools Concept and Usage
Formula Concept
Before understanding the official tools of Kimi, you need to learn a concept ‘Formula’. Formula is a lightweight script engine collection. It can transform Python scripts into “instant computing power that can be triggered by AI with one click”, allowing developers to focus only on code writing while the platform handles everything else like startup, scheduling, isolation, billing, recycling, etc. Formula is called through semantic URIs (like moonshot/web-search:latest). Each formula contains declarations (telling AI what it can do) and implementations (Python code). The platform automatically handles all underlying details (startup, isolation, recycling, etc.), making tools easy to share and reuse in the community. You can experience and debug these tools in Kimi Playground, or call them through API in applications.How to Call Official Tools
For formula URIs, they generally consist of 3 parts, for examplemoonshot/web-search:latest. The web-search part is its name, currently we only support moonshot for namespace, and latest will be the default tag.
A typical usage is if we need to call web search, we can send an HTTP request like this:
context.encrypted_output field. The format is similar to ----MOONSHOT ENCRYPTED BEGIN----... ----MOONSHOT ENCRYPTED END----, which can be directly used in the tool.
Interaction with Chat Completions
As shown in Is 3214567 a prime number? An example of Tool Calls, there are several key points we need to align between the Formula API and the model.How to set the tools field?
Now given a formula uri like moonshot/web-search:latest, we can directly append it to the url
tools field (always an array of dicts) and append it to your request’s tools list. We always ensure this list is API-compatible.
However, you may need to note that if type=function, you need to ensure that function.name is unique within an API request, otherwise the chat completion request will be considered invalid and immediately returned with a 401 error.
Additionally, if you are using multiple formulas, you need to maintain a mapping of function.name -> formula_uri for future reference.
Handling Model Request Return
If the chat completion’sfinish_reason=tool_calls, it means the model has triggered a tool call. The content might look like this:
web_search by checking choices[0].message.tool_calls[0].function.name, and then find that the formula_uri corresponding to web_search is moonshot/web-search:latest.
We can copy the choices[0].message.tool_calls[0].function as the body and send a request to ${MOONSHOT_BASE_URL}/formulas/${FORMULA_URI}/fibers. Specifically, because the function.arguments output by the model is a valid JSON, but in format it is still an encoded string. You don’t need to escape it, just use it as the body of the call.
Handling Fiber Request Return
A Fiber is a “process snapshot” that contains logs, Tracing, and resource usage, making it convenient for debugging and auditing. The result of POST is usuallystatus, which may be succeeded or various types of errors. When succeeded, the result may look like this:
encrypted_output, and in most cases we may return output. This output is your next round of input.
Generally, when continuing the request, the messages are arranged as follows:
- The model may return more than one tool_calls, so you must return all tool_calls for the model to continue, otherwise the request will be considered invalid and rejected.
- If the assistant has tool_calls, the next messages must be exactly the same role=tool messages as the tool_calls, and the tool_call_id must be aligned with the previous tool_calls.id.
- If there are multiple tool_calls, the order is not sensitive
- The ids of the tool_calls output by our model must be unique, and the ids in the role=tool messages must also be aligned.
- The uniqueness requirement is only local to the tool_calls - response in this round, not for the entire conversation or globally.