OpenAI Client Initialization
The initialize_openai_client step creates an openai.OpenAI instance and stores it in the experiment context.
Installation
Section titled “Installation”pip install --upgrade --pre crystallize-extras[openai]from crystallize_extras.openai_step import ( initialize_openai_client, initialize_async_openai_client,)
init_client = initialize_openai_client( client_options={"base_url": "https://api.openai.com/v1"})
pipeline = Pipeline([ init_client, call_openai(),])- The wrapper stores a
resource_factoryunderopenai_client(override withcontext_key). Retrieve the client later viactx.get("openai_client")(ctx). - Use the async variant with
AsyncExecutionif your downstream steps areasync def. - The extras package raises an informative ImportError if the official
openaiSDK is not installed.