Instructions to use moonshotai/Kimi-K2.5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use moonshotai/Kimi-K2.5 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="moonshotai/Kimi-K2.5", trust_remote_code=True) messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("moonshotai/Kimi-K2.5", trust_remote_code=True, dtype="auto") - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use moonshotai/Kimi-K2.5 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "moonshotai/Kimi-K2.5" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "moonshotai/Kimi-K2.5", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/moonshotai/Kimi-K2.5
- SGLang
How to use moonshotai/Kimi-K2.5 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "moonshotai/Kimi-K2.5" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "moonshotai/Kimi-K2.5", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "moonshotai/Kimi-K2.5" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "moonshotai/Kimi-K2.5", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use moonshotai/Kimi-K2.5 with Docker Model Runner:
docker model run hf.co/moonshotai/Kimi-K2.5
400 Bad Request when deploying Kimi-K2.5 with vllm-0.15.0
Different errors occured when Depoying Kimi-K2.5 with vllm-0.15.0 , while it is no problem when these requests are sended to other models. For example:
Error 1 : ValueError: list index out of range
'''
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 05:21:50 [hf.py:483] An error occurred in transformers while applying chat template
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 05:21:50 [hf.py:483] Traceback (most recent call last):
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 05:21:50 [hf.py:483] File "/usr/local/lib/python3.12/dist-packages/vllm/renderers/hf.py", line 471, in safe_apply_chat_template
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 05:21:50 [hf.py:483] return tokenizer.apply_chat_template(
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 05:21:50 [hf.py:483] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 05:21:50 [hf.py:483] File "/root/.cache/huggingface/modules/transformers_modules/Kimi_hyphen_K2_dot_5/tokenization_kimi.py", line 338, in apply_chat_template
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 05:21:50 [hf.py:483] return super().apply_chat_template(
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 05:21:50 [hf.py:483] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 05:21:50 [hf.py:483] File "/usr/local/lib/python3.12/dist-packages/transformers/tokenization_utils_base.py", line 1650, in apply_chat_template
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 05:21:50 [hf.py:483] isinstance(conversation[0], (list, tuple)) or hasattr(conversation[0], "messages")
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 05:21:50 [hf.py:483] ~~~~~~~~~~~~^^^
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 05:21:50 [hf.py:483] IndexError: list index out of range
'''
Error 2 : [ValueError: list index out of range](json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 87 (char 86))
'''
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] Error in preprocessing prompt inputs
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] Traceback (most recent call last):
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] File "/usr/local/lib/python3.12/dist-packages/vllm/entrypoints/openai/chat_completion/serving.py", line 298, in render_chat_request
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] conversation, engine_prompts = await self._preprocess_chat(
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] File "/usr/local/lib/python3.12/dist-packages/vllm/entrypoints/openai/engine/serving.py", line 1053, in _preprocess_chat
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] conversation, prompt = await renderer.render_messages_async(
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] File "/usr/local/lib/python3.12/dist-packages/vllm/renderers/hf.py", line 693, in render_messages_async
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] conversation, mm_data, mm_uuids = await parse_chat_messages_async(
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] File "/usr/local/lib/python3.12/dist-packages/vllm/entrypoints/chat_utils.py", line 1564, in parse_chat_messages_async
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] _postprocess_messages(conversation)
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] File "/usr/local/lib/python3.12/dist-packages/vllm/entrypoints/chat_utils.py", line 1500, in _postprocess_messages
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] item["function"]["arguments"] = json.loads(content)
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] ^^^^^^^^^^^^^^^^^^^
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] File "/usr/lib/python3.12/json/init.py", line 346, in loads
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] return _default_decoder.decode(s)
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] ^^^^^^^^^^^^^^^^^^^^^^^^^^
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] File "/usr/lib/python3.12/json/decoder.py", line 338, in decode
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] obj, end = self.raw_decode(s, idx=_w(s, 0).end())
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] File "/usr/lib/python3.12/json/decoder.py", line 354, in raw_decode
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] obj, end = self.scan_once(s, idx)
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] ^^^^^^^^^^^^^^^^^^^^^^
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:08 [serving.py:314] json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 87 (char 86)
[0;36m(APIServer pid=1)[0;0m INFO: 172.16.221.200:36198 - "POST /v1/chat/completions HTTP/1.1" 400 Bad Request
[0;36m(APIServer pid=1)[0;0m ERROR 02-02 09:27:11 [serving.py:314] Error in preprocessing prompt inputs
'''
It reproduces on my end as well (vLLM v0.18.0).