Docs · Integrate
OpenAI SDK
Integrate with the official OpenAI SDKs (Python / Node.js) or plain HTTP. Existing OpenAI code only needs a new base URL and API key.
Install
pip install --upgrade openaiCreate a client
import os
from openai import OpenAI
client = OpenAI(
base_url=os.environ["OPENAI_BASE_URL"], # https://<your-endpoint>/v1
api_key=os.environ["OPENAI_API_KEY"],
timeout=300, # seconds; use streaming for long outputs
max_retries=3, # built-in exponential backoff (429 / 5xx / network)
)The OpenAI SDK base URL must end with
/v1, e.g. https://<your-endpoint>/v1. Without /v1 you will get 404s.Use environment variables
Prefer not to put the address in code? Set these variables and initialize OpenAI() without arguments.
# Find your endpoint and API key in the console
export OPENAI_BASE_URL="https://<your-endpoint>/v1"
export OPENAI_API_KEY="YOUR_API_KEY"Plain HTTP
Any language can call the API over HTTPS. Request bodies are the same as OpenAI's:
curl https://<your-endpoint>/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4.1-mini",
"messages": [{"role": "user", "content": "Hello!"}]
}'Frameworks and tools
Anything that accepts a custom OpenAI base URL works: LangChain (ChatOpenAI(base_url=..., api_key=...)), LlamaIndex, the Vercel AI SDK (createOpenAI({ baseURL })) and the many clients with an "OpenAI-compatible" setting. Use the console endpoint (with /v1) as the base URL and a model ID from the catalog as the model name.