EN ▾
Get API key

Troubleshooting Gemma NSFW API Integration

Integrating an uncensored text model requires careful handling of API limits and error states. This guide addresses common integration errors, safety risks, and how to choose the right approach for your workflow.

Developer workspace with holographic text stream and crypto wallet icon for Gemma NSFW API

Understanding API Errors and Retries

When integrating with our API, you will encounter specific HTTP status codes that indicate the state of your request. The most common errors are 401, 402, and 429. A 401 error means your API key is invalid or missing. A 402 error indicates you have no credit left. A 429 error signals that you have hit the rate limit of 300 requests per minute. These errors are distinct and require different handling strategies in your code.

For 401 errors, check your key immediately. Ensure you are sending the correct key in the Authorization header. If the key is correct, verify that you have not accidentally rotated it. For 402 errors, you need to top up your account. Since we only accept crypto, you must use USDT on TRC20 or USDC on Base. The minimum top-up is $20, and the maximum is $500. You can also get a bonus if you top up $50 or more.

Rate limits are strict but predictable. You have 300 requests per minute per key. If you hit this limit, your requests will be rejected with a 429 status. You should implement exponential backoff in your retry logic. Wait a few seconds before retrying. This prevents you from overwhelming the server and wasting credits on failed requests. Always check the response body for details on when the limit resets.

Errors and refusals are free, which is a key feature. If the model refuses a request due to the hard content limit, you do not lose tokens. This is useful for testing safety filters. However, the model does not refuse lawful adult or controversial topics. So, most requests will go through. Just ensure you handle the 402 error gracefully to avoid unexpected charges.

Managing the Context Window

The context window for this API is 100,000 tokens. This includes both the prompt and the completion. This is a large window, but it is not infinite. You need to manage your tokens carefully to avoid truncation. If your input plus output exceeds 100,000 tokens, the model may cut off the response. This can lead to incomplete or confusing outputs.

To manage this, you should track the token count in your application. You can estimate the token count by dividing the number of characters by four. This is a rough estimate. For precise counts, use a tokenizer library. Keep an eye on the usage field in the last chunk of streaming responses. This gives you the total tokens used so far.

If you are building a chat application, you need to store the history. Each message in the history consumes tokens. As the conversation grows, the prompt size increases. You may need to truncate older messages to make room for new ones. This is a common trade-off. You lose some context, but you keep the conversation flowing.

Remember that the context window is shared. Both input and output tokens count towards the limit. If you send a long prompt, you have less room for the response. Plan your prompts accordingly. Short, concise prompts are better for long conversations. This helps you stay within the 100,000 token limit and ensures consistent performance.

Payment and Credit Management

Our API uses a prepaid credit system. You pay for tokens used, not for subscriptions. The price is $0.15 per million input tokens and $0.50 per million output tokens. This is charged by real token usage. Errors and refusals are free, so you do not pay for failed requests. This is a fair model for developers who want to test their integrations.

To add credit, you must use crypto. We accept USDT on the TRC20 network or USDC on the Base network. You can top up any whole amount between $20 and $500. If you top up $50 or more, you get a bonus of 5% to 15%. This bonus is added to your balance immediately. You can use this bonus for any request, including streaming or function calling.

There are no monthly fees or subscriptions. Your credit never expires. This is a significant advantage for indie developers and small teams. You only pay when you use the API. There is no risk of paying for a subscription you do not need. However, you must manage your credit carefully. If you run out, you get a 402 error. You cannot use the API until you top up.

Never claim that we accept cards or PayPal. We only accept crypto. This is a hard limit. If you need to use a card, you must use a crypto on-ramp. This adds a step to your workflow, but it also gives you privacy. You do not need to provide personal information to top up. Just send the crypto to the address provided on the site.

Handling Uncensored Output and Safety

The model is uncensored, meaning it does not refuse lawful adult, fictional, or controversial topics. This is useful for creative writing, roleplay, and security research. However, it also means you need to handle the output carefully. The model may generate content that is not suitable for all audiences. You should implement your own safety filters if needed.

The only hard limit is on sexual content involving minors. Requests with such content are refused. This is a legal requirement. The model will not generate images or audio, so this is the only content filter. You can use the stop parameter to control the output. This helps you avoid unwanted content.

When integrating, you should test the output with a variety of prompts. Check for consistency and quality. The model is open-weight, so it may behave differently than closed models. This is expected. You should adapt your application to handle these differences. Do not assume the model will always behave the same way.

Remember that the model is text-only. It does not generate images, audio, or video. If you need multimedia, you must use another tool. This API is for text in and text out. Keep this in mind when designing your workflow. You can use the output of this API as input for other tools. This creates a flexible and powerful system.

When This API Is Not the Right Choice

This API is not the right choice if you need image, audio, or video generation. It is also not suitable if you need embeddings, OCR, or fine-tuning. The model is text-only. If you need to process images or audio, you must use a different tool. This API is for text workflows only.

If you need a model with a specific benchmark score, this API may not be the best fit. We do not claim any benchmark scores. The model is uncensored and open-weight. This means it may not perform as well as closed models in some tasks. You should test the model with your specific use case to see if it meets your needs.

If you need on-prem deployment, this API is not the right choice. It is a hosted service. You send requests to our server, and we return the response. You do not have control over the server. This is a trade-off for ease of use. If you need full control over the model, you may need to deploy it yourself.

Finally, if you need a free unlimited tier, this API is not the right choice. We have a prepaid credit system. You pay for tokens used. There is no free unlimited tier. However, you get $0.50 of trial credit when you sign up. This is enough to test the API. If you need more, you must top up. This is a fair model for developers who want to test the API before committing.

Integrating with Streaming and Tools

Our API supports streaming over SSE. This allows you to receive the response in chunks. This is useful for real-time applications. You can display the response as it is generated. This improves the user experience. The usage is included in the last chunk. This allows you to track token usage in real-time.

You can also use function calling with tools. This allows the model to call functions in your code. This is useful for complex workflows. You can define tools in your request, and the model will return the tool calls. You can then execute the tools and return the results to the model. This creates a powerful loop.

JSON mode is also supported. This allows you to get structured output from the model. This is useful for parsing the response. You can specify the JSON schema in your request. The model will return the response in the specified format. This makes it easier to integrate with your code.

You can also set parameters like temperature, top_p, stop, and seed. These parameters control the behavior of the model. Temperature controls the randomness. Top_p controls the diversity. Stop controls the stopping condition. Seed controls the reproducibility. Use these parameters to fine-tune the model for your specific use case.

Common Integration Pitfalls

One common pitfall is not handling the 402 error correctly. If you run out of credit, your requests will fail. You need to check for this error and top up your account. This is a simple step, but it is easy to forget. Make sure you have a process for monitoring your credit balance.

Another pitfall is not managing the context window. If you send too many tokens, you may hit the limit. This can lead to truncation. Make sure you track the token count and truncate older messages if needed. This is a common issue in chat applications. Plan your workflow to avoid this.

Finally, do not assume the model is perfect. It is uncensored and open-weight. This means it may generate unexpected output. Test your integration thoroughly. Check for consistency and quality. Adapt your application to handle these differences. This will help you build a reliable and reliable system.

Frequently asked questions

How do I top up my account?

You can top up using USDT on TRC20 or USDC on Base. The minimum amount is $20, and the maximum is $500. You get a bonus if you top up $50 or more.

What happens if I hit the rate limit?

You will get a 429 error. You should implement exponential backoff in your retry logic. Wait a few seconds before retrying to avoid overwhelming the server.

Is the model uncensored?

Yes, the model does not refuse lawful adult, fictional, or controversial topics. The only hard limit is on sexual content involving minors. This is useful for creative writing and roleplay.

Can I use this API for image generation?

No, this API is text-only. It does not generate images, audio, or video. If you need multimedia, you must use a different tool.