API Documentation
Swap your OpenAI base URL for ours and start generating text immediately. This quickstart guide shows you how to authenticate, send requests, and handle streaming with our uncensored API.
Authentication and Base URL
Start by updating your client configuration with your unique API key and our specific base URL. You do not need to change your code logic, only the connection string. The endpoint is https://api.gatewayllm.cc/v1 and requires the Authorization: Bearer <key> header. This setup works with any standard OpenAI-compatible SDK you already have installed.
First Request
Send a standard chat completion request to verify your connection and receive an immediate response. Use the model ID uncensored to access our specific large language model. The following example demonstrates a simple text interaction using the cURL command-line tool.
curl https://api.gatewayllm.cc/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Check server health status"}]
}'Your response will arrive as JSON containing the generated text. If you receive a valid response, your integration is working correctly.
Python SDK Integration
Use the official OpenAI Python library to interact with our endpoint by overriding the base URL. This allows you to keep your existing Python code structure while switching the underlying provider. The following snippet shows how to initialize the client and send a message.
from openai import OpenAI
client = OpenAI(base_url="https://api.gatewayllm.cc/v1", api_key="YOUR_KEY")
resp = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)The library handles serialization and deserialization automatically. You can now use standard methods like chat.completions.create with our backend.
Node.js SDK Setup
Initialize the OpenAI Node.js package with your key and our base URL to start generating content. This approach ensures compatibility with existing Node applications without requiring major refactoring. The following code demonstrates the initialization process.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.gatewayllm.cc/v1", apiKey: process.env.API_KEY });
const resp = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);Call the completion method with your desired model ID. The response object will contain the generated text in the content field.
Streaming and SSE
Enable streaming to receive tokens as they are generated, reducing perceived latency for long outputs. Set stream: true in your request parameters to activate Server-Sent Events. The following example shows how to consume the stream in chunks.
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Tell the story in second person."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)Each chunk contains partial data. The final chunk includes the total token usage statistics. This method is ideal for real-time user interfaces.
Limits, Errors, and Context
Monitor your request rate and handle errors gracefully to maintain a stable application. Our API enforces a limit of 300 requests per minute per key. You will receive a 401 error if your key is invalid, a 402 error if your prepaid credit is exhausted, and a 429 error if you exceed the rate limit. Each request supports a context window of 100,000 tokens. Ensure your prompt plus completion stays within this limit to avoid truncation.
Frequently asked questions
Is this an OpenAI compatible API?
Yes, our endpoint follows the OpenAI chat-completions format. You can use the official OpenAI SDKs by simply changing the base URL to ours. This allows for a drop-in replacement for most existing integrations.
What is the LLM gateway context window size?
We support a context window of 100,000 tokens for both the prompt and the completion combined. This allows for processing large documents or long conversation histories in a single request.
How do I handle rate limits?
We allow 300 requests per minute per API key. If you exceed this limit, you will receive a 429 status code. Implement exponential backoff in your client to handle retries efficiently.
Unlock your key in one step
Sign up, grab the key, update your base URL. That’s it.