EN ▾
Start with free creditsUse email and password; your key appears instantly.

Uncensored OpenAI-Compatible API

Create key

OpenRouter Rate Limit Safety Checklist

Developers often worry about unexpected charges when scaling applications. This article outlines safety risks and a troubleshooting approach to ensure your integration stays within safe operational bounds.

Server rack with green lights representing API stability

Understanding Rate Limits and Costs

When you integrate an API into your application, understanding the rate limits is important for maintaining stability. Our API enforces a limit of 300 requests per minute per key. This means that if your application sends more than 300 requests in a single minute, you will encounter a 429 error. It is important to monitor your request volume to ensure you stay within this bound.

Cost management is equally important. Our API charges $0.15 per 1 million input tokens and $0.50 per 1 million output tokens. These rates are prepaid, and you pay only for real token usage. Errors and refusals do not incur charges, which helps in managing your budget effectively. You can top up your account with crypto, such as USDT on TRC20 or USDC on Base, with amounts ranging from $20 to $500.

It is essential to keep track of your token consumption. By monitoring the tokens used in each request, you can estimate your costs accurately. This approach helps you avoid surprise bills and ensures that your application runs smoothly without exceeding your budget. Always check the current rates on our site for the most up-to-date information.

Additionally, our API supports streaming over Server-Sent Events (SSE), which allows you to receive usage information in the last chunk of the response. This feature can help you track token usage in real-time, making it easier to adjust your application's behavior based on the current load and cost.

Handling Errors and Refusals

When integrating with any API, errors are inevitable. Our API returns specific error codes to help you diagnose issues. A 401 error indicates an invalid key, which means you need to check your authentication credentials. A 402 error signals that you have no credit left, requiring you to top up your account. A 429 error means you have hit the rate limit, and you should slow down your request rate.

It is important to handle these errors gracefully in your application. For example, you can implement a retry mechanism with exponential backoff for 429 errors. This ensures that your application does not overwhelm the API during peak usage times. For 401 errors, you should verify your API key and ensure it is correctly included in the request headers.

Refusals are also a part of the integration process. Our API has a hard content limit regarding sexual content involving minors. Requests that violate this limit are refused without charge. This helps in maintaining a safe environment for users. You should design your application to handle these refusals appropriately, perhaps by notifying the user or logging the event for further analysis.

By understanding and handling these errors correctly, you can ensure a smoother user experience. It is also beneficial to log these errors for debugging purposes. This allows you to identify patterns and optimize your integration over time. Always refer to the API documentation for the most accurate and detailed information on error handling.

Optimizing Token Usage

Token usage is a key factor in determining the cost of your API calls. Our API has a context window of 100,000 tokens, which includes both the prompt and the completion. It is important to manage this window efficiently to avoid unnecessary costs. You can optimize your prompts by removing irrelevant information and focusing on the most essential parts.

Using parameters like temperature, top_p, and stop sequences can help control the output length and quality. For example, setting a lower temperature value can produce more deterministic results, which might reduce the need for multiple retries. Similarly, using stop sequences can prevent the model from generating excessive text, thus saving tokens.

JSON mode is another feature that can help in optimizing token usage. By requesting JSON output, you can ensure that the response is structured and easy to parse. This can reduce the need for additional processing on your end, making your application more efficient. It is also useful for integrating with other systems that expect structured data.

Monitoring your token usage regularly can help you identify areas for improvement. You can use the usage information provided in the streaming responses to track your consumption. This data can be used to adjust your application's behavior and optimize your costs. Always aim to strike a balance between quality and efficiency in your API calls.

Safety Risks in Scaling

As your application scales, the risk of unexpected charges increases. It is important to implement safeguards to prevent this. One effective strategy is to set up alerts for high token usage. This can help you detect unusual activity early and take corrective action before the costs spiral out of control.

Another risk is the potential for infinite loops in your application logic. If your application continuously sends requests without proper error handling, it can quickly exhaust your credit. Implementing a maximum retry limit and a timeout for each request can help mitigate this risk. This ensures that your application does not get stuck in a loop and consumes excessive tokens.

It is also important to consider the security of your API key. If your key is exposed, unauthorized users can make requests on your behalf, leading to unexpected charges. Store your key securely and use environment variables to manage it. Regularly rotate your keys to minimize the risk of compromise.

Finally, keep an eye on the rate limits. If your application sends too many requests in a short period, you may hit the 300 requests per minute limit. This can cause your application to slow down or fail. Implementing a queue system can help manage the request rate and ensure that your application stays within the limits.

When Our API Is Not the Right Choice

While our API is designed for text-based interactions, it may not be the right choice for all use cases. If you need image, audio, or video generation, our API does not support these capabilities. It is a text-in, text-out service, so applications requiring multimodal outputs should look for other solutions.

Similarly, if you need embeddings, OCR, or fine-tuning, our API does not offer these features. It is an uncensored open-weight text model, so it is best suited for applications that require flexible and unrestricted text generation. If you need a model that can be fine-tuned for specific tasks, you may need to consider other options.

Another consideration is the context window. Our API has a context window of 100,000 tokens, which is quite large but may not be sufficient for extremely long documents or conversations. If you need a larger context window, you should evaluate other providers that offer this feature.

Finally, if you require an SLA or certifications such as SOC2 or HIPAA, our API does not provide these guarantees. It is an independent service, and while it is reliable, it does not offer the same level of enterprise-grade assurances as some larger providers. For applications with strict compliance requirements, you may need to consider other options.

Addressing Community Concerns

Developers often discuss rate limits and costs in online communities. For instance, on r/ClaudeAI, users have shared their experiences with using OpenRouter for various projects. They mention making content with specific models and discuss the costs involved. These discussions highlight the importance of monitoring token usage and understanding the pricing model.

On r/LocalLLaMA, there have been discussions about other providers like CrofAI, which has been exposed as a wrapper around OpenRouter. Users have raised concerns about markups and the true cost of using these services. This underscores the value of using a direct provider like our API, where you pay for the actual token usage without hidden markups.

There have also been discussions about the acquisition of OpenRouter by Stripe. Users have expressed mixed feelings about this development, with some concerned about potential changes in pricing and service quality. It is important to stay informed about such developments and evaluate how they might affect your integration.

Additionally, users have discussed the introduction of new models like LongCat-2.0. These discussions often focus on the capabilities and performance of these models. While our API does not offer these specific models, it provides a reliable and uncensored text model that can be used for a wide range of applications. It is always beneficial to stay updated on the latest developments in the AI community.

Troubleshooting and Best Practices

Troubleshooting API issues requires a systematic approach. Start by checking your API key and ensuring it is correct. If you encounter a 401 error, verify that the key is being sent in the request headers. If the error persists, try generating a new key and updating your application.

For 402 errors, check your account balance and ensure you have sufficient credit. If you need to top up, you can do so using crypto. Our API accepts USDT on TRC20 or USDC on Base, with a minimum amount of $20. After topping up, verify that the credit is reflected in your account.

For 429 errors, implement a retry mechanism with exponential backoff. This helps in handling rate limits gracefully and prevents your application from overwhelming the API. You can also monitor your request rate and adjust it based on the current load.

Finally, use the streaming feature to monitor token usage in real-time. This can help you detect any unusual activity and take corrective action. By following these best practices, you can ensure that your integration runs smoothly and efficiently. Always refer to the API documentation for the most accurate and detailed information.

Frequently asked questions

How do I check my API key?

You can find your API key in your account dashboard after signing up. It is shown immediately upon registration. If you encounter a 401 error, verify that the key is correctly included in your request headers.

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 crypto, such as USDT on TRC20 or USDC on Base. The minimum top-up amount is $20, and the credit never expires.

Can I use this API for image generation?

No, our API is a text-in, text-out service. It does not support image, audio, or video generation. If you need multimodal capabilities, you should look for other providers that offer these features.

How do I handle rate limits?

Our API enforces a limit of 300 requests per minute per key. If you hit this limit, you will receive a 429 error. You can implement a retry mechanism with exponential backoff to handle this gracefully.