OpenAI Python SDK with Redline
Redline speaks the OpenAI chat-completions dialect, so the official openai Python client works with a base URL change and nothing else.
base_url and api_key
Set base_url to https://redline-gateway.pages.dev/v1 (the /v1 is part of it) and api_key to your key. The client also reads OPENAI_BASE_URL and OPENAI_API_KEY from the environment.
# pip install openai
from openai import OpenAI
client = OpenAI(
base_url="https://redline-gateway.pages.dev/v1",
api_key="rl-...",
)
resp = client.chat.completions.create(
model="deepseek/deepseek-chat-v3.1",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)
Chat completions only Redline serves /v1/chat/completions and /v1/models. It does not serve /v1/responses, /v1/completions or /v1/embeddings, so stay on the chat.completions call.