Skip to main content

OpenAI-compatible clients

Anything that targets the OpenAI API (the OpenAI SDKs, LangChain's ChatOpenAI, the Vercel AI SDK's OpenAI provider, LlamaIndex) points at http://<gateway>:8787/v1. Base URLs, client keys, and attribution headers are on SDKs & frameworks.

OpenAI (Python)
from openai import OpenAI

client = OpenAI(
base_url="http://<gateway>:8787/v1",
api_key="<your-gateway-key>",
default_headers={
"x-anyray-provider": "openai",
"x-anyray-metadata": '{"user":"alice","team":"platform"}',
},
)

client.chat.completions.create(
model="gpt-5",
messages=[{"role": "user", "content": "ping"}],
)

Running a LiteLLM proxy? Put the gateway in front of it; both topologies, front-door and in-process attach, are on the LiteLLM page.