These examples make the same three OCI Generative AI chat API calls using the synchronous client, the asynchronous client, or both clients for comparison.
Set the required compartment OCID before running an example:
export OCI_COMPARTMENT_ID="ocid1.compartment..."
python examples/SyncAsync/async_calls_example.py
python examples/SyncAsync/sync_calls_example.py
python examples/SyncAsync/sync_async_calls_example.pyThe examples read the DEFAULT profile from ~/.oci/config. These optional
environment variables override the defaults:
OCI_CONFIG_FILE: OCI config file pathOCI_CONFIG_PROFILE: profile nameOCI_GENAI_MODEL_ID: on-demand chat model IDOCI_GENAI_ENDPOINT: Generative AI inference endpoint
The async example uses asyncio.gather so that its three calls are in flight at
the same time. The sync example performs the calls one after another. The
combined example runs both approaches and prints their elapsed times.