Grok API Key: setup, costs and alternatives | grokapi.cc
A Grok API key is the credential that authenticates your requests to the model provider, but standard keys often come with strict content filters and usage limits. If you need an uncensored, text-only Grok API key that works with your existing OpenAI SDK code, you can use a drop-in alternative that bypasses refusals while maintaining simple token-based pricing.

Key points
- Standard Grok API keys are tied to specific vendor ecosystems with varying content policies.
- An uncensored Grok API key provides raw model output without refusals for lawful adult content.
- Our API uses the standard OpenAI-compatible format, requiring only a base URL and key change.
- Pricing is prepaid per token with no monthly fees, and credit never expires.
Invalid API Key Errors
When you receive a 401 Unauthorized error, it usually means the grok api key is missing, expired, or incorrectly formatted. This is distinct from a 403 Forbidden error, which indicates the key is valid but lacks permission for the specific endpoint or model.
Ensure you are passing the key in the Authorization header as Bearer <your_key>. A common mistake is including extra spaces or the Bearer prefix twice. If you generated a new key on the dashboard, verify that you are not using an old key from a previous session.
Another frequent cause is attempting to use a key in a different region or base URL than where it was provisioned. Our API key works exclusively with the specified base URL. If you switch environments, ensure the key is still active and not revoked.
If the error persists, check your account status on the dashboard. Keys can be revoked manually or due to unusual activity. There is no automatic renewal for keys; they remain valid until you delete them or they are manually revoked.
Rate Limit Exceeded (429)
A 429 Too Many Requests error occurs when you exceed the allowed number of requests within a given time window. Our API enforces a limit of 300 requests per minute per key and allows up to 8 concurrent requests at the same time. This is designed to prevent a single user from overwhelming the servers.
If you hit this limit, you must wait for the window to reset. The error response will include a Retry-After header indicating how many seconds to wait. Implementing exponential backoff in your client code is the standard way to handle this gracefully.
Keep in mind that concurrent requests count toward the 8-request limit simultaneously. If you are using a streaming response, each chunk does not count as a new request; only the initial request does. However, if you open multiple connections to the same endpoint, each counts.
If you need higher limits, you may need to distribute requests across multiple API keys, as each key has its own independent quota. There is no option to purchase higher rate limits; the limits are fixed to ensure stability for all users.
Context Window Limits
The context window defines the total number of tokens the model can process in a single request, including both the input (prompt) and the output (completion). Our API supports a context window of 100,000 tokens. This means the sum of your input tokens and output tokens cannot exceed 100,000.
If you send a prompt that is too long, or if the model generates a response that pushes the total over 100,000 tokens, the request will fail. It is important to monitor your token usage, especially when dealing with long documents or conversation history.
For example, if you send a 50,000 token prompt, you have only 14,000 tokens left for the output. If you do not specify a max_tokens limit, the model might try to generate more, leading to an error. Always set max_tokens to a safe value below your remaining context window.
Streaming responses do not change the context window limit; they only change how you receive the data. The total tokens used are still counted against the 100,000 token limit. Be sure to truncate your conversation history if it grows too large to fit within the window.
Max Tokens Configuration
The max_tokens parameter controls the maximum number of tokens the model will generate in the response. If you do not set this parameter, the response can run to the end of the window.
Setting max_tokens too high can lead to longer processing times and higher costs, as you are charged for every token generated. It is best to set this value based on your expected output length. For example, if you expect a 500-word response, set max_tokens to around 700 to account for variability.
If the model reaches the max_tokens limit, the response will be truncated, and the finish_reason will be set to length. This allows your application to handle the truncation appropriately, such as by sending a follow-up request to continue the text.
Be aware that the sum of input and output tokens must still fit within the 100,000 token context window. Setting max_tokens to 100,000 is valid only if your input is very short. Always account for your input size when setting this parameter.
Streaming Response Issues
Streaming allows you to receive the model's response token by token, providing a better user experience for long outputs. Our API supports streaming via Server-Sent Events (SSE). When you set stream to true, the API returns a series of chunks instead of a single complete response.
Each chunk contains a partial response, and the final chunk includes the total token usage. It is important to handle these chunks correctly in your client code. If you are using the official OpenAI SDK, streaming is handled automatically, but if you are using a raw HTTP client, you must parse the SSE format.
Common issues include not closing the connection properly or failing to handle network errors during streaming. Ensure your client can handle interruptions and resume if possible. Streaming does not reduce the context window limit or the token cost; it only changes the delivery method.
Remember that the final chunk contains the usage data, which includes the number of input and output tokens. This is the only place where the total token count is provided in a streaming response. Do not try to count tokens yourself from the chunks, as this may lead to inaccuracies.
JSON Mode Parsing Errors
JSON mode ensures that the model's output is valid JSON, which is important for function calling and structured data extraction. To enable this, set response_format to {"type": "json_object"}. The model will then attempt to return a well-formed JSON object.
If the output is not valid JSON, the API will return an error. This can happen if the model generates extra text outside the JSON object or if the JSON structure is malformed. To mitigate this, you can provide a clear schema in your prompt or use a system message to instruct the model to output only JSON.
Even with JSON mode, the model may occasionally produce invalid JSON. It is good practice to wrap your parsing logic in a try-catch block and retry the request if parsing fails. You can also set temperature to a lower value to make the output more deterministic.
Be aware that JSON mode does not guarantee that the JSON will match your expected schema. It only ensures that the output is valid JSON syntax. You still need to validate the structure and content of the JSON in your application code.
Function Calling Payload Structure
Function calling allows the model to call predefined functions based on the user's input. To use this feature, you must define the functions in the tools parameter and set tool_choice to auto or specify a particular function.
The payload structure requires a messages array with the user's input, followed by the tools array defining the function signatures. The model will return a response with a tool_calls array if it decides to call a function. You must then execute the function and send the result back to the model in a new message.
Ensure that the function definitions are accurate and include all necessary parameters. The model relies on these definitions to determine which function to call and what arguments to pass. Incorrect definitions can lead to the model calling the wrong function or passing incorrect arguments.
Streaming works with function calling, but the function call details are only available in the final chunk. You must wait for the complete response before executing the function. Do not try to execute partial function calls, as the model may change its mind.
Payment & Credit Expiry
Our API uses a prepaid credit system. You top up your account with cryptocurrency, and credit is charged based on actual token usage. Errors and refusals do not consume credit, so you only pay for successful requests. This is a transparent and fair pricing model.
Credit does not expire. Once you purchase credit, it remains in your account indefinitely. There are no monthly fees or subscription costs. You can top up with any whole amount between $20 and $500 using USDT (TRC20) or USDC (Base). Larger top-ups come with bonus credit: +5% from $50, +10% from $100, +15% from $200.
You can start using the API immediately after signing up, as new users get $0.50 of trial credit, one per person, valid for 7 days. Claim this credit with one click on your API key page. No credit card is needed for the trial. This allows you to test the API without any financial commitment.
If you make a mistake, such as a double charge, you can contact support through the Support page. Credit is not refunded, but errors are corrected. The credit remains in your account and can be used for future requests. There is no need to worry about losing your credit due to inactivity.
More guides
Questions and answers
Is this the official Grok API?
No, this is an independent API that serves an uncensored large language model. It is not affiliated with x.ai or any other vendor. It uses the same OpenAI-compatible protocol, so it works with the same client code, but the model and pricing are different.
How do I get an uncensored Grok API key?
You can sign up on our site using Google or an email address. After signing up, you will receive an API key immediately. This key is tied to our uncensored model and works with the standard OpenAI SDK by changing the base URL.
Does the API key expire?
API keys do not expire unless you revoke them manually. However, your prepaid credit may be used up. Credit itself never expires, so you can top up at any time to continue using the API.
What happens if I get an invalid API key error?
This error usually means the key is missing, incorrect, or revoked. Check that you are using the correct base URL and that the key is passed in the Authorization header. If the key was generated recently, ensure it is the latest version.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.