EN ▾
Start now

GLM API Key Cost Estimator: Budget for Your Use Case

Developers often ask how to predict monthly spend before committing to a plan. This article provides a calculation method using our specific per-million-token rates to help you budget accurately.

Developer desk with laptop showing code and token counter for GLM API cost estimation

Understanding Our Pricing Structure

This site is an independent service and is not affiliated with Zhipu AI.

When planning your budget for an uncensored open-weight text model, the first step is understanding how our API charges for usage. We operate on a prepaid credit system where you pay only for what you use. There are no monthly subscriptions or hidden fees, which makes it easy to control your spending. The base URL for our API is https://api.glmkey.com/v1, and you can send requests to endpoints like POST /v1/chat/completions or POST /v1/responses.

The pricing model is straightforward: you are charged $0.15 per 1 million input tokens and $0.50 per 1 million output tokens. This means that the cost depends entirely on the volume of text you send to the model and the volume of text the model generates in response. Since we serve one uncensored model, the id for which is "uncensored", you do not need to worry about different pricing tiers for different model versions.

It is important to note that errors and refusals are free. If your request fails due to a network issue or if the model refuses a request due to our hard content limit on sexual content involving minors, you are not charged for those tokens. This feature helps protect your budget from unexpected costs during testing or when dealing with edge cases in your application logic.

Our API supports a context window of 100,000 tokens, which includes both the prompt and the completion together. This large context window allows you to process substantial amounts of text in a single request, which can be more cost-effective than making multiple smaller requests. However, you must still account for the total token count when estimating your costs.

Calculating Input and Output Costs

To estimate your monthly spend, you need to calculate the total number of tokens you will send and receive. Start by determining the average length of your prompts. If your average prompt is 1,000 tokens, and you make 10,000 requests per month, your total input tokens would be 10,000,000. Using our rate of $0.15 per 1 million input tokens, the cost for input tokens would be calculated as (10,000,000 / 1,000,000) * $0.15.

Next, consider the average length of the model's responses. If the model generates an average of 500 tokens per response, your total output tokens for 10,000 requests would be 5,000,000. The cost for output tokens is calculated using the rate of $0.50 per 1 million output tokens. So, the cost would be (5,000,000 / 1,000,000) * $0.50.

By adding these two costs together, you get a clear picture of your monthly expenditure. This method allows you to adjust your budget based on changes in usage patterns. For example, if you increase the number of requests or the length of prompts, you can easily recalculate your expected costs.

Remember that our API supports streaming over SSE, which can be useful for real-time applications. The usage information is provided in the last chunk of the stream, allowing you to track token usage in real-time. This feature can help you monitor your spending as it happens, ensuring you stay within your budget.

Budgeting for Different Use Cases

Different use cases will have varying token requirements, which affects your budget. For instance, if you are using our API for code generation, your prompts might be shorter, but the responses could be longer due to the detailed nature of code. In this scenario, you might find that the output token costs are higher than the input token costs.

On the other hand, if you are using the API for summarization, your prompts might be very long, while the responses are concise. In this case, the input token costs would dominate your budget. It is essential to analyze your specific use case to determine which component of the pricing model will have the greatest impact on your costs.

Another consideration is the use of function calling and JSON mode. These features allow you to integrate our API more deeply into your applications, but they may also increase the complexity of your prompts. Ensure that you account for any additional tokens required for tool definitions or JSON structures when estimating your costs.

Finally, consider the impact of parameters like temperature, top_p, and stop sequences. These parameters can affect the length and variability of the model's responses. By testing different configurations, you can find a balance between response quality and token usage, helping you optimize your budget for your specific needs.

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 developer. If you need embeddings, image generation, audio processing, or video generation, our API does not support these features. We serve only text in and text out, so if your project requires multimodal capabilities, you may need to look elsewhere.

Similarly, if you require fine-tuning of the model to fit your specific domain, our API does not offer this feature. You can use our API for inference, but you cannot fine-tune the model through our service. If fine-tuning is a critical part of your workflow, you might need to combine our API with other tools or services.

Additionally, if you need model routing to switch between different models based on performance or cost, our API does not support this. We serve one uncensored open-weight text model, so you will not have the flexibility to route requests to different models. If model routing is essential for your application, this limitation might affect your decision.

Finally, if you are looking for a free unlimited tier or a subscription-based model with guaranteed SLAs, our API might not fit your needs. We offer a prepaid credit system with no monthly fees, and we do not claim any SLA percentages. If you require strict uptime guarantees or a free tier, you may want to explore other options.

Addressing Common Questions from Developers

Developers often ask about issues related to API keys and endpoints. For example, some users have reported problems with Z.ai GLM API keys, where the service suddenly started working after emailing support or using the first key in their list. It is important to ensure you are using the correct endpoint for your specific plan. If you are using a coding plan, make sure you are hitting the right endpoint, such as the coding PaaS endpoint.

Another common question is about exchanging API keys. Some developers have proposed trading keys, but this can be risky. If you delete your key, you lose access, and the other party might do the same. It is generally safer to manage your own keys and avoid peer-to-peer exchanges unless you trust the other party completely.

Users have also mentioned that payment glitches can occur, especially during UI upgrades. If you experience issues, try deleting all keys and creating a new one, or contact support with your invoice. These steps often resolve temporary issues related to account status or payment processing.

Finally, some developers wonder if they can change their email to switch subscriptions. While this is possible, it is important to note that API keys can be deleted at any time, and no one can prevent you from doing so. This flexibility allows you to manage your access and costs effectively, but it also means you need to be vigilant about securing your keys.

Managing Your Prepaid Credit

Our API uses a prepaid credit system, which means you top up your account before using the service. You can top up with crypto only, specifically USDT on TRC20 or USDC on Base. The minimum top-up amount is $20, and the maximum is $500. There are no cards, PayPal, or bank transfer options available, so you must use one of these two cryptocurrencies.

One of the benefits of our prepaid system is that your credit never expires. You can top up whenever you need to, and the credit will remain in your account until you use it. This flexibility allows you to manage your budget according to your cash flow and usage patterns.

Additionally, we offer bonus credit for top-ups of $50 or more. The bonus ranges from +5% to +15%, depending on the amount you top up. This bonus can help you get more value for your money, especially if you are planning to use the API extensively.

It is important to keep track of your credit balance to avoid running out of funds unexpectedly. You can check your balance and usage details through your account dashboard. If you run out of credit, you will receive a 402 error, and you will need to top up again to continue using the API.

Signing Up and Getting Started

To get started with our API, you can sign up using your Google account or by creating an email and password. Once you sign up, you will receive an API key immediately, which you can use to make requests to our API. The key is shown right after signup, so you can start using it without delay.

Every new account gets $0.50 of trial credit, so you can test the API without needing to top up immediately. This trial credit allows you to explore the API's features, such as streaming, function calling, and JSON mode, before committing to a larger top-up.

Our API supports various parameters, including temperature, top_p, stop sequences, and seed. These parameters allow you to customize the behavior of the model to suit your needs. For example, you can use the seed parameter to ensure reproducibility of your results, which is useful for testing and debugging.

Finally, keep in mind that our API has a rate limit of 300 requests per minute per key. If you exceed this limit, you will receive a 429 error. Make sure to implement rate limiting in your application to avoid hitting this limit and disrupting your workflow.

Frequently asked questions

How do I calculate the cost of my API usage?

Multiply the total input tokens by $0.15 per 1 million, and the total output tokens by $0.50 per 1 million. Sum these values to get your total cost. Errors and refusals are free, so they do not add to your bill.

What happens if I run out of credit?

You will receive a 402 error indicating no credit. You can top up your account with USDT on TRC20 or USDC on Base to restore access. Your credit never expires, so you can top up whenever you need to.

Can I use cards or PayPal to top up?

No, we only accept crypto. You can top up with USDT on TRC20 or USDC on Base. The minimum top-up is $20, and the maximum is $500. There are no cards, PayPal, or bank transfer options.

Is there a free tier or subscription?

We do not have a free unlimited tier or a subscription model. You pay only for what you use with prepaid credit. New accounts get $0.50 of trial credit, but otherwise, you must top up to use the API.