EN ▾
Start now

Estimating Heretic AI API Costs for Your Project

Developers often struggle to predict token usage and budget for uncensored text generation. This guide teaches a method to estimate input and output token volumes using Heretic AI's specific pricing tiers to help you calculate expected spend.

Illustration of token flow and text generation for API cost estimation

Understanding the Pricing Model

Our API uses a straightforward pay-as-you-go model based on token consumption. You are charged $0.15 per one million input tokens and $0.50 per one million output tokens. This structure allows you to pay only for the actual text processed, without any monthly subscription fees or hidden costs. The prepaid credit you purchase is charged against real token usage, ensuring transparency in your billing.

Errors and refusals are free, which means you do not pay for failed requests or content that does not meet your criteria. This is particularly useful when testing different parameters or when dealing with complex prompts that might trigger specific filters. The prepaid credit never expires, giving you the flexibility to use it whenever you need it, if you are running a small script or a large-scale application.

It is important to note that we do not charge for embeddings, image generation, audio processing, or video generation. Our service is strictly text-in, text-out. This focus allows us to keep our pricing simple and predictable. If you need multimodal capabilities, you may need to look at other providers, but for pure text generation, our API offers a clear and cost-effective solution.

The base URL for our API is https://api.hereticia.com/v1. You can access the chat completions endpoint via POST /v1/chat/completions, the responses endpoint via POST /v1/responses, and list available models via GET /v1/models. Keeping these endpoints in mind will help you integrate the API smoothly into your workflow.

Estimating Input and Output Tokens

To estimate your costs, you need to understand how tokens are counted. A token is roughly four characters in English, but this can vary depending on the language and special characters used. For accurate estimation, you can use the tokenizer provided by the model or approximate based on word count. Generally, one thousand words might translate to around 1,300 tokens, but this is a rough estimate.

When you send a prompt, the input tokens include the system message, the user message, and any previous conversation history. The output tokens are generated by the model in response. Our API has a context window of 100,000 tokens, which means the sum of input and output tokens cannot exceed this limit. This is important for long conversations or large document processing.

Let us consider a simple example. If you send a prompt with 1,000 tokens and receive an output of 500 tokens, the total tokens used are 1,500. The cost would be calculated as (1,000 / 1,000,000) * $0.15 for input and (500 / 1,000,000) * $0.50 for output. This formula helps you predict the exact cost for each request.

By tracking your token usage over time, you can identify patterns and optimize your prompts. For instance, you might find that shorter prompts yield similar results, reducing input costs. Similarly, you can adjust the max_tokens parameter to control output length, preventing unnecessary token consumption. This proactive approach helps in maintaining a predictable budget.

Top-Up and Payment Methods

Our API accepts crypto payments only, specifically USDT on the TRC20 network or USDC on the Base network. You can top up your account with any whole amount between $20 and $500. This range allows for flexibility in funding your account, if you are a small indie developer or a larger team.

If you top up with $50 or more, you receive bonus credit ranging from +5% to +15%. This bonus is a great way to maximize your budget and get more value from your purchases. The bonus credit is added to your account and can be used for any request, just like your regular credit.

We do not accept credit cards, PayPal, or bank transfers. This crypto-only approach simplifies the payment process and reduces transaction fees. It also allows for faster processing of top-ups, ensuring that your account is ready to use as soon as the transaction is confirmed on the blockchain.

New accounts receive $0.50 of trial credit, no credit card needed. This allows you to test the API without any financial commitment. You can use this trial credit to explore the features, test different parameters, and get a feel for the model's performance before making a larger investment.

Rate Limits and Error Handling

Our API has a rate limit of 300 requests per minute per key. This limit is designed to ensure fair usage and prevent abuse. If you exceed this limit, you will receive a 429 error, indicating that you have hit the rate limit. It is important to implement retry logic in your application to handle these errors gracefully.

Other common errors include 401 for invalid keys and 402 for insufficient credit. A 401 error means that the API key you are using is invalid or has been revoked. A 402 error indicates that your account does not have enough credit to process the request. In both cases, you should check your account status and API key to resolve the issue.

Errors and refusals are free, which means you do not pay for failed requests. This is beneficial when you are testing different prompts or when the model refuses to generate content due to its internal filters. You can experiment freely without worrying about additional costs.

Understanding these limits and errors is important for building a reliable application. By monitoring your usage and implementing proper error handling, you can ensure a smooth experience for your users. It is also a good practice to log these errors for debugging and analysis purposes.

When Our API Is Not the Right Choice

While our API is excellent for uncensored text generation, it may not be the right choice for every project. If you need multimodal capabilities such as image generation, audio processing, or video creation, our API does not support these features. Our service is strictly text-in, text-out, so you will need to look elsewhere for these additional capabilities.

Similarly, if you require fine-tuning of the model to customize its behavior for your specific domain, our API does not offer fine-tuning options. You can use the provided parameters to influence the output, but you cannot train the model on your own data. If fine-tuning is a critical requirement for your project, you may need to consider other providers.

Another consideration is the lack of an SLA (Service Level Agreement) or certifications such as SOC2, HIPAA, or ISO. If your project requires strict compliance with these standards, our API may not meet your needs. We do not claim to have these certifications, so it is important to evaluate this based on your specific requirements.

Finally, if you need a model that is specifically optimized for a particular language or domain, our uncensored model may not be the best fit. While it is versatile, it is a general-purpose model. If you have highly specialized needs, you might find better results with a domain-specific model from another provider.

Common Developer Questions

Developers often ask about the differences between our API and other popular options. One common question is how our uncensored model compares to others in terms of performance and cost. While we do not claim to be the fastest or the cheapest, our model offers a unique balance of flexibility and control. We encourage you to check the documentation of other vendors for their current prices and limits to make an informed comparison.

Another frequent question is about the stability of the API. Our API is hosted and designed for reliability, but like any service, it may experience occasional downtime. We do not guarantee specific uptime percentages, so it is important to build your application with fault tolerance in mind. This includes handling errors gracefully and retrying failed requests.

Developers also inquire about the ease of integration. Our API follows the OpenAI-compatible format, which means you can likely use existing SDKs and tools with minimal modifications. This compatibility reduces the learning curve and allows you to integrate our service quickly into your existing workflow.

Lastly, many developers ask about the support for streaming. Our API supports streaming over SSE (Server-Sent Events), which allows you to receive the response in chunks as it is generated. This is useful for real-time applications where you want to display the output to the user as it is being generated, improving the perceived performance of your application.

Optimizing Your Usage

To optimize your usage, start by analyzing your prompts. Look for opportunities to shorten them without losing context. This can significantly reduce input token costs. Additionally, use the stop parameter to prevent the model from generating unnecessary text. This helps in controlling the output length and reducing output token costs.

Experiment with different parameters such as temperature, top_p, and seed to find the right balance between creativity and consistency. Lower temperatures produce more deterministic outputs, while higher temperatures introduce more randomness. Adjusting these parameters can help you achieve the desired tone and style for your content.

Monitor your token usage regularly to identify any anomalies or spikes. This can help you detect issues early and take corrective action. Use the usage information provided in the last chunk of the streaming response to track your consumption in real-time.

Finally, consider using the JSON mode if you need structured output. This can simplify parsing the response in your application and ensure that the output is in the expected format. By using these features, you can make the most of our API and build efficient, cost-effective applications.

Frequently asked questions

How do I calculate the cost of a request?

Multiply the input tokens by $0.15 per million and the output tokens by $0.50 per million. Sum these values to get the total cost for that request. Errors and refusals do not incur any charge.

What happens if I run out of credit?

You will receive a 402 error indicating insufficient credit. You can top up your account with USDT on TRC20 or USDC on Base to resume using the API. The prepaid credit never expires.

Can I use the API for image generation?

No, our API is strictly text-in, text-out. It does not support image, audio, or video generation. If you need multimodal capabilities, you may need to use a different service.

Is there a free trial available?

Yes, every new account receives $0.50 of trial credit without needing a credit card. This allows you to test the API before making a purchase.