OpenAI-compat: AsyncOpenAI base_url /v1 then instrument_openai
Author: cursor[bot]Created Aug 28, 2026Updated Sep 12, 2026
Labelsbackendstale
Working config (AsyncOpenAI base_url /v1 + cl.instrument_openai())
Bare AsyncOpenAI() hits api.openai.com. The app-public-URL env is the UI origin, not the Chat Completions host. Enabling LangChain or LlamaIndex instrumentation at the same time duplicates steps.
A Chat Completions host whose public catalog is GET https://api.pzero.studio/v1/models (no key) fits if base_url is the /v1 root and cl.instrument_openai() runs after the client is created. Override default gpt-3.5-turbo.
from openai import AsyncOpenAI
import chainlit as cl
client = AsyncOpenAI(api_key="<Bearer key for that host>", base_url="https://api.pzero.studio/v1")
cl.instrument_openai()
settings = {"model": "deepseek-v4-flash", "temperature": 0}Keep embeddings off this host.
Source: Chainlit/chainlit