Skip to content

Commit aa978c7

Browse files
committed
control for api client changes
1 parent c4ed576 commit aa978c7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

guardrails/api_client.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import os
3+
import sys
34
from typing import Any, Iterator, Optional
45

56
import requests
@@ -37,10 +38,15 @@ def __init__(self, base_url: Optional[str] = None, api_key: Optional[str] = None
3738
api_key if api_key is not None else os.environ.get("GUARDRAILS_API_KEY", "")
3839
)
3940
self.timeout = 300
41+
42+
_api_key = (
43+
self.api_key
44+
if sys.version_info.minor < 10
45+
else {"ApiKeyAuth": self.api_key}
46+
)
47+
4048
self._api_client = ApiClient(
41-
configuration=Configuration(
42-
api_key={"ApiKeyAuth": self.api_key}, host=self.base_url
43-
)
49+
configuration=Configuration(api_key=_api_key, host=self.base_url) # type: ignore
4450
)
4551
self._guard_api = GuardApi(self._api_client)
4652
self._validate_api = ValidateApi(self._api_client)

0 commit comments

Comments
 (0)