Spaces:
Running
Running
import os | |
from openai import OpenAI | |
def init_llm_client(api_key, model_id, base_url=None): | |
""" | |
Initialize the OpenAI client with the provided API key and model ID. | |
""" | |
if base_url: | |
os.environ["OPENAI_API_BASE"] = base_url | |
os.environ["OPENAI_API_KEY"] = api_key | |
os.environ["OPENAI_MODEL_ID"] = model_id | |
return OpenAI(api_key=api_key, model_id=model_id, base_url=base_url) | |