Kimi Code API Base URL and OpenAI-Compatible Setup

The Kimi code API base URL is the root address your client prepends to every endpoint path, and for this service it is https://api.kimicodeapi.com/v1. Set that, add your key as a Bearer token and use the model ID uncensored, and any OpenAI-compatible tool will work.
What a base URL actually is
An OpenAI-compatible client does not hard-code a server. It stores a base URL and builds each request by appending a path. For chat, the client calls {base_url}/chat/completions. With our base URL that becomes:
https://api.kimicodeapi.com/v1/chat/completions
This is why the same SDK can talk to different providers: swap the base URL, key and model name and the rest of your code stays as it was. Note that we run one open-weight model through an independent provider. This is not the official Kimi API, so do not use Moonshot's key or hostname here, and do not use our key there.
The three values you need are:
- Base URL:
https://api.kimicodeapi.com/v1 - Key: from the API key page, sent as
Authorization: Bearer YOUR_KEY - Model:
uncensored
Python setup with the OpenAI SDK
from openai import OpenAI
client = OpenAI(
base_url="https://api.kimicodeapi.com/v1",
api_key="YOUR_KEY",
)
resp = client.chat.completions.create(
model="uncensored",
messages=[
{"role": "system", "content": "You are a careful code assistant."},
{"role": "user", "content": "Write a Python function that reverses a linked list."},
],
temperature=0.2,
)
print(resp.choices[0].message.content)
Low temperature is a good default for code, because you want the same answer for the same question. Parameters like temperature, top_p, stop, seed and the penalties are passed through.
To stream the answer as it is generated, add stream=True and iterate over the chunks. Usage is reported at the end of the stream.
Node and curl
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.kimicodeapi.com/v1",
apiKey: process.env.API_KEY,
});
const res = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Explain what a closure is in JavaScript." }],
});
console.log(res.choices[0].message.content);
Plain curl is the quickest way to confirm that the key and URL are right before you touch any editor config:
curl https://api.kimicodeapi.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"uncensored","messages":[{"role":"user","content":"Say ok."}]}'
curl https://api.kimicodeapi.com/v1/models \
-H "Authorization: Bearer $API_KEY"
The second call lists the available model. If it returns JSON and not an error, your base URL and key are good. The service also supports POST /v1/responses for clients that use that format.
Environment variables for tools you did not write
Many CLI tools and libraries built on the OpenAI SDK read the standard environment variables. Setting them once configures every such program in the shell session:
export OPENAI_BASE_URL="https://api.kimicodeapi.com/v1"
export OPENAI_API_KEY="YOUR_KEY"
Older tools use OPENAI_API_BASE for the same purpose, so if one ignores the first name, try the second. Then pick uncensored as the model in the tool's own setting.
Editor assistants and coding agents that accept a custom OpenAI-compatible provider ask for the same three fields, usually labelled "API base" or "endpoint", "API key" and "model". Paste the values from above. Menus differ between tools and versions, so check the tool's own documentation for where the field lives. If a tool only supports the vendor's native protocol and has no custom-endpoint option, it cannot be pointed here without a translation layer.
Keeping keys and URLs out of your code
Hard-coding a base URL and key makes a script work today and leak tomorrow. Read both from the environment and keep one small config module so that moving between environments is a one-line change.
import os
from openai import OpenAI
client = OpenAI(
base_url=os.environ.get("LLM_BASE_URL", "https://api.kimicodeapi.com/v1"),
api_key=os.environ["LLM_API_KEY"],
)
MODEL = os.environ.get("LLM_MODEL", "uncensored")
With this layout a staging job and a personal script can use different keys, and a future switch to another OpenAI-compatible provider is a change to three variables, not a code search. Never commit the key. If one slips into a repository, regenerate it on the key page, which stops the old key at once.
Common base URL mistakes and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| 404 Not Found | Missing /v1, or the path is doubled such as /v1/chat/completions/chat/completions | Use exactly https://api.kimicodeapi.com/v1 as the base |
| 401 Unauthorized | Wrong or reissued key, or a stray space or newline | Copy the key again from the key page |
| Model not found | Another vendor's model name left in the config | Set the model to uncensored |
| Connection error | Trailing slash handling, a proxy, or http instead of https | Use https and test with curl |
429 with rate_limited or concurrency | Over the limit for your key | Slow down or cap parallel requests |
If you reissue your key on the key page, the old one stops working at once, so update every tool that uses it. Accounts that have topped up can hold up to 5 labelled keys, which is a clean way to give each tool its own key and revoke one without breaking the others.
A checklist before you blame the tool
When an editor plugin or agent refuses to connect, work through this list from top to bottom. Each step rules out one cause.
- Run the curl call from above. If it works, the key and URL are fine and the problem is in the tool's settings.
- Check that the base URL has no trailing path beyond
/v1. - Check the model field. Some tools show a dropdown of vendor models; look for an option to type a custom model name and enter
uncensored. - Look for a separate "provider type" setting. Choose the OpenAI-compatible type, not a vendor-specific one.
- Check for a corporate proxy or VPN that rewrites or blocks the host name.
- Look at the tool's own log or developer console for the exact URL it called. Compare it with the curl URL character by character.
The log step solves most cases in under a minute, because the tool prints the real URL and status code and the mistake is usually visible in them.
Using the base URL with other client libraries
The pattern is identical in other languages. Any HTTP client or OpenAI-style SDK needs the same three values, and the only variation is the name of the option. In plain Python with requests, for instance, you build the full URL yourself, which is a good way to see exactly what an SDK does for you:
import requests
BASE_URL = "https://api.kimicodeapi.com/v1"
resp = requests.post(
BASE_URL + "/chat/completions",
headers={"Authorization": "Bearer YOUR_KEY"},
json={
"model": "uncensored",
"messages": [{"role": "user", "content": "Write a regex that matches an ISO date."}],
},
timeout=120,
)
resp.raise_for_status()
print(resp.json()["choices"][0]["message"]["content"])
Here you add /chat/completions to the base yourself. In an SDK you must not, because it does that for you. This one difference accounts for most doubled-path 404 errors. Set a generous timeout, since long completions can take a while, and consider streaming for interactive tools so output appears as it is generated.
Limits, cost and where to go next
A full key allows 8 concurrent requests and 300 per minute. The trial key allows 2 and 60. The context window is 100,000 tokens, which is enough for a sizeable chunk of a codebase, though not all of a large one.
Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens. A coding request with 8,000 tokens of code in and 1,000 tokens of answer out costs $0.0012 for input plus $0.0005 for output, or $0.0017 in total. See the cost breakdown and the pricing page for more, and the docs for streaming, tool calling and JSON mode.
New users can claim $0.50 of trial credit with one click on the key page, which is enough to test the whole setup.
More guides
Frequently Asked Questions on Pricing
What is the kimicode API pricing? It is $0.15 per million input tokens and $0.50 per million output tokens. Errors are free. Refusals are free. No. You can sign up with Google or email. Top-ups are crypto only. You can use USDT or USDC. The process is simple and secure.
Does credit expire? No. Your prepaid credit never expires. You can use it whenever you need. This is useful for long-term projects. You can pause usage without losing funds. The bonus credit also never expires. This is a key advantage over subscriptions.
How do I get trial credit? Sign up for a new account. You get $0.50 valid for 7 days. This lets you test the API fully. You can run requests and see the cost. It is a great way to evaluate the service before buying.
Comparison with Character.ai and OpenRouter
Character.ai is a chat app, not an API. It has limits and does not allow commercial use easily. OpenRouter routes to many models but charges more. Kimicode offers a dedicated uncensored model at lower costs. You pay per token, not per route.
OpenRouter may charge extra for model switching. Kimicode runs one optimized model. This reduces complexity. You get consistent performance. The cost is lower than most OpenRouter models. Character.ai is for casual users. Kimicode is for developers. You get full control over parameters. You can stream responses. You can use tools. This is a professional API for serious projects.
Common queries
What is the base URL for this API?
https://api.kimicodeapi.com/v1. Clients append the endpoint path, so do not add /chat/completions yourself.
Which model name should I use?
uncensored. It is the only model ID, and it is the one returned by GET /v1/models.
Can I use my Moonshot or OpenAI key?
No. Each provider issues its own keys. Use a key from this site's API key page with this base URL.
Does a tool need to support OpenAI-compatible APIs?
Yes. If it lets you set a custom base URL, key and model, it will work. If it only speaks a vendor-specific protocol, it needs a translation layer.
Get your API key in minutes
Register, retrieve your key, and update your base URL. That is the complete configuration.
https://api.kimicodeapi.com/v1