I'm using Livekit infrence for LLM, can i pass oth...
# ask-ai
e
I'm using Livekit infrence for LLM, can i pass other provider like this, by specifying api_key and base_url
Copy code
from livekit.agents import AgentSession, inference

session = AgentSession(
    llm=inference.LLM(
        model="gpt-oss-120b",      # host model name
        provider="openai",         # or other provider name
        api_key="YOUR_API_KEY",     # from the inference provider
        base_url="<https://api.provider.com/v1>",  # custom endpoint
    ),
    # other LiveKit settings (tts, stt, etc.)
)
t
Thanks for reaching out, Aman. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking whether you can pass a custom
api_key
and
base_url
to
inference.LLM
to use another provider. Short answer: no — LiveKit Inference is a managed gateway and does not accept
api_key
or
base_url
. What you can do: • Use a plugin instead (for example
livekit.plugins.openai.LLM
) which lets you specify
api_key
and
base_url
for OpenAI‑compatible providers. Example using the OpenAI plugin:
Copy code
from livekit.agents import AgentSession
from livekit.plugins import openai

session = AgentSession(
    llm=openai.LLM(
        model="model-name",
        base_url="<https://api.provider.com/v1>",
        api_key="YOUR_API_KEY"
    ),
    # other settings...
)
If you want, tell me which provider you plan to use and I can show the exact plugin usage or confirm compatibility. Sources: Models | LiveKit Docs | Introducing LiveKit Inference: A unified model interface for voice AI | Qwen LLM | LiveKit Docs | OpenAI and LiveKit | LiveKit docs
e
t
Thanks — good to know you're using Qubrid. Does Qubrid expose an OpenAI‑compatible API (same endpoints and request/response shapes, or a custom OpenAI‑compat base_url)? • If yes: use the OpenAI plugin (
livekit.plugins.openai.LLM
) and set
base_url
and
api_key
as shown earlier. • If no (custom API): I can help you either build a small custom plugin adapter or map Qubrid’s API to LiveKit’s plugin interface. Please tell me which of these is true for Qubrid (OpenAI‑compatible or not), and if possible paste an example request/response from Qubrid’s API (auth header and chat/completion endpoint) so I can give exact code snippets.
e
yes it exposes open ai compatiable
can you share example
t
You're using an OpenAI-compatible provider (Qubrid). Use the OpenAI plugin so you can pass
base_url
and
api_key
. Example:
Copy code
from livekit.agents import AgentSession
from livekit.plugins import openai

session = AgentSession(
    llm=openai.LLM(
        model="gpt-4o-mini",                        # Qubrid model name
        base_url="<https://platform.qubrid.com/v1>",  # Qubrid base URL (example)
        api_key="YOUR_QUBRID_API_KEY",
    ),
    # other LiveKit settings (tts, stt, etc.)
)

# Example: ask a simple chat prompt via the session API
response = session.chat.create(
    messages=[{"role": "user", "content": "Summarize the benefits of using Qubrid with LiveKit."}]
)

print(response.choices[0].message["content"])
Notes: • Replace
model
,
base_url
, and
api_key
with the exact values Qubrid provides. • If Qubrid’s OpenAI-compat path differs (e.g.,
/v1/openai
), use that full base URL. • Tell me the exact base URL or a sample request/response if you want a tailored snippet or if you run into auth/response shape issues.