Quickstart for Moonshot users
Integrate with the Moonshot API using standard OpenAI-compatible endpoints. This quickstart covers authentication, request formats, and streaming for immediate deployment.
Base URL and Authentication
Start by setting your base URL to https://api.moonshotapi.cc/v1. You only need one API key, generated immediately after signing up via Google or email. Pass this key in the Authorization header as a Bearer token. The GET /v1/models endpoint confirms connectivity without consuming credits.
Basic Chat Completion Request
Send a POST request to /v1/chat/completions with the model ID uncensored. The API accepts standard message arrays containing role and content. This open source llm api responds with text, supporting up to 100,000 tokens for the combined prompt and completion.
Streaming Responses
Enable streaming by setting stream: true. The API returns Server-Sent Events (SSE), delivering tokens incrementally. Token usage details appear in the final chunk. This method is ideal for real-time user interfaces and reduces perceived latency.
Function Calling (Tools)
Define tools in your request body to enable structured outputs. The uncensored model supports function calling with tool_choice options. Pass tool definitions in the tools array and specify the desired model in tool_choice. The API returns function arguments in JSON format.
JSON Mode Response
Force JSON output by setting response_format to {"type": "json_object"}. This ensures the model returns valid JSON, simplifying parsing in your application. This feature works alongside standard parameters like temperature and top_p for predictable results.
Rate Limits and Constraints
Each key allows 300 requests per minute and 8 concurrent requests. The request body must not exceed 8 MB. If you receive a 401 error, check your key. A 402 indicates insufficient credit. A 429 means you hit the rate limit. Errors do not consume credits.
cURL
curl https://api.moonshotapi.cc/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Write a blunt product review of a cheap VPN."}]
}'Python
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": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)Node.js
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.moonshotapi.cc/v1", apiKey: process.env.API_KEY });
const resp = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);Streaming
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Tell the story in second person."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)Capabilities and limits
Use this table to decide whether the API fits your project before you buy credit.
| Spec | Value |
|---|---|
| Protocol | OpenAI Chat Completions schema; official openai SDKs work unchanged |
| Base URL | https://api.moonshotapi.cc/v1 |
| Model | uncensored |
| Endpoints | POST /v1/chat/completions · GET /v1/models |
| API key | Bearer token in the Authorization header |
| Streaming | Supported (stream: true), usage included at the end |
| JSON mode | response_format: {"type": "json_object"} |
| Tools / tool calls | Supported: tools + tool_choice, tool_calls in the reply (streamed too), tool results as role: tool messages |
| Sampling parameters | temperature, top_p, stop, seed and the two penalties are passed through |
| Completion length | prompt + completion fit within 100,000 tokens; max_tokens optional, no separate output cap |
| Context window | 100,000 tokens, input and output combined |
| Max body | up to 8 MB per request |
| Requests per minute | 300 requests per minute per key |
| Response headers | X-Request-Id, X-Balance-USD, X-RateLimit-Limit-Requests, X-RateLimit-Limit-Concurrency |
| Parallel requests | up to 8 in parallel per key |
| Payment | crypto: USDT on TRON or USDC on Base, $20–$500, any whole sum |
| Bonus credit | +5% on $50+, +10% on $100+, +15% on $200+ |
| Price | input $0.15 / 1M tokens, output $0.50 / 1M tokens |
| How you pay | prepaid credit, charged by real token usage; errors and refusals are free |
| Free trial | $0.50 for 7 days, no card · Trial key: 2 parallel requests, 60 req/min; full limits (8 and 300) after first top-up |
| Subscription | paid credit never expires, no subscription |
| Account | Google or e-mail and password |
| Content policy | uncensored for adults; the only hard rule: no sexual content involving minors |
| Keys | one key per account, regenerate any time (the old one stops working) |
Error reference
Every error is JSON with a type you can switch on. You are never charged for an error.
| HTTP | Type | What to do |
|---|---|---|
400 | bad_request | malformed request or too long for the context window |
401 | missing_key · invalid_key · key_revoked | check the Authorization header or use your current key |
402 | no_credit | out of credit; add credit and retry |
403 | content_blocked | sexual content involving minors — refused, not billed |
404 | not_found | only /v1/chat/completions and /v1/models exist |
413 | request_too_large | body over 8 MB |
429 | rate_limited · concurrency | slow down: rate or parallel limit reached |
503 | upstream_busy | temporary overload, retry shortly |
Questions and answers
How do I top up my credit?
You can top up by crypto (USDT on TRC20, USDC on Base). Payments range from $20 to $500, with bonus credits for larger amounts. Credit never expires and is charged only for real token usage.
Is the model uncensored?
Yes, the model does not refuse lawful adult, fictional, or controversial topics. The only hard limit is on sexual content involving minors. It is not GPT, Claude, or any other vendor's model.
Can I use the standard OpenAI SDK?
Yes, the API is fully OpenAI-compatible. Update the base URL and API key in your SDK configuration, and the same client code works immediately for text completions and streaming.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.