👨‍🏫 Tutorial FREE Kimi K3 Model


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.
 

About this Thread

  • 5
    Replies
  • 110
    Views
  • 6
    Participants
Last reply from:
janz13

Trending Topics

Online now

Members online
1,012
Guests online
3,130
Total visitors
4,142

Forum statistics

Threads
2,325,323
Posts
29,221,034
Members
1,169,216
Latest member
batak kumain ng kiffy
Back
Top