weckrDocs · Kimi

Integration guide

Using Weckr with Kimi

Kimi from Moonshot AI runs on an OpenAI compatible API. That means you already know how to wrap it. Point the OpenAI client at Moonshot, hand it to wk.chat(), and Weckr tracks the same per user cost and margin it tracks for OpenAI, Anthropic, and Gemini.

How detection works. A Kimi client is the OpenAI client with its baseURL set to Moonshot, so it looks identical to OpenAI. Weckr tells them apart by the base URL. If it points at moonshot.ai or moonshot.cn, the call is logged as Kimi and priced from the Kimi table.

The pattern

You do not need a Kimi specific client. Moonshot ships an OpenAI compatible endpoint, so you use the OpenAI SDK you already have and change two things: the baseURL and the API key. Everything else, including the usage and cache fields on the response, matches OpenAI exactly.

  • Create an OpenAI client with baseURL: 'https://api.moonshot.ai/v1' and your Moonshot key.
  • Wrap the call with wk.chat(client, params), exactly like OpenAI.
  • Pass a Kimi model such as kimi-k2.6 or kimi-k3 as the model.

Install

bash
npm install @weckr/sdk openai      # TypeScript
pip install weckr-sdk openai       # Python

Get a wk_ API key from app.useweckr.com/auth/signup and a Moonshot key from platform.moonshot.ai.

Working example

TypeScript. Two lines of Weckr, one OpenAI client pointed at Moonshot.

ts
import { Weckr } from '@weckr/sdk';
import OpenAI from 'openai';

// Point the OpenAI client at Moonshot. Weckr detects Kimi from the base URL.
const kimi = new OpenAI({
  apiKey: process.env.MOONSHOT_API_KEY,
  baseURL: 'https://api.moonshot.ai/v1',
});

const wk = new Weckr({
  apiKey: 'wk_...',                 // from app.useweckr.com
  plans: { free: 0, pro: 29 },      // your plan prices in USD
});

const res = await wk.chat(kimi, {
  model: 'kimi-k2.6',
  messages: [{ role: 'user', content: 'Summarize this in one line.' }],
  userId: 'u_42',
  feature: 'doc-summary',
  plan: 'pro',
});

Python. Same idea, same call shape.

python
import os
import openai
from weckr import Weckr

# Point the OpenAI client at Moonshot. Weckr detects Kimi from the base URL.
kimi = openai.OpenAI(
    api_key=os.environ["MOONSHOT_API_KEY"],
    base_url="https://api.moonshot.ai/v1",
)

wk = Weckr(api_key="wk_...", plans={"free": 0, "pro": 29})

res = wk.chat(kimi, {
    "model": "kimi-k2.6",
    "messages": [{"role": "user", "content": "Summarize this in one line."}],
    "user_id": "u_42",
    "feature": "doc-summary",
    "plan": "pro",
})

What you get

  • Per user cost and margin on the dashboard, attributed to u_42 on the pro plan.
  • Spending caps enforced before the call. If u_42 is over budget, wk.chat() blocks or downgrades to a cheaper Kimi model before any tokens are spent.
  • Cost recomputed on the server from the Kimi pricing table, so a leaked key cannot fake a cheaper number.

Models and pricing

Weckr prices these Kimi models today. Dated or suffixed variants resolve to the closest match by prefix, so kimi-k2.6 and a future kimi-k2.6-0930 both price correctly.

  • kimi-k3, the flagship, at roughly 3.00 in and 15.00 out per million tokens.
  • kimi-k2.6 at roughly 0.95 in and 4.00 out per million.
  • kimi-k2.5 and kimi-k2 at roughly 0.60 in and 3.00 out per million.

Moonshot changes rates often, so treat these as a starting point and confirm the live numbers at platform.moonshot.ai. For the full cost comparison against Claude and GPT, read Kimi vs Claude vs GPT cost, or browse all integrations at /docs/integrations.