Mini cpm API documentation
Get your uncensored chatbot running instantly with our openai compatible API. This quickstart guides you through authentication, requests, and streaming.
https://api.cpmmini.com/v1uncensored
Create keyAuthentication and Base URL
Start every request with your API key and the correct base URL. We use standard OpenAI headers for compatibility. Your key grants access to the uncensored model immediately. The base URL is HTTPS://api.cpmmini.com/v1. Use the header Authorization: Bearer . Keep your key secure. It identifies your prepaid credit account. No subscription fees apply here. Just pay per token used.
First Request
Send your first message to the chat completions endpoint. This confirms your key works and credits deduct correctly. The uncensored model responds without typical refusals. Use curl for a quick test. Replace YOUR_API_KEY with your actual key from the dashboard. This step verifies connectivity and latency. Errors like 401 indicate an invalid key. Check your account dashboard if it fails. The response returns the generated text.
Python SDK Integration
Use the official OpenAI Python library for programmatic access. Set the base URL to our endpoint. This ensures all requests route to our uncensored model. Install the library via pip. Pass your API key in the client initialization. Request the model uncensored. The SDK handles retries and JSON parsing. This approach simplifies integration into your existing bots. It works with async loops too. Check your credit balance after the call.
Node SDK Setup
Integrate with Node.js using the npm package. Configure the base URL to point to our API. This maintains compatibility with OpenAI standards. Install the dependency in your project. Initialize the client with your key. Call the chat completions method. The response object contains the generated text. Handle errors gracefully in your application. This setup supports both CommonJS and ES modules. It is ideal for server-side chatbots.
Streaming Responses
Stream tokens for real-time user experiences. Enable streaming in your request parameters. The API sends chunks as they generate. This reduces perceived latency for users. Use the SSE endpoint for continuous data. Parse each chunk to build the final message. This feature works with both Python and Node SDKs. It is essential for chat interfaces. Monitor the token usage in the final chunk. Your credit deducts based on total tokens sent.
Limits, Errors, and Context
Watch your rate limits and credit status. You get 300 requests per minute. Only eight concurrent requests per key are allowed. A 429 error means you hit the limit. A 402 error indicates insufficient credit. Top up with crypto to continue. The context window supports 100,000 tokens. This allows long conversations without losing history. Errors and refusals do not cost credits. Your prepaid credit never expires. Manage your keys in the dashboard.
cURL
curl https://api.cpmmini.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Send test message"}]
}'Python
from openai import OpenAI
client = OpenAI(base_url="https://api.cpmmini.com/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.cpmmini.com/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)Common questions
How do I get started with the mini cpm API?
Sign up with Google or email to get your API key instantly. Fund your account with USDT or USDC via crypto. Use the base URL and your key to send your first request. Trial credit is available for new accounts.
What is the context window size?
The context window supports 100,000 tokens for both input and output combined. You can send long prompts and receive up to 16,000 tokens in one response. This allows for extensive conversations and document processing without losing context.
Why am I getting a 402 error?
A 402 error means your prepaid credit is insufficient for the request. Top up your account with crypto to restore access. Errors like refusals do not consume credit, so you only pay for actual tokens used. Credit never expires, so you can top up whenever you like.
Get your API key now
Sign up, copy the token, update your base URL. Done.