kimik2api.comKimi K2 API Claude Code: Does It Work?
Kimi K2 API Claude Code: Does It Work?
If you want a kimi k2 api claude code setup, the first thing to know is that the two do not connect directly: Claude Code speaks Anthropic's Messages format and this endpoint speaks OpenAI chat completions. A translation layer in between fixes that, and clients built for OpenAI-style APIs skip the problem altogether.
Updated

Key points
- This API offers POST /v1/chat/completions and GET /v1/models, not the Anthropic Messages endpoint.
- To use Claude Code you need a local proxy that translates between the two formats.
- Clients that already speak OpenAI chat format, such as Aider, connect with only a base URL and key.
- The model is uncensored, not Claude and not Kimi K2, so agent behavior will differ.
Why it does not plug in directly
Claude Code is Anthropic's terminal coding agent. It can be pointed at another host through environment variables such as ANTHROPIC_BASE_URL, but it still sends requests in the Anthropic Messages format and expects replies in that format. The endpoint here, https://api.kimik2api.com/v1, accepts the OpenAI chat completions format. Same idea, different JSON: message structure, tool definitions and streaming events are all shaped differently.
That is why setting the base URL alone produces errors. The request lands on a path the API does not offer, and even if it did, the response would not parse. This is a limit of the format, not a bug on either side.
You have three realistic routes:
- Run a small proxy that accepts Anthropic-style calls and forwards them as OpenAI-style calls.
- Use an agent or editor client that already speaks the OpenAI format.
- Write a short script of your own against the API, which is often all a task needs.
It also helps to be honest about the model. The API serves one open-weight model, ID uncensored, from an independent provider. It is neither Claude nor the official Kimi K2. Claude Code's prompts and tool habits were written with Claude models in mind, so a different model may follow them less reliably. Treat the result as an experiment and measure it.
Route 1: a translation proxy
A proxy such as LiteLLM can sit on your machine, present an Anthropic-style interface to Claude Code, and call an OpenAI-compatible upstream. Proxy features and config keys change over time, so read the proxy's own documentation for the Anthropic-compatible route before you rely on this. The shape of the config is usually like this:
pip install "litellm[proxy]"
cat > config.yaml <<'YAML'
model_list:
- model_name: uncensored
litellm_params:
model: openai/uncensored
api_base: https://api.kimik2api.com/v1
api_key: os.environ/MIRROR_API_KEY
YAML
export MIRROR_API_KEY=YOUR_KEY
litellm --config config.yaml --port 4000
Then tell Claude Code where to go. These variables are the documented way to redirect it:
export ANTHROPIC_BASE_URL=http://localhost:4000
export ANTHROPIC_AUTH_TOKEN=any-local-token
export ANTHROPIC_MODEL=uncensored
claude
Names for the model variables vary by Claude Code version, and some versions use separate settings for a smaller background model. If a request fails, look at the proxy's log first: it will show which model name Claude Code asked for. Map that name to uncensored in the config, or set the matching variable.
What to expect from a proxy setup
Agents send long system prompts, tool definitions and a growing history. All of that counts as input tokens, which cost $0.15 per 1M. The context window is 100,000 tokens, prompt and completion together, so a very long session will eventually need a fresh start. The proxy adds one more thing that can fail, so test the upstream key with curl before blaming the agent.
Route 2: use a client that speaks OpenAI format
Many coding tools take an OpenAI-compatible base URL natively, and this skips the proxy. Aider is one example: it reads the standard OpenAI environment variables and accepts a model name with an openai/ prefix.
export OPENAI_API_BASE=https://api.kimik2api.com/v1
export OPENAI_API_KEY=YOUR_KEY
aider --model openai/uncensored
Editors with a bring-your-own-endpoint option work the same way, as long as they let you set a base URL and type a custom model name. Whichever tool you pick, the three values stay the same: base URL, key, and the model ID uncensored. The docs page shows the request format if a tool asks for details.
Which route is better? If your whole goal is "use Claude Code's interface with a different model", take route 1 and accept the extra moving part. If your goal is "get an agent that edits files with this model", route 2 has fewer failure points.
Route 3: a minimal tool-calling loop
The API supports tool calling: you pass tools and tool_choice, the model replies with tool_calls, and you send results back as role: "tool" messages. That is the core of every coding agent, and it fits in a short script. This also doubles as a test of how well the model handles tools before you wire it into something bigger.
import json
from openai import OpenAI
client = OpenAI(base_url="https://api.kimik2api.com/v1", api_key="YOUR_KEY")
tools = [{
"type": "function",
"function": {
"name": "read_file",
"description": "Read a UTF-8 text file and return its contents",
"parameters": {
"type": "object",
"properties": {"path": {"type": "string"}},
"required": ["path"],
},
},
}]
messages = [{"role": "user", "content": "Read notes.txt and summarise it in two sentences."}]
for _ in range(5):
r = client.chat.completions.create(
model="uncensored", messages=messages, tools=tools, tool_choice="auto"
)
msg = r.choices[0].message
messages.append(msg)
if not msg.tool_calls:
print(msg.content)
break
for call in msg.tool_calls:
args = json.loads(call.function.arguments)
with open(args["path"], encoding="utf-8") as f:
result = f.read()
messages.append({"role": "tool", "tool_call_id": call.id, "content": result})
Create a notes.txt next to the script and run it. If the model asks for the file and then summarises it, tool calling works for your purposes. If it answers without calling the tool, or sends malformed arguments, you have learned something important about how far an agent can go on this model. Add more tools (write a file, list a folder, run a test command) one at a time and keep the loop capped, as the range(5) does here.
Streamed tool calls are supported as well, with stream: true. One thing to keep in mind is that a streamed request holds its concurrency slot until the stream ends, and a full key allows 8 concurrent requests.
Costs and limits for agent work
Agents make many calls, so check the arithmetic before a long run. Say an agent session makes 60 calls with an average of 25,000 input tokens and 600 output tokens each.
- Input: 60 x 25,000 = 1,500,000 tokens, which is 1.5 x $0.15 = $0.225
- Output: 60 x 600 = 36,000 tokens, which is 0.036 x $0.50 = $0.018
- Session total: $0.243
Billing is prepaid with no subscription, and credit never expires. Top-ups range from $20 to $500, with +5% from $50, +10% from $100 and +15% from $200; crypto is accepted. The current rates live on the pricing page. A trial key, claimable with one click after sign-up for $0.50 and 7 days, allows 2 concurrent requests and 60 per minute, which an agent can exhaust quickly. A full key allows 8 and 300.
When you see a 429, read the error code. rate_limited means too many requests per minute, concurrency means too many at once, and a response with Retry-After: 5 means a brief overload. Wait and retry. Failed or refused requests are not charged.
Debugging a proxy setup step by step
When nothing works, narrow the problem from the bottom up. Each step proves one link in the chain, so you never debug two things at once.
- Upstream alone. Run the curl call from the docs against the API with your key. If this fails, the proxy is not the problem.
- Proxy to upstream. Send an OpenAI-style request to the proxy's own OpenAI route on port 4000 and confirm you get the same answer. This checks the key, the base URL and the model mapping.
- Agent to proxy. Only now start Claude Code, and watch the proxy log while you type a one-word prompt.
Common failures at step three are a model name the proxy does not know, a missing token variable, and a request that uses a feature the translation does not cover. Keep the first test tiny: a prompt such as "say ok" proves the path without spending tokens on a big context. Each response from the API carries an X-Request-Id header; if you contact support, include it.
Also expect behavioral differences even when the plumbing is right. A model that did not see Claude's tool-use training may call tools less often, produce longer explanations before acting, or stop early. Lower temperature (for example 0.2) tends to make tool arguments more regular, and a short system instruction such as "call a tool whenever you need file contents" often helps. Treat these as things to try, not promises.
Is it the right tool for the job
Be selective. If you need the strongest coding agent available and nothing you do triggers refusals, a model made for that purpose may serve you better, and you should check that provider's current pricing and terms. This endpoint makes sense when your work involves lawful but sensitive material that other assistants decline: security tooling for your own systems, red-team text for test harnesses, adult fiction or companion app backends, or content moderation datasets. The hard limit is no sexual content involving minors.
Prompts are not used for training. For an account, go to the API key page.
More guides
Questions and answers
Can I set ANTHROPIC_BASE_URL to this API directly?
No. Claude Code sends Anthropic Messages requests, and this API accepts OpenAI chat completions. You need a translation proxy in between.
What model name do I use?
Use uncensored. It is the only model on the endpoint.
Does the API support tool calling?
Yes. Pass tools and tool_choice, and return results as role tool messages. Streamed tool calls work too.
Is the model Claude or Kimi K2?
Neither. It is one open-weight model from an independent provider, tuned to answer without content refusals for lawful adult use.
Which clients work without a proxy?
Any client that lets you set an OpenAI-compatible base URL and a custom model name, such as Aider with an openai/ model prefix.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.