airia 0.1.4__py3-none-any.whl → 0.1.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- airia/client/async_client.py +22 -6
- airia/client/base_client.py +2 -1
- airia/client/sync_client.py +21 -5
- {airia-0.1.4.dist-info → airia-0.1.5.dist-info}/METADATA +19 -3
- {airia-0.1.4.dist-info → airia-0.1.5.dist-info}/RECORD +8 -8
- {airia-0.1.4.dist-info → airia-0.1.5.dist-info}/WHEEL +0 -0
- {airia-0.1.4.dist-info → airia-0.1.5.dist-info}/licenses/LICENSE +0 -0
- {airia-0.1.4.dist-info → airia-0.1.5.dist-info}/top_level.txt +0 -0
airia/client/async_client.py
CHANGED
|
@@ -21,6 +21,7 @@ class AiriaAsyncClient(AiriaBaseClient):
|
|
|
21
21
|
|
|
22
22
|
def __init__(
|
|
23
23
|
self,
|
|
24
|
+
base_url: str = "https://api.airia.ai/",
|
|
24
25
|
api_key: Optional[str] = None,
|
|
25
26
|
timeout: float = 30.0,
|
|
26
27
|
log_requests: bool = False,
|
|
@@ -30,20 +31,29 @@ class AiriaAsyncClient(AiriaBaseClient):
|
|
|
30
31
|
Initialize the asynchronous Airia API client.
|
|
31
32
|
|
|
32
33
|
Args:
|
|
34
|
+
base_url: Base URL of the Airia API.
|
|
33
35
|
api_key: API key for authentication. If not provided, will attempt to use AIRIA_API_KEY environment variable.
|
|
34
36
|
timeout: Request timeout in seconds.
|
|
35
37
|
log_requests: Whether to log API requests and responses. Default is False.
|
|
36
38
|
custom_logger: Optional custom logger object to use for logging. If not provided, will use a default logger when `log_requests` is True.
|
|
37
39
|
"""
|
|
38
|
-
super().__init__(
|
|
40
|
+
super().__init__(
|
|
41
|
+
base_url=base_url,
|
|
42
|
+
api_key=api_key,
|
|
43
|
+
timeout=timeout,
|
|
44
|
+
log_requests=log_requests,
|
|
45
|
+
custom_logger=custom_logger,
|
|
46
|
+
)
|
|
39
47
|
|
|
40
48
|
# Session will be initialized in __aenter__
|
|
41
49
|
self.session = None
|
|
42
50
|
self.headers = {"Content-Type": "application/json"}
|
|
43
|
-
|
|
51
|
+
|
|
44
52
|
@classmethod
|
|
45
53
|
def with_openai_gateway(
|
|
46
54
|
cls,
|
|
55
|
+
base_url: str = "https://api.airia.ai/",
|
|
56
|
+
gateway_url: str = "https://gateway.airia.ai/openai/v1",
|
|
47
57
|
api_key: Optional[str] = None,
|
|
48
58
|
timeout: float = 30.0,
|
|
49
59
|
log_requests: bool = False,
|
|
@@ -54,6 +64,8 @@ class AiriaAsyncClient(AiriaBaseClient):
|
|
|
54
64
|
Initialize the asynchronous Airia API client with AsyncOpenAI gateway capabilities.
|
|
55
65
|
|
|
56
66
|
Args:
|
|
67
|
+
base_url: Base URL of the Airia API.
|
|
68
|
+
gateway_url: Base URL of the Airia Gateway API.
|
|
57
69
|
api_key: API key for authentication. If not provided, will attempt to use AIRIA_API_KEY environment variable.
|
|
58
70
|
timeout: Request timeout in seconds.
|
|
59
71
|
log_requests: Whether to log API requests and responses. Default is False.
|
|
@@ -65,15 +77,17 @@ class AiriaAsyncClient(AiriaBaseClient):
|
|
|
65
77
|
api_key = cls._get_api_key(api_key)
|
|
66
78
|
cls.openai = AsyncOpenAI(
|
|
67
79
|
api_key=api_key,
|
|
68
|
-
base_url=
|
|
80
|
+
base_url=gateway_url,
|
|
69
81
|
**kwargs,
|
|
70
82
|
)
|
|
71
83
|
|
|
72
|
-
return cls(api_key, timeout, log_requests, custom_logger)
|
|
84
|
+
return cls(base_url, api_key, timeout, log_requests, custom_logger)
|
|
73
85
|
|
|
74
86
|
@classmethod
|
|
75
87
|
def with_anthropic_gateway(
|
|
76
88
|
cls,
|
|
89
|
+
base_url: str = "https://api.airia.ai/",
|
|
90
|
+
gateway_url: str = "https://gateway.airia.ai/anthropic",
|
|
77
91
|
api_key: Optional[str] = None,
|
|
78
92
|
timeout: float = 30.0,
|
|
79
93
|
log_requests: bool = False,
|
|
@@ -84,6 +98,8 @@ class AiriaAsyncClient(AiriaBaseClient):
|
|
|
84
98
|
Initialize the asynchronous Airia API client with AsyncAnthropic gateway capabilities.
|
|
85
99
|
|
|
86
100
|
Args:
|
|
101
|
+
base_url: Base URL of the Airia API.
|
|
102
|
+
gateway_url: Base URL of the Airia Gateway API.
|
|
87
103
|
api_key: API key for authentication. If not provided, will attempt to use AIRIA_API_KEY environment variable.
|
|
88
104
|
timeout: Request timeout in seconds.
|
|
89
105
|
log_requests: Whether to log API requests and responses. Default is False.
|
|
@@ -95,11 +111,11 @@ class AiriaAsyncClient(AiriaBaseClient):
|
|
|
95
111
|
api_key = cls._get_api_key(api_key)
|
|
96
112
|
cls.anthropic = AsyncAnthropic(
|
|
97
113
|
api_key=api_key,
|
|
98
|
-
base_url=
|
|
114
|
+
base_url=gateway_url,
|
|
99
115
|
**kwargs,
|
|
100
116
|
)
|
|
101
117
|
|
|
102
|
-
return cls(api_key, timeout, log_requests, custom_logger)
|
|
118
|
+
return cls(base_url, api_key, timeout, log_requests, custom_logger)
|
|
103
119
|
|
|
104
120
|
async def __aenter__(self):
|
|
105
121
|
"""Async context manager entry point."""
|
airia/client/base_client.py
CHANGED
|
@@ -16,6 +16,7 @@ class AiriaBaseClient:
|
|
|
16
16
|
|
|
17
17
|
def __init__(
|
|
18
18
|
self,
|
|
19
|
+
base_url: str = "https://api.airia.ai/",
|
|
19
20
|
api_key: Optional[str] = None,
|
|
20
21
|
timeout: float = 30.0,
|
|
21
22
|
log_requests: bool = False,
|
|
@@ -34,7 +35,7 @@ class AiriaBaseClient:
|
|
|
34
35
|
self.api_key = self.__class__._get_api_key(api_key)
|
|
35
36
|
|
|
36
37
|
# Store configuration
|
|
37
|
-
self.base_url =
|
|
38
|
+
self.base_url = base_url
|
|
38
39
|
self.timeout = timeout
|
|
39
40
|
self.log_requests = log_requests
|
|
40
41
|
|
airia/client/sync_client.py
CHANGED
|
@@ -21,6 +21,7 @@ class AiriaClient(AiriaBaseClient):
|
|
|
21
21
|
|
|
22
22
|
def __init__(
|
|
23
23
|
self,
|
|
24
|
+
base_url: str = "https://api.airia.ai/",
|
|
24
25
|
api_key: Optional[str] = None,
|
|
25
26
|
timeout: float = 30.0,
|
|
26
27
|
log_requests: bool = False,
|
|
@@ -30,12 +31,19 @@ class AiriaClient(AiriaBaseClient):
|
|
|
30
31
|
Initialize the synchronous Airia API client.
|
|
31
32
|
|
|
32
33
|
Args:
|
|
34
|
+
base_url: Base URL of the Airia API.
|
|
33
35
|
api_key: API key for authentication. If not provided, will attempt to use AIRIA_API_KEY environment variable.
|
|
34
36
|
timeout: Request timeout in seconds.
|
|
35
37
|
log_requests: Whether to log API requests and responses. Default is False.
|
|
36
38
|
custom_logger: Optional custom logger object to use for logging. If not provided, will use a default logger when `log_requests` is True.
|
|
37
39
|
"""
|
|
38
|
-
super().__init__(
|
|
40
|
+
super().__init__(
|
|
41
|
+
base_url=base_url,
|
|
42
|
+
api_key=api_key,
|
|
43
|
+
timeout=timeout,
|
|
44
|
+
log_requests=log_requests,
|
|
45
|
+
custom_logger=custom_logger,
|
|
46
|
+
)
|
|
39
47
|
|
|
40
48
|
# Initialize session for synchronous requests
|
|
41
49
|
self.session = requests.Session()
|
|
@@ -44,6 +52,8 @@ class AiriaClient(AiriaBaseClient):
|
|
|
44
52
|
@classmethod
|
|
45
53
|
def with_openai_gateway(
|
|
46
54
|
cls,
|
|
55
|
+
base_url: str = "https://api.airia.ai/",
|
|
56
|
+
gateway_url: str = "https://gateway.airia.ai/openai/v1",
|
|
47
57
|
api_key: Optional[str] = None,
|
|
48
58
|
timeout: float = 30.0,
|
|
49
59
|
log_requests: bool = False,
|
|
@@ -54,6 +64,8 @@ class AiriaClient(AiriaBaseClient):
|
|
|
54
64
|
Initialize the synchronous Airia API client with OpenAI gateway capabilities.
|
|
55
65
|
|
|
56
66
|
Args:
|
|
67
|
+
base_url: Base URL of the Airia API.
|
|
68
|
+
gateway_url: Base URL of the Airia Gateway API.
|
|
57
69
|
api_key: API key for authentication. If not provided, will attempt to use AIRIA_API_KEY environment variable.
|
|
58
70
|
timeout: Request timeout in seconds.
|
|
59
71
|
log_requests: Whether to log API requests and responses. Default is False.
|
|
@@ -65,15 +77,17 @@ class AiriaClient(AiriaBaseClient):
|
|
|
65
77
|
api_key = cls._get_api_key(api_key)
|
|
66
78
|
cls.openai = OpenAI(
|
|
67
79
|
api_key=api_key,
|
|
68
|
-
base_url=
|
|
80
|
+
base_url=gateway_url,
|
|
69
81
|
**kwargs,
|
|
70
82
|
)
|
|
71
83
|
|
|
72
|
-
return cls(api_key, timeout, log_requests, custom_logger)
|
|
84
|
+
return cls(base_url, api_key, timeout, log_requests, custom_logger)
|
|
73
85
|
|
|
74
86
|
@classmethod
|
|
75
87
|
def with_anthropic_gateway(
|
|
76
88
|
cls,
|
|
89
|
+
base_url: str = "https://api.airia.ai/",
|
|
90
|
+
gateway_url: str = "https://gateway.airia.ai/anthropic",
|
|
77
91
|
api_key: Optional[str] = None,
|
|
78
92
|
timeout: float = 30.0,
|
|
79
93
|
log_requests: bool = False,
|
|
@@ -84,6 +98,8 @@ class AiriaClient(AiriaBaseClient):
|
|
|
84
98
|
Initialize the synchronous Airia API client with Anthropic gateway capabilities.
|
|
85
99
|
|
|
86
100
|
Args:
|
|
101
|
+
base_url: Base URL of the Airia API.
|
|
102
|
+
gateway_url: Base URL of the Airia Gateway API.
|
|
87
103
|
api_key: API key for authentication. If not provided, will attempt to use AIRIA_API_KEY environment variable.
|
|
88
104
|
timeout: Request timeout in seconds.
|
|
89
105
|
log_requests: Whether to log API requests and responses. Default is False.
|
|
@@ -95,11 +111,11 @@ class AiriaClient(AiriaBaseClient):
|
|
|
95
111
|
api_key = cls._get_api_key(api_key)
|
|
96
112
|
cls.anthropic = Anthropic(
|
|
97
113
|
api_key=api_key,
|
|
98
|
-
base_url=
|
|
114
|
+
base_url=gateway_url,
|
|
99
115
|
**kwargs,
|
|
100
116
|
)
|
|
101
117
|
|
|
102
|
-
return cls(api_key, timeout, log_requests, custom_logger)
|
|
118
|
+
return cls(base_url, api_key, timeout, log_requests, custom_logger)
|
|
103
119
|
|
|
104
120
|
def _handle_exception(self, e: requests.HTTPError, url: str, correlation_id: str):
|
|
105
121
|
# Log the error response if enabled
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: airia
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: Python SDK for Airia API
|
|
5
5
|
Author-email: Airia LLC <support@airia.com>
|
|
6
6
|
License: MIT
|
|
@@ -176,6 +176,20 @@ This will create both wheel and source distribution in the `dist/` directory.
|
|
|
176
176
|
|
|
177
177
|
## Quick Start
|
|
178
178
|
|
|
179
|
+
### Client Instantiation
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
from airia import AiriaClient
|
|
183
|
+
|
|
184
|
+
client = AiriaClient(
|
|
185
|
+
base_url="https://api.airia.com", # Default: "https://api.airia.com"
|
|
186
|
+
api_key=None, # Or set AIRIA_API_KEY environment variable
|
|
187
|
+
timeout=30.0, # Request timeout in seconds (default: 30.0)
|
|
188
|
+
log_requests=False, # Enable request/response logging (default: False)
|
|
189
|
+
custom_logger=None # Use custom logger (default: None - uses built-in)
|
|
190
|
+
)
|
|
191
|
+
```
|
|
192
|
+
|
|
179
193
|
### Synchronous Usage
|
|
180
194
|
|
|
181
195
|
```python
|
|
@@ -208,7 +222,7 @@ response = client.execute_pipeline(
|
|
|
208
222
|
async_output=True
|
|
209
223
|
)
|
|
210
224
|
|
|
211
|
-
for c in
|
|
225
|
+
for c in response.stream:
|
|
212
226
|
print(c, end="")
|
|
213
227
|
```
|
|
214
228
|
|
|
@@ -244,7 +258,7 @@ async def main():
|
|
|
244
258
|
user_input="Tell me about quantum computing",
|
|
245
259
|
async_output=True
|
|
246
260
|
)
|
|
247
|
-
async for c in
|
|
261
|
+
async for c in response.stream:
|
|
248
262
|
print(c, end="")
|
|
249
263
|
|
|
250
264
|
asyncio.run(main())
|
|
@@ -292,6 +306,8 @@ response = client.anthropic.messages.create(
|
|
|
292
306
|
print(response.content[0].text)
|
|
293
307
|
```
|
|
294
308
|
|
|
309
|
+
You can set the Gateway URL by passing the `gateway_url` parameter when using the gateway constructors. The default values are `https://gateway.airia.ai/openai/v1` for OpenAI and `https://gateway.airia.ai/anthropic` for Anthropic.
|
|
310
|
+
|
|
295
311
|
### Asynchronous Gateway Usage
|
|
296
312
|
|
|
297
313
|
Both gateways also support asynchronous usage:
|
|
@@ -2,15 +2,15 @@ airia/__init__.py,sha256=T39gO8E5T5zxlw-JP78ruxOu7-LeKOJCJzz6t40kdQo,231
|
|
|
2
2
|
airia/exceptions.py,sha256=4Z55n-cRJrtTa5-pZBIK2oZD4-Z99aUtKx_kfTFYY5o,1146
|
|
3
3
|
airia/logs.py,sha256=17YZ4IuzOF0m5bgofj9-QYlJ2BYR2kRZbBVQfFSLFEk,5441
|
|
4
4
|
airia/client/__init__.py,sha256=6gSQ9bl7j79q1HPE0o5py3IRdkwWWuU_7J4h05Dd2o8,127
|
|
5
|
-
airia/client/async_client.py,sha256=
|
|
6
|
-
airia/client/base_client.py,sha256=
|
|
7
|
-
airia/client/sync_client.py,sha256=
|
|
5
|
+
airia/client/async_client.py,sha256=4JU6RePXjznulnQXkfo9ZVX3zLeUyclOgxwlaM7-5Js,18816
|
|
6
|
+
airia/client/base_client.py,sha256=IEVsskGpiEL3jw7YLc96YWUZ5rpUZula52IZHe2D8mE,6844
|
|
7
|
+
airia/client/sync_client.py,sha256=mCLViWkW-z8QhCy8CmlEsT8dssBb1g6V2B3fAYgYU1A,18336
|
|
8
8
|
airia/types/__init__.py,sha256=OOFtJ0VIbO98px89u7cq645iL7CYDOel43g85IAjRRw,562
|
|
9
9
|
airia/types/api_version.py,sha256=Uzom6O2ZG92HN_Z2h-lTydmO2XYX9RVs4Yi4DJmXytE,255
|
|
10
10
|
airia/types/pipeline_execution.py,sha256=obp8KOz-ShNxEciF1YQCSpHXPoJUyEa_9uPv-VHf6YA,699
|
|
11
11
|
airia/types/request_data.py,sha256=RbVPWPRIYuT7FaolJKn19IVzuQKbLM4VhXM5r7UXTUY,186
|
|
12
|
-
airia-0.1.
|
|
13
|
-
airia-0.1.
|
|
14
|
-
airia-0.1.
|
|
15
|
-
airia-0.1.
|
|
16
|
-
airia-0.1.
|
|
12
|
+
airia-0.1.5.dist-info/licenses/LICENSE,sha256=R3ClUMMKPRItIcZ0svzyj2taZZnFYw568YDNzN9KQ1Q,1066
|
|
13
|
+
airia-0.1.5.dist-info/METADATA,sha256=WIPLholUrToVlvO4K269qOSYHT4fD7XHpVSrjowOF6A,10745
|
|
14
|
+
airia-0.1.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
15
|
+
airia-0.1.5.dist-info/top_level.txt,sha256=qUQEKfs_hdOYTwjKj1JZbRhS5YeXDNaKQaVTrzabS6w,6
|
|
16
|
+
airia-0.1.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|