GLM API: First request in five minutes
Get started with the GLM API in under five minutes by creating a key, topping up with crypto, and sending your first request.
Base URL and Authentication
The GLM API follows the OpenAI chat-completions standard. Point your client to the base URL https://api.glmapi.top/v1 and send your API key in the Authorization header as a Bearer token. You do not need a credit card to start; sign up with Google or an email address to generate your key immediately. The key is displayed once after creation, so save it securely.
Authentication is straightforward. If your key is missing or invalid, the API returns a 401 error. If your prepaid credit runs out, you receive a 402 error. These clear status codes help you debug integration issues quickly without hidden fees or subscription traps. You can only have one active key per account, but you can generate a new one to replace it at any time.
First Request
Test the endpoint with a simple chat completion. The following curl command sends a basic prompt to the uncensored model. Replace YOUR_API_KEY with the key from your dashboard. This request demonstrates the text-in, text-out nature of the service without extra complexity.
The response includes the generated text and token usage. If you encounter a 401, verify your key. A 402 indicates you need to top up your crypto balance. The API supports streaming, function calling, and JSON mode, but this simple test confirms your connection is working correctly.
curl https://api.glmapi.top/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 SDK
Use the official OpenAI Python SDK to integrate quickly. Set the base URL to our endpoint and provide your API key. The code below initializes the client and requests a completion. This approach works for any OpenAI-compatible client library, making migration from other providers simple.
The model ID is always uncensored. You can adjust parameters like temperature and top_p to control creativity. The API does not support embeddings or image generation, so stick to text-based interactions. Errors are returned as standard HTTP status codes, allowing you to handle rate limits or credit issues programmatically.
from openai import OpenAI
client = OpenAI(base_url="https://api.glmapi.top/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 SDK
For JavaScript environments, the Node SDK works identically to the Python version. Configure the base URL and API key, then call the chat completion method. This ensures consistent behavior across your backend services. The response structure matches the OpenAI standard, making it easy to parse the content and usage statistics.
You can handle errors by checking the status code. A 429 response means you have exceeded the rate limit of 300 requests per minute. A 402 response means your prepaid credit is exhausted. Since there are no monthly fees, you only pay for what you use, and your credit never expires.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.glmapi.top/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 Responses
Enable streaming by setting stream: true in your request. The API returns a Server-Sent Events (SSE) stream, allowing you to display tokens as they are generated. This reduces perceived latency for users. The final chunk of the stream contains the total token usage, which is billed to your prepaid credit.
Streaming is useful for long-form content generation. You can process tokens in real-time without waiting for the entire response. The API supports parameters like stop sequences and seed for reproducibility. Remember that the context window is 100,000 tokens, so streaming large responses is efficient.
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)
Limits, Errors, and Context
Each API key allows 300 requests per minute and 8 concurrent requests. The maximum request body size is 8 MB. If you exceed these limits, you receive a 429 error. The context window is 100,000 tokens for the combined prompt and completion. There is no separate output cap, and if you do not specify max_tokens, the response can run to the end of the window.
Errors are standard: 401 for invalid keys, 402 for insufficient credit, and 429 for rate limits. Refusals due to content filters are free. Mistakes like double charges are handled via the Support page. Credit is topped up with crypto (USDT, USDC) and never expires.
What the API supports
Everything the endpoint can and cannot do, in one place — check it before you top up.
| Feature | Support |
|---|---|
| Compatibility | OpenAI-compatible: any OpenAI SDK or client works — change the base URL and the key |
| Base URL | https://api.glmapi.top/v1 |
| Model ID | uncensored |
| Methods | POST /v1/chat/completions · GET /v1/models |
| Authentication | Bearer token in the Authorization header |
| Streaming | Supported (stream: true), usage included at the end |
| Function calling | Supported: tools + tool_choice, tool_calls in the reply (streamed too), tool results as role: tool messages |
| Max output | prompt + completion fit within 100,000 tokens; max_tokens optional, no separate output cap |
| Context window | 100,000 tokens, input and output combined |
| Other parameters | temperature, top_p, stop, seed and the two penalties are passed through |
| JSON mode | JSON object mode via response_format json_object |
| Headers | X-Request-Id, X-Balance-USD, X-RateLimit-Limit-Requests, X-RateLimit-Limit-Concurrency |
| Concurrency | up to 8 in parallel per key |
| Max body | up to 8 MB per request |
| Requests per minute | 300 requests per minute per key |
| Volume bonus | +5% on $50+, +10% on $100+, +15% on $200+ |
| Trial credit | $0.50 for 7 days, no card · Trial key: 2 parallel requests, 60 req/min; full limits (8 and 300) after first top-up |
| Token prices | input $0.15 / 1M tokens, output $0.50 / 1M tokens |
| Top-up | USDT (TRC20) or USDC (Base), any whole amount from $20 to $500 |
| How you pay | pay as you go from prepaid credit; nothing is charged for failed or refused requests |
| Subscription | no monthly fee; paid credit does not expire |
| Content policy | adult content allowed; sexual content involving minors is refused |
| Key management | one key per account, regenerate any time (the old one stops working) |
| Sign-in | sign in with Google or with e-mail + password |
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 | balance is empty — top up, requests resume at once |
403 | content_blocked | refused by the content policy |
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 | model busy — retry in a few seconds |
Questions and answers
How do I top up my credit?
You can top up by crypto (USDT on TRC20, USDC on Base). Minimum deposits are $20, and bonuses apply for larger amounts. There are no monthly fees, and your credit never expires.
What is the context window size?
The context window is 100,000 tokens for both prompt and completion. There is no separate output cap per request, and if max_tokens is not specified, the response can run to the end of the window.
Is there a free trial?
Yes, new accounts receive $0.50 of trial credit valid for 7 days. Claim this credit with one click on your API key page. No credit card is required to sign up and start using the API.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.
Get API key