Understanding the pay-per-token model
Pay-per-token billing means you only pay for what you consume, not for idle access to a server. Unlike traditional monthly subscriptions, this model aligns costs directly with usage volume. You get charged based on actual input and output tokens processed by the endpoint.
Most providers charge different rates for input versus output tokens. For example, some uncensored LLM services price input at $0.15 per million tokens and output at $0.50 per million tokens. This disparity exists because generating text requires significantly more compute than reading it.
You should monitor your token counts closely. A single long response can exceed your input cost if you do not estimate output length. Always check the usage metadata returned in the response headers or body to track your spending accurately.
Why your streaming response cuts off early
Streaming responses cut off early because clients often stop listening after the first few chunks. The server sends data in real-time, but your application might disconnect prematurely if it does not handle the stream correctly.
Each chunk contains partial text. You must concatenate these chunks to form the complete response. If you discard intermediate chunks, you lose data. The final chunk usually contains the complete usage statistics.
Check your timeout settings. Some networks drop connections after a few seconds of inactivity. Ensure your client handles intermittent pauses in the stream. This is common with large language models that generate long texts.
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)
Handling the 100k context window correctly
The context window limit includes both your prompt and the generated completion. You cannot send 100k tokens in the prompt and expect another 100k in the response. The total combined length must stay within the limit.
If you send a large prompt, you have less room for the response. For example, a 90k token prompt leaves only 10k tokens for output. This can truncate long answers abruptly.
Implement token counting on your side. Use a tokenizer that matches the model's encoding. This ensures you do not exceed the limit during the request. If you do, the server will return an error.
Consider truncating older messages in chat histories. This keeps the most recent context while staying within bounds. This is crucial for maintaining conversation coherence over long sessions.
Crypto top-ups: why your balance didn't update
Crypto top-ups fail to update when you send tokens to the wrong network. Our API accepts USDT on TRC20 and USDC on Base. Sending USDT on Ethereum to a TRC20 address will result in lost funds.
Always verify the network prefix before sending. The deposit page shows the specific address and network for each currency. Do not assume all USDT addresses are interchangeable.
Wait for the required number of confirmations. Transactions are not instant. The system credits your account only after the blockchain confirms the transfer. This prevents double-spending issues.
Check the transaction hash on a block explorer. If the balance does not update, provide the hash to support. They can manually verify the transfer. This is the fastest way to resolve discrepancies.
Fixing function calling errors in uncensored models
Function calling errors often stem from non-standard JSON formatting in uncensored models. These models prioritize creativity over strict structure, which can break rigid parsers.
Set the response format to json_object to enforce stricter output. This reduces the chance of malformed JSON. However, it may slightly reduce creativity.
Validate the response before parsing. Use a try-catch block to handle JSON decode errors. If parsing fails, retry with a lower temperature. This encourages more deterministic output.
from openai import OpenAI
client = OpenAI(base_url="https://api.aiapisubscription.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)
Rate limits: handling 300 RPM bursts
Rate limits restrict how many requests you can send per minute. Our API allows 300 requests per minute per key. Exceeding this limit returns a 429 status code.
Implement exponential backoff when you hit the limit. Retry the request after a short delay. This prevents overwhelming the server during peak usage.
Monitor your request frequency. If you send requests too quickly, you may trigger the limit. Space out your requests evenly. This ensures consistent performance.
Use multiple keys if you need higher throughput. Each key has its own limit. This allows you to scale your application without hitting a single bottleneck.
JSON mode failures and response formatting
JSON mode failures occur when the model returns invalid syntax. This is common in uncensored models that prioritize natural language over structured data.
Use the response_format parameter to enforce JSON output. This tells the model to structure its response as valid JSON. However, it does not guarantee correctness.
Validate the output using a JSON schema. This ensures the data matches your expected structure. If validation fails, request a retry or adjust the prompt.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.aiapisubscription.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);
Debugging token counting discrepancies
Token counting discrepancies arise when your client uses a different tokenizer than the model. This leads to inaccurate cost estimates.
Use the official tokenizer provided by the model vendor. This ensures your counts match the actual usage. Third-party tokenizers may handle special characters differently.
Check the usage metadata in the response. This provides the exact token count. Compare this with your local count to identify discrepancies.
Account for special tokens. These include system prompts and function definitions. They consume tokens but may not be visible in the raw text.
When to switch from local to API
Switch to an API when local hardware cannot meet your latency or scale requirements. Running a large model locally requires expensive GPUs and significant power.
APIs offer scalability without hardware maintenance. You can handle sudden traffic spikes easily. This is ideal for production environments.
Consider cost. If you run a local model 24/7, the electricity and hardware costs may exceed API usage. Pay-per-token billing is only cost-effective if usage is variable.
curl https://api.aiapisubscription.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Summarize the technical specs of the new GPU."}]
}'