1. Directly set the environment variable, the code is as follows
API_SECRET_KEY = "sk-xxx" #302.AI Backend-Use API-API Keys generated API KEY
BASE_URL = "https://api.302.ai/v1/chat/completions"; #302.AI's base-url
os.environ["OPENAI_API_KEY"] = API_SECRET_KEY
os.environ["OPENAI_BASE_URL"] = BASE_URL
(Note: Add /v1 to the end of BASE_URL)
2. Call in the code
from langchain_openai import ChatOpenAI,OpenAI
llm = OpenAI(model_name='gpt-4o-mini',
openai_api_key='sk-xxxx', #302.AI Backend-Use API-API Keys generated API KEY
openai_api_base='https://api.302.ai/v1/chat/completions',) #302.AI's base-url