EN ▾
Get API key

Troubleshooting Connection Errors and API Rate Limits

Moving from local inference to a hosted endpoint often introduces new failure modes that do not exist when running models on your own hardware. This guide helps you diagnose common connection risks and adjust your client settings for stable, uncensored text generation.

Server rack with data streams and API error codes

Understanding HTTP Error Codes

When you migrate from a local environment to a remote service, the first thing you will notice is that errors are no longer silent crashes. Our API returns specific HTTP status codes that tell you exactly what went wrong. The most common codes you will encounter are 401, 402, and 429. A 401 error means your API key is invalid or missing. A 402 error indicates that you have run out of prepaid credit. A 429 error signals that you have exceeded the rate limit.

It is important to read these codes carefully because they dictate your next step. If you receive a 401, check that you are sending the correct key in the authorization header. If you see a 402, you need to add more credit using cryptocurrency. If you hit a 429, you must slow down your request rate. These codes are not vague; they are precise instructions for fixing your integration.

Unlike local models where a crash might just stop your script, remote APIs give you feedback. You can log these codes and build logic to handle them gracefully. For example, you might pause your application for a few seconds when you see a 429. This approach turns potential failures into manageable events in your workflow.

Always check the response body for additional details. While the status code tells you the category of the error, the message might explain if the key is expired or if the credit balance is exactly zero. This precision allows you to fix issues quickly without guessing what went wrong.

Handling Rate Limits and Throttling

Our API allows 300 requests per minute per key. This limit is generous for most applications, but it can be hit quickly if you are sending many concurrent requests or if your application loops without delay. When you exceed this limit, you will receive a 429 error. This is not a punishment; it is a mechanism to ensure stable performance for all users.

To avoid hitting the rate limit, you should implement exponential backoff in your client code. This means that if you receive a 429, you wait for a short period, then try again. If you fail again, you wait longer. This approach prevents your application from spamming the server and helps you recover smoothly when the rate limit resets.

You can also monitor your usage by checking the response headers or the last chunk of streaming data. This helps you understand how close you are to the limit. If you are building a high-throughput application, you might need to distribute your requests across multiple keys or pace your output generation.

Remember that the rate limit is per key, not per account. If you have multiple keys, you can split your load. However, each key has its own 300 requests per minute limit. This flexibility allows you to scale your application without hitting a hard ceiling too quickly.

Configuring Timeouts and Retries

Network latency can cause timeouts, especially when your application is far from the server hosting our API. If your client waits too long for a response, it will give up and throw a timeout error. This is common when moving from local models, where latency is near zero, to remote services.

You should configure your client to handle timeouts gracefully. Set a reasonable timeout value, such as 30 seconds, and allow for retries. If a request times out, it might be due to a temporary network issue or server load. Retrying the request can often resolve the issue without manual intervention.

It is important to distinguish between a timeout and a rate limit. A timeout means the server did not respond in time. A rate limit means the server rejected your request because you sent too many. Both require different handling strategies. Timeouts need retries; rate limits need pacing.

By configuring your client to handle these errors properly, you ensure that your application remains stable even when the network is unreliable. This is a key difference between local and remote inference, and mastering it is essential for a reliable integration.

Diagnosing Connection Risks

When you move from local to remote, you introduce new points of failure. Network congestion, DNS issues, and server maintenance can all affect your connection. It is important to monitor your connection health and have a plan for when things go wrong.

One common issue is DNS resolution failure. If your domain name cannot be resolved, your request will fail before it even reaches the server. Check your DNS settings and ensure that your application can resolve the API endpoint. This is a simple check that can save you hours of debugging.

Another risk is SSL certificate errors. If your client does not trust the certificate authority that issued the API's certificate, the connection will be rejected. Ensure that your client trusts the root certificates used by the API. This is usually a one-time configuration step.

Finally, consider the impact of your own network environment. If you are using a public Wi-Fi network, you might experience higher latency or packet loss. Test your integration in different network conditions to ensure it is reliable. This helps you identify issues before they affect your users.

What Reddit Users Are Asking

Threads on r/LocalLLaMA often discuss the transition from local models to remote services. Users frequently ask why they are experiencing more errors and timeouts when switching to a hosted endpoint. They compare the simplicity of running a model locally with the complexity of managing API connections.

Many users note that local models give them full control over the environment, while remote services introduce external dependencies. They ask how to handle rate limits and what to do when the API is slow. The consensus is that remote services require more careful client configuration.

Some users also discuss the cost implications of moving to a remote service. They want to know how to estimate token usage and budget for API calls. Our API offers prepaid credit, which helps users control their spending. You can start with a trial credit to test the integration without any financial commitment.

Overall, the community is looking for practical advice on debugging and optimization. They want to know how to make their applications more resilient. This guide provides the tools to do just that, helping you move from local to remote with confidence.

When Our API Is Not the Right Choice

While our API is powerful for text generation, it is not the right choice for every project. If you need image generation, audio processing, or video synthesis, this API will not meet your needs. It is a text-only service, so you cannot generate multimedia content directly.

Similarly, if you require fine-tuning your own model, our API does not support that feature. You can use the API to generate text, but you cannot train a new model through it. If you need to customize the model's behavior through training, you will need a different service.

Another limitation is the lack of embeddings. If you need to convert text into vector representations for search or recommendation systems, this API does not provide that capability. You will need to use a separate embedding service or model.

Finally, if you need on-premises deployment for data privacy, our hosted API might not be suitable. All data is processed on our servers. If you need to keep your data within your own infrastructure, you will need a self-hosted solution. Be honest about your requirements and choose the right tool for the job.

Optimizing Your Integration

To get the most out of our API, you should optimize your integration for performance. This includes using streaming responses to reduce perceived latency and implementing efficient retry logic. Streaming allows you to start displaying text to the user as soon as it is generated, rather than waiting for the entire response.

You should also use the correct parameters for your use case. For example, setting the temperature to zero will make the output more deterministic, while a higher temperature will make it more creative. Experiment with these parameters to find the best balance for your application.

Monitor your usage closely to avoid unexpected charges. You can track your token usage and adjust your rate limits accordingly. This helps you stay within your budget and ensures that your application runs smoothly.

Finally, keep your client library up to date. New versions may include bug fixes and performance improvements. By staying current, you can take advantage of the latest features and ensure that your integration is reliable and reliable.

Frequently asked questions

What does a 429 error mean?

A 429 error means you have exceeded the rate limit of 300 requests per minute per key. You should slow down your request rate or implement exponential backoff to handle this error gracefully.

How do I fix a 401 error?

A 401 error indicates that your API key is invalid or missing. Check that you are sending the correct key in the authorization header and that the key has not been revoked or expired.

Does the API support image generation?

No, the API is text-only. It does not support image, audio, or video generation. If you need multimedia capabilities, you will need to use a different service or combine this API with other tools.

How much does the API cost?

The API costs $0.15 per 1M input tokens and $0.50 per 1M output tokens. You can start with $0.50 of trial credit, and you can top up with USDT on TRC20 or USDC on Base.