API Gateway

Use this site's API with OpenAI clients, Claude Code, OpenCode, and OpenClaw.

Overview

This site exposes a user-facing API on top of the same accounts, API keys, and credits used by the web app.

You do not need a separate Moonshot key for day-to-day usage here. The normal flow is:

  1. Sign in on the site
  2. Create a user API key in Settings -> API Keys
  3. Point your client at this site's API routes

There are two route families:

  • OpenAI-compatible: /api/openai/v1
  • Anthropic-compatible: /api/anthropic/v1

Base URLs

OpenAI-compatible:

https://kimi-k25.com/api/openai/v1

Anthropic-compatible:

https://kimi-k25.com/api/anthropic/v1

Authentication

Use the API key you created inside the site.

OpenAI-compatible requests:

Authorization: Bearer sk-...

Anthropic-compatible requests can also use:

anthropic-auth-token: sk-...

or:

x-api-key: sk-...

OpenAI-compatible usage

curl

curl https://kimi-k25.com/api/openai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_SITE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k2.5",
    "messages": [
      {"role": "user", "content": "Reply with exactly OK."}
    ]
  }'

Python

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_SITE_API_KEY",
    base_url="https://kimi-k25.com/api/openai/v1",
)

resp = client.chat.completions.create(
    model="kimi-k2.5",
    messages=[{"role": "user", "content": "Write a one-line summary."}],
)

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

JavaScript / TypeScript

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.SITE_API_KEY,
  baseURL: 'https://kimi-k25.com/api/openai/v1',
});

const response = await client.responses.create({
  model: 'kimi-k2.5',
  input: 'Summarize this repo in one sentence.',
});

console.log(response.output_text);

Claude Code

Claude Code cares about the Anthropic Messages API, so point it at this site's Anthropic-compatible route.

Environment variables

export ANTHROPIC_BASE_URL="https://kimi-k25.com/api/anthropic"
export ANTHROPIC_AUTH_TOKEN="YOUR_SITE_API_KEY"
export ANTHROPIC_MODEL="kimi-k2.5"
export ANTHROPIC_SMALL_FAST_MODEL="kimi-k2.5"

claude

~/.claude/settings.json

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://kimi-k25.com/api/anthropic",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_SITE_API_KEY",
    "ANTHROPIC_MODEL": "kimi-k2.5",
    "ANTHROPIC_SMALL_FAST_MODEL": "kimi-k2.5"
  }
}

OpenCode

OpenCode can use the OpenAI-compatible route.

{
  "ai_provider": {
    "name": "lumen-ai",
    "model": "kimi-k2.5",
    "api_key": "${SITE_API_KEY}",
    "base_url": "https://kimi-k25.com/api/openai/v1"
  }
}

If your OpenCode setup uses extension-style settings instead, the key point stays the same:

  • base_url -> this site's /api/openai/v1
  • api_key -> your site API key
  • model -> kimi-k2.5

OpenClaw

OpenClaw can use the same OpenAI-compatible route as long as your deployment supports a custom OpenAI-compatible provider.

Use these values:

  • Base URL: https://kimi-k25.com/api/openai/v1
  • API key: your site API key
  • Model: kimi-k2.5

If you are starting from a Moonshot-specific OpenClaw guide, replace the Moonshot base URL and Moonshot key with:

  • this site's OpenAI-compatible base URL
  • your site API key

Billing

API usage is tied to the same user credits ledger shown in the web app.

Current billing behavior:

  • Base request cost follows chat_credits_per_message
  • Reasoning requests add chat_credits_reasoning_surcharge
  • GET /api/openai/v1/models is free
  • POST /api/anthropic/v1/messages/count_tokens is free

Route Summary

  • GET /api/openai/v1/models
  • POST /api/openai/v1/chat/completions
  • POST /api/openai/v1/responses
  • POST /api/anthropic/v1/messages
  • POST /api/anthropic/v1/messages/count_tokens