Moonshot API Base URL: Point Your SDK at Our Endpoint
Any OpenAI-style client needs three settings to talk to this API: a base URL, a key and a model name. Here are the exact values and where each one goes.
Updated

Key points
- The base URL is https://api.moonshotapi.cc/v1, including the /v1 part.
- The model ID is uncensored, and the key goes in an Authorization: Bearer header.
- Python, Node, curl and most chat front ends need only these three values changed.
- Most connection errors come from a missing /v1, a doubled path or a wrong model name.
The base URL and the two other values
The moonshot api base url you are after, for this service, is:
https://api.moonshotapi.cc/v1
Be clear about what this is. It is not the address of Moonshot's own API, and this service is not run by Moonshot. It is a separate, hosted, OpenAI-compatible endpoint for one open-weight model, run by an independent provider and tuned to answer without content refusals for lawful adult use. If you want Moonshot's official endpoint, take the URL from their documentation, since it is theirs to change.
Three values are all you need:
- Base URL:
https://api.moonshotapi.cc/v1 - API key: created on the API key page after you sign up with Google or with email and password.
- Model:
uncensored
Two endpoints are available: POST /v1/chat/completions and GET /v1/models. Auth is a standard Authorization: Bearer YOUR_KEY header, which every OpenAI SDK sets for you.
Python and Node.js
Python with the openai SDK
The official openai package takes a base_url argument. Install it with pip install openai and run:
from openai import OpenAI
client = OpenAI(
base_url="https://api.moonshotapi.cc/v1",
api_key="YOUR_KEY",
)
resp = client.chat.completions.create(
model="uncensored",
messages=[
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Give me three names for a fantasy tavern."},
],
temperature=0.8,
)
print(resp.choices[0].message.content)
Nothing else in your existing code has to change. Messages, temperature, top_p, stop, seed and the penalties are passed through to the model.
If you would rather not touch the code at all, set environment variables. The SDK reads OPENAI_BASE_URL and OPENAI_API_KEY when you create the client with no arguments:
export OPENAI_BASE_URL="https://api.moonshotapi.cc/v1"
export OPENAI_API_KEY="YOUR_KEY"
python app.py
This is the cleanest way to switch a project between providers: the code stays the same and only the environment differs.
Node.js
The Node package uses baseURL, with a capital URL, where Python uses base_url. Mixing the two up is a common reason a request silently goes to the wrong host.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.moonshotapi.cc/v1",
apiKey: process.env.API_KEY,
});
const stream = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Write a two-line limerick about DNS." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
Streaming works over server-sent events, the same format the OpenAI SDKs already parse. Keep in mind that a streamed request holds its concurrency slot until the stream ends, which matters if you run many at once. The quickstart has the full request format.
Both SDKs also let you set a request timeout. For long replies, give streaming calls a generous timeout, since a completion can use the rest of the 100,000-token window and may take a while to finish.
curl for a quick check
Before you debug a framework, prove the key and URL work with curl. First list the models:
curl https://api.moonshotapi.cc/v1/models \
-H "Authorization: Bearer YOUR_KEY"
Then send a chat request:
curl https://api.moonshotapi.cc/v1/chat/completions \
-H "Authorization: Bearer YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Say hello in five words."}],
"max_tokens": 30
}'
If both work, the problem in your app is configuration, not the service. The response headers include X-Request-Id, which you should quote if you contact support, and X-Balance-USD with your remaining credit.
Chat front ends and custom endpoint fields
Many chat and roleplay front ends let you add an OpenAI-compatible endpoint. SillyTavern is one example: it has a custom OpenAI-compatible connection where you paste a URL, a key and a model name. Other tools label the fields differently, so match them by meaning.
| Field label you may see | Value to enter |
|---|---|
| Base URL, API URL, Endpoint, Server URL | https://api.moonshotapi.cc/v1 |
| API key, Secret, Token | Your key from the dashboard |
| Model, Model ID, Model name | uncensored |
| Provider or type | OpenAI-compatible, Custom OpenAI, or Chat Completions |
Some tools ask for the full path instead of the base. If the field says something like "chat completions URL", enter https://api.moonshotapi.cc/v1/chat/completions. If it says "base", stop at /v1. When a tool offers a model picker, it usually calls GET /v1/models, and the list should show uncensored.
Keeping the URL in configuration, not in code
Hard-coding a base URL in ten files is how projects end up pointing at the wrong place after a move. Put the three values in one place and read them everywhere.
import os
from openai import OpenAI
def make_client():
return OpenAI(
base_url=os.environ.get("LLM_BASE_URL", "https://api.moonshotapi.cc/v1"),
api_key=os.environ["LLM_API_KEY"],
)
MODEL = os.environ.get("LLM_MODEL", "uncensored")
With this layout a staging environment, a laptop and production differ only in their environment variables. If you ever compare this endpoint with another OpenAI-compatible one, you change two strings and run the same test suite against both. That is the real value of a compatible API: the switching cost is a config edit, not a rewrite.
In Docker, pass the values with --env-file or your orchestrator's secret store. Do not bake the key into the image, and keep it out of version control. A .env file in your project root is fine locally as long as it is listed in your ignore file.
Never put the key in browser code
The key is a bearer secret. Anyone who can read your page source can read it and spend your credit. Call the API from a server, and let your front end talk to your own backend. This is also where you apply your own per-user limits, so one visitor cannot use up the 300 requests per minute that belong to your whole account.
Checking that the connection itself is healthy
If a request fails before any API error appears, the problem is on the network path. A short checklist, in order:
- Resolve the host:
nslookup api.moonshotapi.ccshould return an address. A failure here means DNS, a typo or a blocked resolver. - Open it with curl as shown above. A TLS error points at an old system certificate store or a proxy that rewrites HTTPS.
- Look for a corporate proxy. SDKs honor
HTTPS_PROXYandNO_PROXY; a stale value may send traffic somewhere unexpected. - Run
GET /v1/modelswith your key. A response listinguncensoredconfirms host, key and path in one call. - Only then look at your own request body. The size limit is 8 MB, and the context window is 100,000 tokens for prompt plus completion.
When you contact support, send the X-Request-Id from the failing response and the time of the call. Without it, finding one request among many is guesswork.
Common mistakes and how to fix them
Missing /v1
The most frequent error. A URL of https://api.moonshotapi.cc with no /v1 reaches the wrong path, and you get a not-found response. Add /v1.
Doubled path
The SDK appends /chat/completions itself. If you also put it in the base URL, the request goes to /v1/chat/completions/chat/completions. Keep the base URL short.
Wrong model name
The model ID is uncensored, lowercase. Names copied from another provider's docs will not match. Call GET /v1/models if in doubt.
Key not sent or wrongly formatted
The header must read Authorization: Bearer YOUR_KEY. Check for stray spaces or quote characters pasted along with the key, a frequent trap with .env files.
Old environment variables overriding your code
If a shell still exports a different OPENAI_BASE_URL from an earlier project, a client created without arguments will use it. Print the variable and unset it if needed.
HTTP 429
This means a limit, not a wrong URL. The error code rate_limited means too many requests per minute and concurrency means too many at once. A 429 with a Retry-After: 5 header is temporary overload; wait that long and retry. A full key allows 8 concurrent requests and 300 per minute, and the trial key 2 and 60.
Trying it without paying first
New users can claim $0.50 of trial credit with one click on the API key page after sign-up. It needs no card, is valid for 7 days and is limited to one per person. Pricing after that is $0.15 per 1M input tokens and $0.50 per 1M output tokens, from prepaid credit that never expires, with top-ups from $20 by crypto. See pricing for the bonus tiers.
The prompts you send are not used for training. The model handles text only: no images, audio, video, embeddings or fine-tuning. Lawful adult use is the intended scope, and sexual content involving minors is not allowed under any circumstances.
If the first request works from curl but fails inside your app, compare the two side by side: the URL, the header, the model string and the body. Nine times out of ten the difference is one character.
More guides
Questions and answers
What is the base URL for this API?
It is https://api.moonshotapi.cc/v1, including the /v1 suffix. Use it as the base_url in Python or baseURL in Node.
Is this the official Moonshot endpoint?
No. It is an independent, OpenAI-compatible endpoint for one open-weight model. For Moonshot's own API, use the URL in their documentation.
What model name should I use?
Use uncensored as the model ID in every request. GET /v1/models returns it.
Do I need a different SDK?
No. Any OpenAI SDK or client works once you change the base URL and the key.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.