Spaces:
Running
Running
File size: 411 Bytes
c25ce6b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
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)
|