EN ▾

Uncensored API. No refusals. Pay by token.

Modeluncensored

Last updated2026-10-30

Base URLhttps://api.groqaiapikey.com/v1

Start now

Integrating Groq AI API Key with React Frontends

Developers often seek a straightforward way to add AI capabilities to their React interfaces without complex backend infrastructure. This guide outlines how to integrate our uncensored text API directly into client-side applications using standard web technologies. We focus on secure key management, proper request formatting, and handling responses efficiently.

Developer workspace with laptop showing React code connected to server rack

Understanding the API Integration Context

Integrating an AI API into a React frontend requires a clear understanding of how data flows between the browser and the server. Our service provides a hosted, OpenAI-compatible interface that accepts text and returns text. The base URL for all requests is https://api.groqaiapikey.com/v1. This simplicity allows developers to bypass complex backend logic for simple text generation tasks.

Unlike many competitors, our API does not support embeddings, image generation, or audio processing. It is strictly a text-in, text-out service. This focus means you do not need to handle binary data streams or large file uploads. The model identifier you must send is simply uncensored. This identifier tells the system to use our specific open-weight model which does not refuse lawful adult, fictional, or controversial topics.

When building your React application, you will interact with three main endpoints. The primary endpoint is POST /v1/chat/completions for generating responses. You can also use POST /v1/responses for alternative response formats and GET /v1/models to verify available configurations. Keeping your integration focused on these text-based endpoints ensures compatibility with our current feature set.

It is important to note that our API serves one specific model. You do not need to route requests to different models based on complexity. This reduces the decision-making overhead for your frontend code. The context window for this model is 100,000 tokens, allowing for substantial input and output in a single conversation. This large window is beneficial for applications that need to maintain long-term context without frequent resets.

Securely Managing API Keys in React

One of the most critical aspects of integrating an API key in a React application is security. Since React applications run in the user's browser, your API key is exposed to the client. To mitigate risks, you should store your key in environment variables. Create a file named .env in the root of your project and add your key there. This prevents the key from being committed to your version control system.

In your React components, access the key using process.env.REACT_APP_API_KEY. This variable holds the string value of your key. You can then include this key in the header of your HTTP requests. The header name is typically Authorization with the value Bearer followed by your key. This method ensures that the key is available to your fetch calls without hardcoding it into your component files.

When you sign up for an account, you can continue with Google or use an email and password. The key is shown immediately after signup. It is important to copy this key and store it in your environment file. If you lose the key, you may need to generate a new one. The key is tied to your prepaid credit, so losing it does not lose your funds, but it requires reconfiguration of your app.

Remember that our API charges by real token usage. Errors and refusals are free. This means that even if your frontend code makes a request that results in an error, you are not charged. However, you should still monitor your usage to avoid unexpected costs. The prepaid credit never expires, so you can top up as needed without worrying about monthly fees.

Constructing Chat Completion Requests

To generate text, you send a POST request to /v1/chat/completions. The request body must include the model, messages, and other parameters. The model field should be set to uncensored. The messages field is an array of objects, each containing a role and content. The role can be system, user, or assistant. This structure allows you to define the conversation history and the current prompt.

You can also specify parameters such as temperature, top_p, stop, and seed. The temperature controls the randomness of the output. A higher value makes the output more creative, while a lower value makes it more deterministic. The top_p parameter controls the diversity of the output by filtering tokens based on their probability. The stop parameter allows you to define sequences that terminate the response. The seed parameter ensures reproducibility of the output.

Our API supports streaming over Server-Sent Events (SSE). This feature allows you to receive responses in chunks as they are generated. This is particularly useful for real-time applications where you want to display text as it is being typed. The usage information is included in the last chunk of the stream. This allows you to track token usage without waiting for the entire response.

When constructing your requests, ensure that you handle the response correctly. The response will be a stream of data. You need to parse this data to extract the text content. This can be done using the ReadableStream API in JavaScript. By processing the stream, you can update the UI incrementally, providing a smooth user experience.

Handling Responses and Streaming Data

Handling streaming responses in React requires a careful approach to state management. When you initiate a request, you should set a loading state to indicate that the response is being generated. As chunks of data arrive, you append them to the current response text. This creates the effect of real-time typing. It is important to update the state efficiently to avoid unnecessary re-renders.

The API returns usage information in the final chunk of the stream. This chunk includes the number of input and output tokens. You can use this information to update your credit balance or display usage statistics to the user. Since errors and refusals are free, you do not need to worry about being charged for failed requests. However, you should still handle errors gracefully in your code.

If the API returns an error, such as a 401 for an invalid key or a 402 for insufficient credit, you should display an appropriate message to the user. A 429 error indicates that you have exceeded the rate limit of 300 requests per minute. In this case, you may need to implement a backoff strategy to retry the request after a delay. This ensures that your application does not overwhelm the API.

It is also important to handle cases where the user stops the generation process. You can abort the fetch request using an AbortController. This cancels the ongoing request and frees up resources. By implementing proper error handling and abort mechanisms, you can create a reliable and responsive user interface.

When Our API Is Not the Right Choice

While our API is excellent for text generation, it may not be the right choice for all projects. Our service is strictly text-based. If your application requires image generation, audio processing, or video creation, our API will not meet your needs. You would need to integrate with a different provider that offers these multimedia capabilities.

Additionally, our API does not support embeddings. If your application relies on vector search or semantic similarity, you will need to handle embeddings separately. This might involve using a different API for embedding generation and then sending those vectors to your database. This adds complexity to your architecture but is necessary if you need advanced search features.

Our API also does not offer fine-tuning. If you need to train a model on your specific dataset, you will need to look for a provider that supports fine-tuning. Our service uses a single uncensored model, so you cannot customize the model behavior beyond the parameters provided. This is a trade-off for the simplicity and speed of our service.

Finally, if you need on-premises deployment or specific SLA guarantees, our hosted service may not fit your requirements. We do not offer on-prem deployment or certified SLAs. For applications with strict data residency or uptime requirements, you might need to consider a different solution. Always evaluate your specific needs before committing to a provider.

Addressing Common Developer Questions

Developers often ask how to securely connect their API keys to React frontends without exposing secrets. The key is to use environment variables and avoid hardcoding the key in your source code. This ensures that the key is not visible in your version control history. You can also use a backend proxy to hide the key from the client, but this adds complexity.

Another common question is how to handle streaming responses in React. The best approach is to use the ReadableStream API to process the data chunk by chunk. This allows you to update the UI in real-time as the text is generated. You should also handle errors and abort signals to ensure a smooth user experience.

Users also inquire about the cost structure and payment methods. Our API charges $0.15 per 1 million input tokens and $0.50 per 1 million output tokens. You can top up your balance using crypto, specifically USDT on TRC20 or USDC on Base. The minimum top-up amount is $20, and the maximum is $500. There is no monthly fee, and your credit never expires.

Finally, developers often ask about the model capabilities. Our model is uncensored, meaning it does not refuse lawful adult, fictional, or controversial topics. However, it does refuse sexual content involving minors. This makes it suitable for a wide range of applications, from creative writing to customer support. Always review the content policy to ensure it aligns with your application's needs.

Best Practices for Production Deployment

When deploying your React application to production, ensure that your environment variables are properly configured. Use a build tool to inject the variables into your code. This ensures that the key is available at runtime. You should also minify your code to reduce the size of the bundle. This improves load times and performance.

Monitor your API usage closely. Since you are charged by token usage, it is important to track how many tokens your application consumes. You can use the usage information provided in the streaming responses to calculate costs. This helps you budget effectively and avoid unexpected charges. Remember that errors and refusals are free, so you do not need to worry about failed requests.

Implement rate limiting in your application to prevent abuse. Our API allows 300 requests per minute per key. If you exceed this limit, you will receive a 429 error. You can implement a queue system in your React app to manage requests and ensure that you stay within the limit. This ensures a consistent experience for your users.

Finally, keep your dependencies up to date. React and its ecosystem evolve rapidly, so it is important to use the latest versions of your libraries. This ensures compatibility with the API and improves security. Regularly review your code for potential vulnerabilities and update your dependencies accordingly. This helps maintain a stable and secure application.

Frequently asked questions

How do I securely store my API key in a React app?

Store your key in a .env file and access it via process.env.REACT_APP_API_KEY. This keeps it out of your version control system. You can then include it in the Authorization header of your fetch requests.

What is the model ID for the uncensored model?

The model ID is simply 'uncensored'. You send this string in the model field of your POST request to /v1/chat/completions. This selects our specific open-weight text model.

Can I use this API for image generation?

No, our API is text-only. It does not support image, audio, or video generation. If you need multimedia capabilities, you will need to integrate with a different provider.

How do I pay for API usage?

You can top up your balance using crypto, specifically USDT on TRC20 or USDC on Base. The minimum amount is $20, and the maximum is $500. There are no monthly fees, and your credit never expires.