EN ▾
Get API key

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.

SpecValue
ProtocolOpenAI Chat Completions schema; official openai SDKs work unchanged
Base URLhttps://api.moonshotapi.cc/v1
Modeluncensored
EndpointsPOST /v1/chat/completions · GET /v1/models
API keyBearer token in the Authorization header
StreamingSupported (stream: true), usage included at the end
JSON moderesponse_format: {"type": "json_object"}
Tools / tool callsSupported: tools + tool_choice, tool_calls in the reply (streamed too), tool results as role: tool messages
Sampling parameterstemperature, top_p, stop, seed and the two penalties are passed through
Completion lengthprompt + completion fit within 100,000 tokens; max_tokens optional, no separate output cap
Context window100,000 tokens, input and output combined
Max bodyup to 8 MB per request
Requests per minute300 requests per minute per key
Response headersX-Request-Id, X-Balance-USD, X-RateLimit-Limit-Requests, X-RateLimit-Limit-Concurrency
Parallel requestsup to 8 in parallel per key
Paymentcrypto: USDT on TRON or USDC on Base, $20–$500, any whole sum
Bonus credit+5% on $50+, +10% on $100+, +15% on $200+
Priceinput $0.15 / 1M tokens, output $0.50 / 1M tokens
How you payprepaid 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
Subscriptionpaid credit never expires, no subscription
AccountGoogle or e-mail and password
Content policyuncensored for adults; the only hard rule: no sexual content involving minors
Keysone 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.

HTTPTypeWhat to do
400bad_requestmalformed request or too long for the context window
401missing_key · invalid_key · key_revokedcheck the Authorization header or use your current key
402no_creditout of credit; add credit and retry
403content_blockedsexual content involving minors — refused, not billed
404not_foundonly /v1/chat/completions and /v1/models exist
413request_too_largebody over 8 MB
429rate_limited · concurrencyslow down: rate or parallel limit reached
503upstream_busytemporary 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.