Installation and Configuration
To begin, ensure you have the official OpenAI SDK installed for your language. The API uses a standard header-based authentication scheme. You must set the Authorization header to Bearer your-api-key and configure the base URL to https://api.glmapi.cc/v1. This URL works with any client that supports the OpenAI Chat Completions format.
No special client initialization is required beyond standard configuration. The service acts as a drop-in replacement for existing OpenAI integrations. You can verify your setup by checking the available models endpoint.
First Request
Send a simple text completion request to test connectivity. Use the model identifier uncensored for the primary large language model. The API accepts standard parameters like max_tokens and temperature.
This request returns a direct text response. If you encounter a 401 error, verify your API key. A 402 error indicates insufficient prepaid credit.
curl https://api.glmapi.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 SDK Integration
Use the official Python library to interact with the API. Initialize the client with your base URL and API key. The syntax mirrors the standard OpenAI client structure.
This approach allows you to swap providers without rewriting business logic. The model responds to standard prompt formats. You can control output length and randomness via standard parameters.
from openai import OpenAI
client = OpenAI(base_url="https://api.glmapi.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 SDK Integration
For JavaScript environments, use the Node SDK. Configure the baseUrl to point to our API endpoint. This ensures all requests route correctly to our servers.
The SDK handles retries and response parsing automatically. You can pass standard completion parameters. The response object contains the generated text in the expected location.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.glmapi.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 Responses
Enable streaming by setting the stream parameter to true. The API returns chunks via Server-Sent Events (SSE). Each chunk contains partial text and usage statistics.
This method reduces perceived latency for long responses. You can process tokens as they arrive. The final chunk includes the total token count for billing.
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
The context window supports 100,000 tokens total, with a maximum output of 32,000 tokens. Requests exceeding the 8 MB body limit will fail. You are limited to 300 requests per minute and 8 concurrent requests per key.
Error 401 means an invalid key. Error 402 indicates no prepaid credit remains. Error 429 signals rate limiting. Credit never expires, and errors do not consume tokens. Privacy is maintained; prompts are not used for training.
Under the hood: specs
If your tool speaks the OpenAI API, these are the details that matter.
| Feature | Support |
|---|---|
| Protocol | OpenAI Chat Completions schema; official openai SDKs work unchanged |
| Model | uncensored |
| Endpoints | POST /v1/chat/completions · GET /v1/models |
| Authentication | Bearer token in the Authorization header |
| Base URL | https://api.glmapi.cc/v1 |
| Sampling parameters | temperature, top_p, stop, seed and the two penalties are passed through |
| Context window | 100,000 tokens (prompt + completion together) |
| Completion length | prompt + completion fit within 100,000 tokens; max_tokens optional, no separate output cap |
| Tools / tool calls | Supported: tools + tool_choice, tool_calls in the reply (streamed too), tool results as role: tool messages |
| SSE streaming | Yes — server-sent events; the last chunk carries token usage |
| Structured output | response_format: {"type": "json_object"} |
| Concurrency | up to 8 in parallel per key |
| Request size | up to 8 MB per request |
| Response headers | X-Request-Id, X-Balance-USD, X-RateLimit-Limit-Requests, X-RateLimit-Limit-Concurrency |
| Requests per minute | 300 requests per minute per key |
| Payment | USDT (TRC20) or USDC (Base), any whole amount from $20 to $500 |
| Credit expiry | no monthly fee; paid credit does not expire |
| Bonus credit | +5% on $50+, +10% on $100+, +15% on $200+ |
| How you pay | prepaid credit, charged by real token usage; errors and refusals are free |
| 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 |
| Price | input $0.15 / 1M tokens, output $0.50 / 1M tokens |
| Content | adult content allowed; sexual content involving minors is refused |
| Account | sign in with Google or with e-mail + password |
| Key management | one key per account, regenerate any time (the old one stops working) |
When a request fails
Errors come back as JSON with a stable type; failed and refused requests are not billed.
| Code | Type | Meaning |
|---|---|---|
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 | sexual content involving minors — refused, not billed |
404 | not_found | unknown endpoint |
413 | request_too_large | body over 8 MB |
429 | rate_limited · concurrency | over 300/min or 8 parallel — back off and retry |
503 | upstream_busy | model busy — retry in a few seconds |
Questions and answers
Is this the official GLM API?
No, this is an independent service. We run our own uncensored model and provide an OpenAI-compatible interface. It is not affiliated with the original GLM developers.
How do I pay for the API?
We accept top-ups by crypto (USDT on TRC20, USDC on Base). Minimum top-up is $20. Prepaid credit is charged by token usage and never expires.
What is the context window size?
The model supports a 100,000-token context window. The maximum output per request is 32,000 tokens unless specified otherwise.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.