Currently, the /threads endpoint initializes the OpenAI client like this:
" client = OpenAI(api_key=settings.OPENAI_API_KEY)"
This pulls the API key from the global .env file, which is not ideal for multi-tenant setups.
Expected Behavior
The endpoint should:
Currently, the /threads endpoint initializes the OpenAI client like this:
" client = OpenAI(api_key=settings.OPENAI_API_KEY)"
This pulls the API key from the global .env file, which is not ideal for multi-tenant setups.
Expected Behavior
The endpoint should:
Fetch the OpenAI API key from the credentials table based on the authenticated user's organization (UserOrganization)
Use that API key when initializing the OpenAI client