API Documentation
Get started with the Codex API using standard OpenAI-compatible tools. This guide covers authentication, request formats, and streaming for your uncensored LLM integration.
Base URL and authentication
Start every request by pointing your SDK to https://api.codexapitoken.com/v1 and attaching your key. We provide one active API key per account, which you receive immediately after signing up via Google or email. This key authorizes all subsequent calls to the chat-completions endpoint. Do not share this key in client-side code, as it grants full access to your prepaid credit. The endpoint works with any library that supports the OpenAI schema, ensuring you can switch clients without rewriting your core logic.
First request with cURL
Verify your setup by sending a simple text completion request. Use the uncensored model ID to access the open-weight model tuned for minimal refusals. The request includes standard parameters like temperature and max_tokens to control output behavior. You can observe the raw JSON response to confirm the API is returning text without filtering adult content. This method works instantly for testing your integration before moving to your main application code.
curl https://api.codexapitoken.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Summit the tax form for Q3 2024"}]
}'
Python SDK integration
Install the official openai package and configure the base URL to point to our server. Set the API_KEY environment variable or pass it directly to the client constructor. This approach lets you use familiar Python patterns for generating text. You can stream responses or fetch them synchronously depending on your application's needs. The SDK handles tokenization and retries, making it easier to manage the 100,000-token context window in memory.
from openai import OpenAI
client = OpenAI(base_url="https://api.codexapitoken.com/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)
Node.js SDK integration
Initialize the OpenAI client in your Node environment with the correct base URL and API key. This allows you to integrate the uncensored model into your JavaScript or TypeScript applications seamlessly. You can use async/await patterns to handle responses without blocking the event loop. The SDK supports both synchronous and asynchronous request handling. This flexibility is crucial for high-throughput applications that need to manage multiple concurrent requests efficiently.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.codexapitoken.com/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);
Streaming responses
Enable streaming by setting stream: true in your request parameters. The API returns data in chunks via Server-Sent Events (SSE), allowing you to display text as it is generated. This reduces perceived latency for users waiting for long outputs. The final chunk includes the token usage statistics for billing purposes. Streaming is ideal for chat interfaces where immediate feedback improves the user experience significantly.
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)
Rate limits and constraints
Your API key is limited to 300 requests per minute and 8 concurrent requests. Each request body must not exceed 8 MB. If you hit the rate limit, you will receive a 429 error. Ensure you implement exponential backoff in your client to handle transient spikes gracefully. The context window is 100,000 tokens for prompt and completion combined. Exceeding this limit results in an error. Monitor your usage via the final response chunk to stay within your prepaid credit limits.
Frequently asked questions
How do I authenticate with the Codex API?
Include your API key in the <code>Authorization</code> header as a Bearer token. You receive this key immediately after signing up. It grants access to your prepaid credit until it is exhausted.
What happens if I get a 402 error?
A 402 error indicates that your account has insufficient prepaid credit. You must top up using USDT (TRC20) or USDC (Base) to continue making requests. Credit never expires, so you can add funds whenever convenient.
Does the uncensored model support function calling?
Yes, the model supports tools and tool_choice parameters. You can define function schemas in the request to enable structured data extraction. This feature works alongside standard text generation for flexible integration.