Home › Blog › Call an Uncensored LLM API from Python (Working Code)

Call an Uncensored LLM API from Python (Working Code)

2026-11-15 · ArxPays engineering notes

Every uncensored endpoint worth using speaks the OpenAI protocol. That means the official SDK works unchanged — you only change two arguments.

pip install openai
from openai import OpenAI

client = OpenAI(
    base_url="https://arxpay.my.id/v1",
    api_key="arx-live-YOUR_KEY",
)

r = client.chat.completions.create(
    model="deepseek-v4.1-flash-abliterated-2",
    messages=[{"role": "user", "content": "Write the scene exactly as described."}],
    temperature=0.85,
    max_tokens=600,
)
print(r.choices[0].message.content)

Streaming

Long replies should stream. Buffering a 900-token answer feels broken even when latency is fine.

stream = client.chat.completions.create(
    model="deepseek-v4.1-flash-abliterated-2",
    messages=[{"role": "user", "content": "Continue."}],
    stream=True,
)
for chunk in stream:
    delta = chunk.choices[0].delta.content
    if delta:
        print(delta, end="", flush=True)

Retries and 429s

Rate limits are per key, not per account. Catch 429, back off exponentially, and cap the number of attempts. Never retry a 401 or 403 — those are configuration errors and will fail identically.

import time
from openai import RateLimitError, AuthenticationError

for attempt in range(4):
    try:
        r = client.chat.completions.create(...)
        break
    except RateLimitError:
        time.sleep(2 ** attempt)
    except AuthenticationError:
        raise

Tracking spend

The response carries usage counts. Log them per feature, not globally — that is how you find the endpoint call that quietly burns 40% of the budget.

print(r.usage.prompt_tokens, r.usage.completion_tokens)

Errors you will hit

FAQ

Does the SDK need a specific version?

Any recent openai>=1.0 works; the base_url argument is what matters.

Is async supported?

Yes, use AsyncOpenAI with the same base_url.

Can I use httpx or requests directly?

Yes, POST to /v1/chat/completions with a Bearer token.

Endpoint https://arxpay.my.id/v1 · Model deepseek-v4.1-flash-abliterated-2

Get a key