| 8 | |
| 9 | |
| 10 | def configure_openpipe_clients( |
| 11 | reporting_client: Union[OpenPipe, AsyncOpenPipe], |
| 12 | completions_client: Union[OpenAI, AsyncOpenAI], |
| 13 | openpipe_options={}, |
| 14 | ): |
| 15 | completions_client.base_url = "https://app.openpipe.ai/api/v1" |
| 16 | if os.environ.get("OPENPIPE_API_KEY"): |
| 17 | reporting_client.api_key = os.environ["OPENPIPE_API_KEY"] |
| 18 | completions_client.api_key = os.environ["OPENPIPE_API_KEY"] |
| 19 | |
| 20 | if os.environ.get("OPENPIPE_BASE_URL"): |
| 21 | reporting_client.base_url = os.environ["OPENPIPE_BASE_URL"] |
| 22 | completions_client.base_url = os.environ["OPENPIPE_BASE_URL"] |
| 23 | |
| 24 | if openpipe_options and openpipe_options.get("api_key"): |
| 25 | reporting_client.api_key = openpipe_options["api_key"] |
| 26 | completions_client.api_key = openpipe_options["api_key"] |
| 27 | |
| 28 | if openpipe_options and openpipe_options.get("base_url"): |
| 29 | reporting_client.base_url = openpipe_options["base_url"] |
| 30 | completions_client.base_url = openpipe_options["base_url"] |
| 31 | |
| 32 | |
| 33 | def get_extra_headers(create_kwargs, openpipe_options): |