Moonshot API Rate Limit vs Ours: Limits and Retries
Rate limits are only useful to know if you can turn them into a plan. Here are our exact limits, the math behind them, and code that stays inside them.
Updated

Key points
- A full key allows 8 concurrent requests and 300 requests per minute; the trial key allows 2 and 60.
- Two different 429 errors exist: rate_limited and concurrency. They need different fixes.
- The context window is 100,000 tokens, prompt plus completion, and a stream holds its slot until it ends.
- Check Moonshot's own documentation for their current limits instead of trusting a copied table.
On this page
- What to compare when you search for a rate limit
- Requests per minute versus concurrency
- The two kinds of 429
- A retry loop that respects Retry-After
- Capping concurrency in your own code
- Planning for bursts and several workers
- The 100k context window as a limit
- Choosing between providers on limits alone
- More guides
What to compare when you search for a rate limit
A moonshot api rate limit question usually hides three separate numbers: how many requests you can make per minute, how many can run at the same time, and how large a single request can be. Providers publish these differently, often by account tier, and the figures change. I will not copy Moonshot's numbers into this page. Open their documentation, find the limits for your tier, and put them next to ours.
Ours are fixed and short enough to memorize:
| Limit | Full key | Trial key |
|---|---|---|
| Concurrent requests | 8 | 2 |
| Requests per minute | 300 | 60 |
| Context window (prompt plus completion) | 100,000 tokens | 100,000 tokens |
| Maximum request body | 8 MB | 8 MB |
The trial key is the one you get with the $0.50 trial credit, which you can claim with one click on the API key page. The context window bounds the size of a single request.
Requests per minute versus concurrency
These two limits interact, and the smaller effective one wins. Concurrency caps how many calls are in flight. Requests per minute caps how many you start in a 60-second window. What you can actually sustain is:
max_per_minute = min(300, concurrency * 60 / average_seconds_per_request)
With 8 slots and requests that take 1.6 seconds each, you get 8 x 60 / 1.6 = 300 per minute, so both limits bind at once. If your requests are longer, the concurrency limit binds first. At 10 seconds per request you top out at 8 x 60 / 10 = 48 per minute, far below 300. Long replies are the usual reason people hit the concurrency ceiling while their request-per-minute counter looks nearly empty.
On a trial key the same formula gives 2 x 60 / average seconds. At 2 seconds per request the trial hits 60 per minute exactly; at 6 seconds it sustains 20.
The practical rule: measure how long your typical call takes before you decide how many workers to run. Eight workers is the most that will make progress at the same time; a ninth only adds a queue of rejections.
The two kinds of 429
When you go over, the API answers with HTTP 429 and an error code that tells you which limit you hit.
rate_limited: too many requests per minute. Slow down your start rate. The window is a minute, so a short pause usually clears it.concurrency: too many requests at the same time. Wait for some to finish, or cap your worker pool at 8.
There is a third case. If the service is temporarily overloaded, it also returns 429, with a Retry-After: 5 header. Treat that as an instruction: wait five seconds, then retry. This is not your quota; nothing is wrong with your code.
Response headers help you stay under the limits before you hit them. Every response carries X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency, plus X-Request-Id for support and X-Balance-USD for your remaining credit. Read the first two once at startup and size your pool from them rather than hard-coding 8.
A retry loop that respects Retry-After
The openai Python SDK retries some errors on its own, but a small explicit wrapper makes the behavior visible and lets you treat the two 429 types differently.
import time
import random
from openai import OpenAI, RateLimitError
client = OpenAI(
base_url="https://api.moonshotapi.cc/v1",
api_key="YOUR_KEY",
max_retries=0,
)
def ask(messages, tries=6):
delay = 1.0
for attempt in range(tries):
try:
return client.chat.completions.create(
model="uncensored",
messages=messages,
)
except RateLimitError as e:
retry_after = e.response.headers.get("retry-after")
wait = float(retry_after) if retry_after else delay
time.sleep(wait + random.uniform(0, 0.5))
delay = min(delay * 2, 30)
raise RuntimeError("still rate limited after retries")
It honors Retry-After when present, otherwise backs off exponentially up to 30 seconds, and adds jitter so that many workers do not retry in lockstep. Setting max_retries=0 stops the SDK from stacking its own retries on top.
The same ideas apply to any provider. The Groq troubleshooting article on this site covers similar 429 handling for another API, and the pattern carries over.
Capping concurrency in your own code
Retrying is the fallback. The better fix is not to exceed 8 in the first place. A semaphore does this in a few lines:
import asyncio
from openai import AsyncOpenAI
client = AsyncOpenAI(
base_url="https://api.moonshotapi.cc/v1",
api_key="YOUR_KEY",
)
gate = asyncio.Semaphore(8)
async def one(prompt):
async with gate:
r = await client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": prompt}],
)
return r.choices[0].message.content
async def main(prompts):
return await asyncio.gather(*(one(p) for p in prompts))
Use 2 instead of 8 on a trial key. If several processes share one key, they share the same budget, so divide: two services on one key might each get a gate of 4.
Streaming deserves a special mention. A streamed request occupies its slot until the last chunk arrives, not until the first one. A chat UI that opens eight streams and leaves them idle blocks everything else. Close streams you no longer read.
Planning for bursts and several workers
Traffic is rarely flat. A chat product sees quiet minutes and sudden bursts when a community event starts. Limits apply to the burst, not to the daily average, so average numbers mislead.
Suppose you expect 20,000 requests a day. That is about 14 a minute on average, which is far below 300. But if 40% of the day's traffic arrives in one evening hour, you see 8,000 requests in 60 minutes, or about 133 a minute. Still under 300, yet the concurrency check now matters: at 5 seconds per reply, 133 a minute needs about 133 x 5 / 60 = 11 requests in flight, above the limit of 8. The fix is a queue in front of the API, not a bigger retry loop.
A queue gives you three things. It smooths the burst so that at most 8 calls run at once. It lets you show users a waiting state instead of an error. And it gives you one place to measure how long requests wait, which is the number to watch as you grow.
Several processes on one key
Limits belong to the key, not to the process. If you run four web workers, each with its own pool of 8, you have a pool of 32 asking for 8 slots. Either share one queue between workers (a job queue or a small gateway service) or give each worker a fraction, such as 2 each for four workers.
What to monitor
Count 429 responses by error code, and graph the two codes separately. A rise in concurrency says add queueing or reduce parallelism. A rise in rate_limited says you start too many requests per minute. Both together mean you have outgrown a single key's budget, and it is time to decide between batching, caching repeated answers, or a different architecture.
The 100k context window as a limit
Context is the third limit and the one that quietly changes your bill. The window is 100,000 tokens, shared by the prompt and the completion. A prompt of 90,000 tokens leaves about 10,000 for the reply. You do not need to set max_tokens, since the completion can use whatever the window leaves, but setting it protects you from a runaway reply.
The cost of filling the window is modest at our rates of $0.15 per 1M input tokens and $0.50 per 1M output tokens. A full 90,000-token prompt with a 2,000-token answer costs 0.09 x $0.15 = $0.0135 for input plus 0.002 x $0.50 = $0.001 for output, a total of $0.0145. But 300 such calls in a minute would be $4.35, so large prompts at high rates add up fast. See pricing for how top-ups and bonuses work.
Bodies are capped at 8 MB, which only matters if you embed large pasted files in the request. For long documents, trim or summarize first rather than hitting the body limit.
Choosing between providers on limits alone
If your workload is a batch job that needs hundreds of simultaneous calls, 8 concurrent requests is a hard ceiling here, and another provider or a self-hosted setup may fit better. If your workload is an interactive app with a few dozen active users, 8 concurrent and 300 per minute is plenty, provided you cap your pool and stream responses.
Compare the three numbers from the table above against your own peak. Then run a trial. The $0.50 trial credit runs on a key limited to 2 concurrent requests and 60 per minute, so it will show you the error format and the headers even if it cannot show you full-speed throughput. The quickstart has a first request you can paste in.
More guides
Questions and answers
What are the rate limits on a full key?
8 concurrent requests and 300 requests per minute. The trial key allows 2 concurrent and 60 per minute.
How do I tell which 429 I got?
Read the error code. rate_limited means too many requests per minute, and concurrency means too many at once. A Retry-After: 5 header means temporary overload.
Does a stream count against concurrency the whole time?
Yes. A streamed request keeps its slot until the stream ends, so close streams you no longer read.
What is the maximum context?
100,000 tokens for prompt plus completion. The request body can be up to 8 MB.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.