EN ▾
Try with trial credit
Try with trial credit

Codex API documentation and endpoints

Start generating text with our uncensored LLM API. This guide covers the base URL, authentication, and the specific endpoints you need to integrate quickly.

Base URL and authentication

Send requests to the base URL https://api.codexapipricing.com/v1 using your API key. This endpoint is compatible with standard OpenAI SDKs, so you only need to update the base URL and provide your key. Authenticate by passing the header Authorization: Bearer YOUR_API_KEY with every request. You can generate a key immediately by signing in with Google or an email and password. The key is displayed once after creation, so save it securely. Your prompts are not used for training, ensuring privacy for your data.

Chat completions endpoint

Use the POST /v1/chat/completions endpoint to generate text. This is the primary interface for sending prompts and receiving responses. The model ID is always uncensored, regardless of the model version running on our servers. You can check available models via GET /v1/models. Send your message history in the messages

Supported parameters and JSON mode

Control generation with parameters like temperature, top_p, and stop. Use response_format set to {"type": "json_object"} to force JSON output. This is useful for structured data extraction or function calling. You can also set max_tokens to limit output length, defaulting to 2,048 if omitted. The context window supports up to 100,000 tokens for prompt and completion combined. Pass seed for deterministic results or presence_penalty and frequency_penalty to adjust repetition. These parameters allow fine-tuning of the model's behavior without complex configuration. JSON mode ensures strict formatting for reliable parsing in your application.

Streaming responses via SSE

Enable streaming by setting stream: true in your request. The API returns Server-Sent Events (SSE) as tokens are generated. This reduces perceived latency for long responses. Token usage details appear in the final chunk of the stream. You can process tokens incrementally to display text in real-time. This feature works with all OpenAI-compatible SDKs. Streaming is ideal for chat interfaces where users expect immediate feedback. The last chunk contains the total token count for billing accuracy. Use this method to handle large outputs gracefully without waiting for the full response.

Rate limits and request bodies

Each API key is limited to 300 requests per minute and 8 concurrent requests. The maximum request body size is 8 MB. If you exceed these limits, you receive a 429 error. You can generate new keys to replace existing ones, but only one key is active per account. Errors and refusals do not count against your rate limit. The context window of 100,000 tokens allows for extensive conversation history. Keep your request bodies concise to stay within size limits. Monitor your usage to avoid interruptions during peak times. These limits ensure fair usage across all prepaid customers.

Error handling and troubleshooting

Handle errors by checking the HTTP status code. A 401 error indicates an invalid or missing API key. A 402 error means your prepaid credit is exhausted. A 429 error signals that you have exceeded the rate limits. Use the error field in the response to get details. Mistakes like double charges are fixed via the Support page. Credit never expires, so you can top up later. Refusals for content policy violations are free. This predictable error structure helps you debug integration issues quickly without guessing the cause.

cURL

curl https://api.codexapipricing.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "List the hourly rates for the large model."}]
  }'

Python

from openai import OpenAI

client = OpenAI(base_url="https://api.codexapipricing.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

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.codexapipricing.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

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)

Frequently asked questions

What is the base URL and how do I authenticate?

The base URL is HTTPS://api.codexapipricing.com/v1. Authenticate by including the header Authorization: Bearer YOUR_API_KEY with each request. You get an API key instantly after signing up with Google or email.

Does the uncensored model support JSON mode?

Yes, set response_format to {"type": "json_object"} in your request. This forces the model to output valid JSON, which is useful for structured data. It works with the standard chat completions endpoint.

What happens if I hit the rate limit?

You will receive a 429 HTTP status code. The limit is 300 requests per minute and 8 concurrent requests per key. Errors and refusals do not count toward this limit. You can generate a new key to continue if needed.

Get your API key in one step

Sign up, copy the key, update the endpoint. That’s all there is to it.