Public preview: This API is in public preview. Endpoints, schemas, and limits may change before general availability.
Using the OpenAI SDK
Point the official `openai` SDK at EU GPT and reuse your existing code.
There is no EU GPT-specific SDK. The official OpenAI SDKs already speak the Responses API, and EU GPT implements it — so configuration is one line.
Install the SDK#
npm install openaibun add openaipip install openaiuv add openaiConfigure the base URL#
Override baseURL (JS) / base_url (Python) to point at the EU GPT environment. Use your EU GPT API key — not an OpenAI key.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.EUGPT_API_KEY,
baseURL: "https://api.eugpt.ai/v1",
});import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["EUGPT_API_KEY"],
base_url="https://api.eugpt.ai/v1",
)That is the entire configuration. Every call to client.responses.create now goes to EU GPT.
What works#
client.responses.create(...)— bothstream: trueandstream: false.- The async iterator pattern in JavaScript (
for await (const event of stream)). - The Python generator pattern (
for event in stream:). - Typed events — the SDK parses the
data:JSON for you. client.models.list()— the models you can pass asmodel.client.files.create,.list,.retrieve,.content, and.delete— see Using files as context.
EU GPT-specific fields such as conversation_id, project_id, visible, and response_format are not in the SDK’s types. In JavaScript you can pass them in the request object (in TypeScript, cast the object); in Python, pass them in extra_body:
const response = await client.responses.create({
model: "auto",
input: "And add a bulleted list of risks.",
conversation_id: "8f14e45f-ceea-467a-a4ed-a9e9a5cb16ee",
stream: false,
});response = client.responses.create(
model="auto",
input="And add a bulleted list of risks.",
stream=False,
extra_body={"conversation_id": "8f14e45f-ceea-467a-a4ed-a9e9a5cb16ee"},
)What does not work (yet)#
The following surfaces are part of the OpenAI SDK but not implemented in EU GPT today. Calling them returns a 404:
client.chat.completions.*— useclient.responses.*instead.client.responses.retrieve,.delete,.cancel, and other calls on an existing response.client.assistants.*,client.threads.*— the Assistants API is a separate product line.client.embeddings.*— embeddings are an internal RAG concern; no public endpoint.client.images.*,client.audio.*— image and audio generation are not exposed publicly.
These request parameters are accepted but ignored, so they fail silently:
previous_response_id— useconversation_idinstead.tools— EU GPT uses its own built-in tools.text.format, and thereforeclient.responses.parse(...)withtext_format— useresponse_formatinstead; see Structured outputs.- Sampling parameters such as
temperatureandtop_p.
Recommended patterns#
A reusable client#
Create the client once at module load. The SDK reuses HTTP connections.
// lib/eugpt.js
import OpenAI from "openai";
export const eugpt = new OpenAI({
apiKey: process.env.EUGPT_API_KEY,
baseURL: process.env.EUGPT_BASE_URL ?? "https://api.eugpt.ai/v1",
});
# app/eugpt.py
import os
from openai import OpenAI
eugpt = OpenAI(
api_key=os.environ["EUGPT_API_KEY"],
base_url=os.getenv("EUGPT_BASE_URL", "https://api.eugpt.ai/v1"),
)
Parameterising the base URL lets your tests point the client at a mock server without code changes.
Switching providers#
If your code already uses OpenAI and you want to add EU GPT alongside, instantiate two clients:
import OpenAI from "openai";
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const eugpt = new OpenAI({
apiKey: process.env.EUGPT_API_KEY,
baseURL: "https://api.eugpt.ai/v1",
});
// Route per-call:
const client = featureFlag("use-eu-gpt", user) ? eugpt : openai;
Common pitfalls#
- Forgetting
/v1: the base URL must end in/v1, not/v1/and not barehttps://api.eugpt.ai. The SDK appendsresponsesto it. - OpenAI key vs EU GPT key: keys are not interchangeable. EU GPT keys start with
eugpt_. - Calling Chat Completions:
client.chat.completions.createreturns 404. Useclient.responses.create. - Using an OpenAI model name: names like
gpt-4odon’t exist on EU GPT and return400withmodel_not_found. Pass"auto"or an EU GPT model id fromclient.models.list(). See Models. - Sending chat history in
input: only the first text part ofinputis used. Useconversation_idfor multi-turn conversations. - No credit: requests return
402(the SDK throws an error withstatus402) until your prepaid balance has credit. See Usage limits & billing.