Docs / OpenAI-compatible API
Keep your SDK. Change two lines.
Requests follow the OpenAI chat completions format, so the official OpenAI libraries and most agent frameworks work unchanged.
Python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_DISCOUNT_TOKENS_KEY",
base_url="https://api.discounttokens.example/v1", # placeholder
)
reply = client.chat.completions.create(
model="kimi-k3",
messages=[{"role": "user", "content": "Summarize this repo."}],
)
print(reply.choices[0].message.content)
JavaScript
import OpenAI from "openai";
const client = new OpenAI({ apiKey: process.env.DT_KEY, baseURL: "https://api.discounttokens.example/v1" });
const r = await client.chat.completions.create({ model: "deepseek-v4-pro", messages: [{ role: "user", content: "Hi" }] });
Model ids
Use the ids in the model catalog. Chinese and American models share the same request format.
What differs
- Some provider-specific parameters may be ignored.
- Token counts vary by model tokenizer, so the same text can bill differently on two models.
- Reasoning models may spend extra output tokens thinking.