Skip to content
Regolo Logo
Self‑Hosting & DevOps

Drop-In OpenAI Replacement: Swap base_url to EU-Hosted Regolo

Alex Genovese
3 min read
Share

Replacing OpenAI with a European, GDPR-compliant inference provider does not require rewriting your application because we provide an OpenAI-compatible endpoint, you only need to change two variables to switch providers.

In a nutshell: to move from OpenAI to a GDPR-friendly EU provider, keep your code and just change the base_url to https://api.regolo.ai/v1 plus your Regolo API key. This drop-in approach works seamlessly across the official SDKs, LangChain, and LlamaIndex.

Why use an OpenAI-compatible endpoint?

When building AI applications, vendor lock-in is a significant risk. By relying on an OpenAI-compatible API, you decouple your application logic from a single model provider. This flexibility allows you to seamlessly switch to open-weight models, test different architectures, or migrate to EU data residency without overhauling your codebase.

Update the OpenAI Python SDK

The official Python SDK allows you to override the default endpoints during client initialization.

from openai import OpenAI
import os

# Initialize the client pointing to Regolo's endpoint
client = OpenAI(
    api_key=os.environ.get("REGOLO_API_KEY"),
    base_url="https://api.regolo.ai/v1",
)

response = client.chat.completions.create(
    model="meta-llama/Llama-3-70b-chat-hf",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello!"}
    ]
)
print(response.choices[0].message.content)Code language: Python (python)

Update the OpenAI JavaScript/TypeScript SDK

Node.js and browser applications follow the exact same logic. Update the configuration object when instantiating the client.

import OpenAI from 'openai';

const openai = new OpenAI({
  apiKey: process.env.REGOLO_API_KEY,
  baseURL: 'https://api.regolo.ai/v1',
});

async function main() {
  const completion = await openai.chat.completions.create({
    messages: [{ role: 'user', content: 'Say this is a test' }],
    model: 'meta-llama/Llama-3-8b-chat-hf',
  });

  console.log(completion.choices[0].message.content);
}

main();Code language: Python (python)

Integrating with LangChain

LangChain natively supports OpenAI-compatible endpoints through its standard ChatOpenAI class. You do not need a custom wrapper.

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    openai_api_key="your-regolo-api-key",
    openai_api_base="https://api.regolo.ai/v1",
    model_name="meta-llama/Llama-3-70b-chat-hf"
)

response = llm.invoke("What is the capital of France?")
print(response.content)Code language: Python (python)

Integrating with LlamaIndex

LlamaIndex works smoothly with alternative endpoints. Simply configure the OpenAI LLM class to route requests to Regolo.ai.

from llama_index.llms.openai import OpenAI

llm = OpenAI(
    api_key="your-regolo-api-key",
    api_base="https://api.regolo.ai/v1",
    model="meta-llama/Llama-3-70b-chat-hf"
)

response = llm.complete("Explain quantum computing in simple terms.")
print(response.text)Code language: Python (python)

Key compliance trade-offs

ConsiderationOpenAI DefaultRegolo.ai
Data residencyUS-centric100% EU infrastructure
API compatibilityNativeFull drop-in replacement
Model selectionProprietary onlyLeading open-weight models
Data retentionDefault 30 daysZero data retention

FAQs

What is an inference provider?
An inference provider runs pre-trained AI models on cloud infrastructure and exposes them via an API, so you can integrate AI without managing GPUs yourself.

How is inference different from training?
Training creates the model by feeding it massive datasets. Inference is the process of using that already-trained model to generate responses or predictions in real time.

Can I use an OpenAI-compatible endpoint and keep data in Europe?
Yes. By pointing your existing OpenAI SDK integration to a European inference provider like Regolo.ai, your data processing remains strictly within the EU.

Is zero data retention enough for GDPR compliance?
Zero data retention is a massive advantage because it means user prompts are not stored after processing. However, full GDPR compliance also depends on where the processing happens and how you handle data on your end.

When does self-hosting make more sense than using an inference provider?
Self-hosting makes sense if you have specialized security requirements (like air-gapped systems) or high, predictable continuous workloads. For most teams, an inference provider is faster to implement and easier to maintain.


Start your free 30-day trial at regolo.ai and deploy LLMs with complete privacy by design.

👉 Talk with our Engineers or Start your 30 days free →



Built with ❤️ by the Regolo team. Questions? regolo.ai/contact or chat with us on Discord