EN ▾
Get your key

Budgeting LLM Costs: Token Math for Uncensored APIs

Switching to an uncensored API often means moving from fixed monthly subscriptions to pay-as-you-go token models. This shift requires a new approach to cost estimation, focusing on token counts rather than flat fees. By understanding the specific rates of our service, you can predict monthly expenses more accurately and avoid unexpected overages.

Illustration of token math and cost budgeting for LLM APIs

Understanding the Token-Based Pricing Model

When you move away from subscription-based models, the first thing to grasp is how token pricing works. Our API charges based on the volume of text processed, measured in millions of tokens. The input rate is set at $0.15 per million tokens, while the output rate is $0.50 per million tokens. This means that generating responses is significantly more expensive than sending prompts.

It is important to note that this pricing structure applies to the text-only capabilities of our service. We do not charge for image, audio, or video generation, nor for embeddings or fine-tuning. If you need those features, you should check the documentation of other vendors for their specific pricing and limits.

Another key aspect is that prepaid credit never expires. You can top up your account with cryptocurrency, such as USDT on TRC20 or USDC on Base, in amounts ranging from $20 to $500. This flexibility allows you to manage your cash flow without the pressure of monthly renewal deadlines.

Errors and refusals are free of charge, which can help reduce costs if your prompts occasionally trigger safety filters or syntax errors. However, the core cost driver remains the volume of tokens processed. By monitoring your token usage, you can keep your budget predictable and avoid surprise bills at the end of the month.

Calculating Input and Output Costs

To estimate your monthly budget, you need to calculate the total tokens sent and received. Start by tracking the number of input tokens your application sends to the API. Multiply this number by $0.15 and then divide by one million to get the input cost. This formula helps you understand the baseline expense of your prompts.

Next, track the output tokens generated by the model. Since output tokens are more expensive, this component often dominates your total cost. Multiply the output token count by $0.50 and divide by one million to find the output expense. Adding these two values gives you the total cost for a specific period.

For example, if your application sends 500,000 input tokens and receives 200,000 output tokens in a month, you can calculate the costs separately. The input cost would be derived from the 500,000 tokens, and the output cost from the 200,000 tokens. This breakdown helps you identify which part of your workflow is driving expenses.

By keeping a close eye on these metrics, you can optimize your prompts to reduce input tokens or refine your system instructions to limit output length. This proactive approach ensures that your budget remains aligned with your actual usage, preventing unexpected spikes in spending.

Managing Rate Limits and Budget Caps

Rate limits are a important part of managing your API usage. Our API allows 300 requests per minute per key, which is generally sufficient for most applications. However, if you are running multiple agents or high-volume workflows, you might need to manage these limits carefully to avoid hitting the cap.

In automation tools like n8n, developers often create hard spend caps for each client or workflow. This ensures that a single runaway workflow cannot drain the entire budget. By logging tokens per execution and measuring cost per completed task, you can gain better control over your spending.

It is also wise to monitor your token usage in real-time. If you notice that a specific workflow is consuming more tokens than expected, you can adjust the parameters or add additional logic to limit the output. This helps in maintaining a stable budget and prevents unexpected overages.

Additionally, consider using scoped API keys for different projects. This allows you to track usage per project and set individual limits. By separating your workflows, you can isolate issues and prevent one project from affecting the budget of another. This strategy is particularly useful for agencies managing multiple clients.

When Our API Is Not the Right Choice

While our API is excellent for text generation, it may not be the right choice for all use cases. If you need image, audio, or video generation, our service does not support these features. You would need to look for other vendors that specialize in multimodal outputs.

Similarly, if you require embeddings for semantic search or fine-tuning for custom model behavior, our API does not offer these capabilities. In such cases, you should check the documentation of other providers to find a solution that meets your specific needs.

Another limitation is that our API is text-only. If your application relies on OCR or model routing to switch between different models, our service does not support these functions. You would need to integrate with other tools to achieve these capabilities.

Finally, if you need a dedicated SLA or certifications like SOC2 or HIPAA, our service does not currently offer these guarantees. For enterprises with strict compliance requirements, you might need to consider other vendors that provide these specific assurances. Always verify the current features and limits of any vendor before making a decision.

Handling API Key Security and Scoping

Security is a major concern when managing API keys at scale. Developers often scope keys per agent or project to prevent unauthorized access and control spending. By using scoped keys, you can limit the damage if a key is compromised and track usage more accurately.

In the context of n8n workflows, it is common to give each client their own key with a hard spend cap. This ensures that one runaway workflow cannot burn through the shared budget. By logging tokens per execution, you can measure the cost per completed task rather than per call, which provides a clearer picture of your actual expenses.

Another best practice is to use a centralized proxy to handle routing to the right provider. This allows you to manage multiple models and keys from a single point. It also simplifies the process of switching providers if needed, as you can update the proxy configuration without changing your application code.

Additionally, consider using managed identities or environment variables to store your keys securely. This reduces the risk of exposing your keys in your codebase or version control system. By keeping your keys secure, you can protect your budget from unauthorized usage and ensure that your API credits are used efficiently.

Optimizing Prompts for Cost Efficiency

One of the most effective ways to reduce costs is by optimizing your prompts. Shorter prompts generally mean fewer input tokens, which directly lowers your input costs. However, you need to ensure that the prompt contains enough context for the model to generate accurate responses.

Another strategy is to limit the output length. By setting appropriate parameters such as max_tokens, you can prevent the model from generating excessively long responses. This not only reduces output costs but also improves the speed of your application.

You can also use techniques like few-shot learning to provide examples in your prompt. This helps the model understand the desired format and content, reducing the need for extensive output. By providing clear examples, you can guide the model to produce more concise and relevant responses.

Finally, consider caching frequently used responses or results. If your application often queries the same information, you can store the results and reuse them instead of sending new requests. This reduces the number of tokens processed and lowers your overall costs. By combining these strategies, you can maximize the efficiency of your API usage.

Integrating with Automation Tools

Integrating our API with automation tools like n8n can simplify your workflows and improve efficiency. By using the API within these tools, you can automate tasks such as content generation, data processing, and customer support.

When integrating, it is important to handle errors and rate limits gracefully. Our API returns specific error codes, such as 401 for invalid keys, 402 for no credit, and 429 for rate limits. By handling these errors appropriately, you can ensure that your workflows continue to run smoothly even when issues arise.

Additionally, you can use streaming to provide real-time responses to users. Our API supports streaming over SSE, which allows you to send usage information in the last chunk. This enhances the user experience by providing immediate feedback and reduces the perceived latency of your application.

Finally, consider using function calling to enable more complex interactions. Our API supports tools and JSON mode, allowing you to integrate with other services and perform specific actions. By using these features, you can build more sophisticated and interactive applications that meet the needs of your users.

Frequently asked questions

How do I calculate the cost of my API usage?

Multiply the number of input tokens by $0.15 and divide by one million. Then, multiply the output tokens by $0.50 and divide by one million. Add these two values to get your total cost.

What happens if I run out of credit?

If you run out of credit, you will receive a 402 error. You can top up your account with USDT on TRC20 or USDC on Base in amounts between $20 and $500. Your prepaid credit never expires.

Can I use the API for image generation?

No, our API is text-only. It does not support image, audio, or video generation. If you need those features, you should check the documentation of other vendors for their specific capabilities.

How many requests can I make per minute?

You can make 300 requests per minute per key. If you exceed this limit, you will receive a 429 rate limit error. You can manage this by using scoped keys or a centralized proxy.