system message under tools. They become available from that position forward and calls come back in the standard OpenAI tool_calls response field.
Dynamic loading is available on Kimi K3 (
morph-kimik3 and morph-kimik3-fast) through /v1/chat/completions. Other models still require tool definitions in the request’s top-level tools array.Quick Start
This request declaresCalculator after the user turn, then requires K3 to call an available tool:
tool message.
Load tools on demand
Keep a small discovery tool in the top-leveltools array. When K3 calls it, search your registry and append the matching definitions as a dynamic declaration.
messages[].tools is a K3 extension to the OpenAI message schema. The Python SDK sends the extra dictionary field at runtime, but static type checkers and generated TypeScript types may not recognize it. Widen that message type locally or send the JSON request directly.
Message rules
A dynamic declaration must:- use
role: "system"; - contain a non-empty
toolsarray of standard OpenAI function definitions; and - omit the
contentkey entirely.
content: null. A declaration containing both content and tools returns HTTP 400.
Static and dynamic tools can coexist. Keep universal tools such as search_tools in the top-level tools array, then append task-specific definitions in system messages. Each dynamic declaration extends the tools already available at that point in the conversation.
Choosing static or dynamic tools
Use top-level tools when the set is small and stable. Use dynamic loading when the full registry is large, tenant-specific, permission-dependent, or expensive to place in every request. Dynamic loading changes how schemas reach the model. It does not change execution security. Validate arguments, authorize the action for the current user, require approval for sensitive operations, and make side-effecting tools idempotent before executing a returned call.See Also
- Open Source Models — model IDs and standard tool calling
- Prompt Caching — cached-input behavior and usage fields
- Agent Runs — keep a multi-turn K3 run on the worker holding its cache
- Moonshot’s dynamic tool loading guide — the upstream K3 request format