SDK MigrationUpdated 2026-01-22

Switch OpenAI Python SDK base URL

Switch your OpenAI Python SDK to abliteration.ai in one line. Change base_url and keep your existing code.

The OpenAI Python SDK supports custom endpoints via base_url. Switch to abliteration.ai without rewriting your application.

Your existing message format, streaming logic, and function calls work unchanged.

Definition

Switch OpenAI Python SDK base URL

Switching the OpenAI Python SDK base URL means changing one parameter to route requests through an alternative OpenAI-compatible provider.

Why it matters
  • Keep all existing OpenAI Python SDK code unchanged.
  • No new dependencies or SDK migrations required.
  • Test alternative providers without rewriting your application.
  • Maintain compatibility with tools and libraries that expect OpenAI SDK patterns.
How it works
  1. 01Install or update the openai package.
  2. 02Set base_url="https://api.abliteration.ai/v1" in the client constructor.
  3. 03Replace your OpenAI key with your abliteration.ai API key.
  4. 04Use a supported model id like abliterated-model.
Python SDK base URL switch
from openai import OpenAI

# Before: OpenAI default
# client = OpenAI(api_key="sk-...")

# After: abliteration.ai
client = OpenAI(
    base_url="https://api.abliteration.ai/v1",
    api_key="YOUR_ABLIT_KEY",
)

completion = client.chat.completions.create(
    model="abliterated-model",
    messages=[{"role": "user", "content": "Summarize this document."}],
)

print(completion.choices[0].message.content)
FAQ

Frequently asked questions.

Do I need to change my message format?

No. The message format is identical to OpenAI. Your existing role/content arrays work unchanged.

Does streaming work?

Yes. Set stream=True and iterate over chunks exactly like OpenAI.

Can I switch back to OpenAI later?

Yes. Remove the base_url parameter to return to the OpenAI default endpoint.