How to use Kimi K3 API with Python, Cursor, and OpenAI-compatible tools

How to use Kimi K3 API with Python, Cursor, and OpenAI-compatible tools

Kimi K3 is useful to test when you want a model for coding, long-context reading, agent workflows, or document-heavy work. The easiest way to evaluate it is not to rebuild your whole stack. Start with an OpenAI-compatible endpoint, send one small request, then move the same configuration into Python, Cursor, Hermes, OpenClaw, or your own backend.

This tutorial uses lizh.ai as an independent OpenAI-compatible API gateway.

lizh.ai is not the official Moonshot AI or Kimi API website. It is an independent gateway for calling Kimi K3 and other models through a familiar API shape.

What values do you need?

For most OpenAI-compatible tools, the important values are:

Base URL: https://lizh.ai/v1
Model ID: kimi-k3
API Key: your lizh.ai API key

Create your API key at https://lizh.ai/keys.

Check current model availability and pricing at https://lizh.ai/pricing.

Step 1: Test Kimi K3 with cURL

Before debugging an SDK or an editor integration, send one small cURL request.

export LIZH_API_KEY="your_lizh_api_key"

curl https://lizh.ai/v1/chat/completions \
  -H "Authorization: Bearer ${LIZH_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k3",
    "messages": [
      {
        "role": "user",
        "content": "Write a short test plan for evaluating a long-context coding model."
      }
    ],
    "max_tokens": 500
  }'

If this works, your API key, endpoint, and model name are basically correct.

Step 2: Use Kimi K3 from Python

Install the OpenAI Python SDK:

pip install openai

Then call the lizh.ai OpenAI-compatible endpoint:

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["LIZH_API_KEY"],
    base_url="https://lizh.ai/v1",
)

response = client.chat.completions.create(
    model="kimi-k3",
    messages=[
        {
            "role": "system",
            "content": "You are a concise technical assistant.",
        },
        {
            "role": "user",
            "content": "Explain when Kimi K3 is useful for long-context coding tasks.",
        },
    ],
    max_tokens=500,
)

print(response.choices[0].message.content)

For more code examples, see the public documentation mirror:

Kimi K3 OpenAI-compatible API Guide

Step 3: Configure Cursor

If your coding tool supports custom OpenAI-compatible providers, use these values:

Provider: OpenAI-compatible
Base URL: https://lizh.ai/v1
API Key: your lizh.ai API key
Model: kimi-k3

Start with a small prompt, for example:

Read this file and explain the main logic in 5 bullets.

After the first request works, try a real workflow:

  • summarize a large source file,
  • generate tests for a function,
  • review an error log,
  • compare two implementations,
  • plan a safe refactor.

Step 4: Configure Hermes or OpenClaw

For agent tools that accept YAML-style provider configuration, the important values are usually:

base_url: https://lizh.ai/v1
api_key: ${LIZH_API_KEY}
model: kimi-k3

If the tool asks for a provider type, choose an OpenAI-compatible or custom OpenAI provider rather than an official OpenAI-only preset.

Cost checklist before long-context tests

Long-context coding and document workflows can send large prompts. Before a large test:

  • start with a short prompt,
  • set a small output limit,
  • check current pricing,
  • review logs after the first request,
  • compare input, output, and cache-hit tokens separately.

The pricing page is here:

https://lizh.ai/pricing

Common mistakes

  • Using the wrong Base URL instead of https://lizh.ai/v1.
  • Typing Kimi K3 as a display name instead of the model ID kimi-k3.
  • Testing a huge prompt before confirming a small request works.
  • Hard-coding an API key in source code.
  • Forgetting to check current model price before long-context tasks.

Useful links

Final thought

The best first test is small and reversible: create a key, send one request to https://lizh.ai/v1, use kimi-k3 as the model ID, and then move the same configuration into your preferred tool.

评论