Is there a global setting I can update instead of ...
# ask-ai
w
Is there a global setting I can update instead of hardcodding base url for openAI?
t
Thanks for reaching out, Ilya. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! To make things easier and avoid hardcoding the base URL in your app, you can set a global configuration. Here are a couple of friendly ways to do it: • Environment Variables: Try using the
OPENAI_BASE_URL
environment variable. This acts as a handy fallback if you don’t specify a base URL directly in your code. For example:
Copy code
import os
API_BASE_URL = os.getenv('OPENAI_BASE_URL', '<DEFAULT_API_BASE_URL>')
Per-Instance Configuration: You can also set the base URL when you create instances for integrations like Ollama or Letta. Here’s how that looks:
Copy code
from livekit.plugins import openai
session = AgentSession(
    llm=openai.LLM.with_ollama(
        model="llama3.1",
        base_url="<CUSTOM_BASE_URL>",
    ),
)
If you want, I’m here to help with any specific integration or deployment questions you have—just let me know!