import os from openai import OpenAI import urllib def init_llm_client(api_key, base_url=None): """ Initialize the OpenAI client with the provided API key and model ID. """ if base_url and len(base_url) > 0 and base_url.startswith("http"): os.environ["OPENAI_API_BASE"] = base_url else: base_url = None os.environ["OPENAI_API_KEY"] = api_key return OpenAI(api_key=api_key, base_url=base_url)