I've read through this several times and there are some gaps.
This line "apiKey: environment.OPENAI_API_KEY" throws a "Property 'OPENAI_API_KEY' does not exist on type" ...... Error. I am searching for a resolution and have been unsuucessful.
I copied and pasted your "rxjs" code. It needs the import statement..which was not mentioned. "import { filter, from, map } from 'rxjs'";