How to Use the Free Kimi K3 Model
1. Create an account:
You do not have permission to view the full content of this post. Log in or register now.
2. Go to Models and select:
moonshotai/kimi-k3-free
3. Open API Keys and create your API key.
4. Install the OpenAI package:
Bash:
pip install openai
5. Run this Python code:
Python:
from openai import OpenAI
client = OpenAI(
base_url="https://api.tokenrouter.com/v1",
api_key="YOUR_API_KEY",
)
messages = [
{
"role": "system",
"content": "You are an intelligent assistant, please reply concisely.",
},
{
"role": "user",
"content": "Hello, what kind of model are you?",
},
]
stream = client.chat.completions.create(
model="moonshotai/kimi-k3-free",
messages=messages,
stream=True,
stream_options={"include_usage": True},
extra_body={}
)
content_parts = []
for chunk in stream:
if chunk.choices:
delta = chunk.choices[0].delta
if delta and delta.content:
content_parts.append(delta.content)
print("".join(content_parts))
Replace YOUR_API_KEY with your TokenRouter API key, then run the file.