Text Generation
MLX
Safetensors
English
llama
llm
tool-calling
lightweight
agentic-tasks
react
conversational
Instructions to use applexml/kimi-k2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use applexml/kimi-k2 with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("applexml/kimi-k2") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- MLX LM
How to use applexml/kimi-k2 with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "applexml/kimi-k2"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "applexml/kimi-k2" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "applexml/kimi-k2", "messages": [ {"role": "user", "content": "Hello"} ] }' - Atomic Chat
| # tool_declaration_ts.py - Stub for Kimi tool/function-calling support | |
| # Loaded by EXO via importlib before tokenization_kimi.py is exec()'d. | |
| # Must exist to prevent ImportError in tokenization_kimi.py relative-import path. | |
| """ | |
| Minimal tool-declaration stub for the Kimi tokenizer PoC. | |
| The real Kimi model uses this module for tool/function-call schema support. | |
| """ | |
| # Stub constants expected by some tokenization_kimi variants | |
| TOOL_CALL_START = "<|tool_call_begin|>" | |
| TOOL_CALL_END = "<|tool_call_end|>" | |
| TOOL_CALL_ARG_BEGIN = "<|tool_call_argument_begin|>" | |
| def build_tool_declaration(name: str, description: str = "", params: dict = None) -> dict: | |
| """Stub — returns a minimal tool declaration dict.""" | |
| return { | |
| "name": name, | |
| "description": description, | |
| "parameters": params or {}, | |
| } | |
| print("[PoC] tool_declaration_ts.py stub loaded") | |