Groq vs Grok Keys in LangChain: What Works Where
A LangChain Groq API key belongs to Groq's own service and its dedicated package. If you want an uncensored, OpenAI-compatible endpoint inside LangChain instead, the setup is short and uses ChatOpenAI.

No card needed. After sign-up, claim $0.50 of free test credit with one click (once per person).
Key points
- Groq (the inference company), Grok (xAI's model) and this service are three unrelated things.
- Groq keys work with the langchain-groq package; they will not authenticate here.
- For this endpoint use ChatOpenAI with base_url, an api_key from this site and model uncensored.
- Agents, tool calling, streaming and JSON mode work through the normal LangChain interfaces.
Three names, three different things
The spelling trap is real, so start by sorting it out. Groq is a company that runs hosted inference, and LangChain has a dedicated integration for it, langchain-groq, whose chat class reads a key from a Groq environment variable. Grok, with a k, is xAI's model. This site, uncensoredgrok.cc, is neither: it runs a single open-weight model from an independent provider behind an OpenAI-compatible API, tuned to answer without content refusals for lawful adult use.
So when you search for a langchain groq api key, there are two possible situations. If you want Groq's service, create a key in Groq's console and follow the current LangChain and Groq documentation; this page cannot help with that. If you are choosing a provider and want an uncensored one, you need a key from this site, and a Groq key will not work here, nor will ours work there.
The rest of the page assumes the second situation and walks through connecting LangChain to this endpoint in a few minutes.
Step by step
- Get a key. Sign up with Google, or with email and password. New users can claim $0.50 of trial credit with one click on the API key page. It needs no payment method and lasts 7 days.
- Install the packages. Run
pip install langchain-openai langchain-core. Use a virtual environment so versions stay isolated. - Export the key. Put it in
UNCENSORED_API_KEYin your shell or a secrets manager, not in the repository. - Build the model object. Use
ChatOpenAIwith three overrides.
import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="uncensored",
base_url="https://api.uncensoredgrok.cc/v1",
api_key=os.environ["UNCENSORED_API_KEY"],
temperature=0.7,
max_retries=3,
)
print(llm.invoke("Write a villain's monologue in four lines.").content)
If this prints a response, the connection works. The base URL ends in /v1 and LangChain appends the route itself, so do not add /chat/completions. Behind the scenes it sends POST /v1/chat/completions with an Authorization: Bearer header.
Migrating code written for ChatGroq
If your project already uses Groq's chat class, the changes are mechanical, because every LangChain chat model implements the same runnable interface. Your prompts, output parsers, retrievers and memory code do not care which class sits at the end of the chain.
| Item | Before (Groq) | After (this endpoint) |
|---|---|---|
| Package | langchain-groq | langchain-openai |
| Class | Groq's chat class | ChatOpenAI |
| Key variable | Groq's key variable | your own, passed as api_key |
| Model name | a Groq-hosted model ID | uncensored |
| Endpoint | chosen by the package | base_url set explicitly |
Do not expect identical output. The two services serve different models, so a prompt tuned for one will need small edits for the other. Latency and throughput also differ, and we do not publish figures for ours; measure on your own workload. Prices for other services are theirs to state, so check their current pricing.
An agent with tools
Agents are where the model swap shows up most. The endpoint supports tool calling in the OpenAI format, so the LangGraph prebuilt agent works with ChatOpenAI. Install langgraph as well, then:
import os
from langchain_core.tools import tool
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
@tool
def word_count(text: str) -> int:
"""Count the words in a piece of text."""
return len(text.split())
llm = ChatOpenAI(
model="uncensored",
base_url="https://api.uncensoredgrok.cc/v1",
api_key=os.environ["UNCENSORED_API_KEY"],
)
agent = create_react_agent(llm, [word_count])
out = agent.invoke({"messages": [("user", "How many words are in: the lantern swung over black water?")]})
print(out["messages"][-1].content)
Agent loops make several model calls per user question, and each call resends the growing history. Budget for that. If the agent made 5 calls averaging 3,000 input tokens and 200 output tokens each, the input is 15,000 tokens costing 15,000 × $0.15 / 1M = $0.00225 and the output is 1,000 tokens costing 1,000 × $0.50 / 1M = $0.0005, so one question costs $0.00275.
Cap the number of agent steps so a confused loop cannot run up a bill, and validate tool arguments yourself, since they are text produced by the model.
Environment variables and configuration
You can avoid hard-coding by relying on the environment. The OpenAI Python client that sits under ChatOpenAI reads its settings from variables when arguments are omitted, but variable names have changed between library versions, so passing arguments explicitly is the safer habit. Keep the three values in one settings module and import them everywhere:
import os
from langchain_openai import ChatOpenAI
SETTINGS = {
"model": "uncensored",
"base_url": "https://api.uncensoredgrok.cc/v1",
"api_key": os.environ["UNCENSORED_API_KEY"],
}
def chat(**overrides):
return ChatOpenAI(**{**SETTINGS, **overrides})
story_llm = chat(temperature=1.0)
extract_llm = chat(temperature=0)
print(extract_llm.invoke("Reply with the single word ready.").content)
Two models objects with different temperatures is a common pattern: a warm one for narration and a cold one for extraction or classification. Both use the same key, so they share its concurrency budget of 8 on a full key.
A retrieval chain
Retrieval-augmented chains work the same way. LangChain builds the prompt from retrieved text and passes it to whichever chat model you give it. The only cost-related change is size: each retrieved passage counts as input tokens on every call. With four passages of 600 tokens, a 200-token question and a 150-token instruction, a call carries 2,750 input tokens. If the answer runs 300 tokens, the call costs 2,750 × $0.15 / 1M = $0.0004125 for input plus 300 × $0.50 / 1M = $0.00015 for output, so $0.0005625 in all. The embedding step for your vector store is outside this service, because it offers no embeddings endpoint.
Keep the retrieved context honest: tell the model in the system message to answer from the supplied passages and to say when they do not contain the answer. This holds for any provider and reduces made-up details.
Streaming, JSON and batches
Three more features use the same pattern. For streaming, iterate over llm.stream(...) and print chunk.content. For JSON, call llm.bind(response_format={"type": "json_object"}) and mention JSON in the prompt. For parallel work, use llm.batch(inputs, config={"max_concurrency": 8}).
import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="uncensored",
base_url="https://api.uncensoredgrok.cc/v1",
api_key=os.environ["UNCENSORED_API_KEY"],
)
prompts = ["Name a tavern.", "Name a blacksmith.", "Name a ferry captain."]
for r in llm.batch(prompts, config={"max_concurrency": 8}):
print(r.content)
The number 8 matches the full-key limit of 8 concurrent requests, with 300 requests per minute. A trial key allows 2 concurrent and 60 per minute, so use max_concurrency of 2 there. Beyond the limit you get HTTP 429, with rate_limited or concurrency as the error code, and Retry-After: 5 on temporary overload. The retry setting in ChatOpenAI absorbs occasional ones. Streaming holds the slot until the stream ends, which matters when you stream to many users from one key.
Troubleshooting
- Authentication error. The key is wrong, was copied with a trailing space, or is a Groq key. Create a key on this site and check the environment variable is set in the process that runs the code.
- Not found. The base URL is missing
/v1or has an extra path segment. Use exactlyhttps://api.uncensoredgrok.cc/v1. - Model error. A leftover model name from another provider. The model is
uncensored;GET /v1/modelsconfirms it. - 429 responses. Lower
max_concurrency, read the error code, and back off. - Context too long. The window is 100,000 tokens including the completion. Trim history or retrieved passages.
Credit is prepaid at $0.15 per 1M input tokens and $0.50 per 1M output tokens, never expires, and failed or refused requests are not charged. Top-ups of $20 to $500 are paid in crypto (USDT on TRC20 or USDC on Base), and bonuses start at 5% from $50. See the pricing page and the quickstart for details. This is a text-only service, so embeddings for a vector store must come from another provider, and the sexual-content-involving-minors rule is absolute. Prompts are not used for training.
A last habit worth adopting: keep a tiny smoke-test script in the repository that builds the model, sends one short prompt and prints the reply. Run it after every dependency upgrade, since LangChain packages release often and a changed default can break a working setup without any change in your own code. It also gives you a quick way to confirm that a key, a balance and a network path are all healthy before you start debugging the larger application. If the smoke test passes and your chain still fails, the problem is in your prompt or parser, not the connection.
More guides
Questions and answers
Can I use my Groq key on this site?
No. Keys are issued per service. Create a key on this site and use it as api_key with base_url set to https://api.uncensoredgrok.cc/v1.
Is Groq the same as Grok?
No. Groq is an inference company, Grok is xAI's model, and this service runs an independent open-weight model. This site is not affiliated with either of the other two.
Which LangChain class do I use here?
ChatOpenAI from langchain-openai, with model set to uncensored and a custom base_url.
Does the trial key work with LangChain?
Yes, the trial key works the same way, but it is limited to 2 concurrent requests and 60 per minute, so set max_concurrency to 2.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.