You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Full Changelog: [v0.0.1-alpha.0...v0.1.0-alpha.1](https://github.com/hanzoai/python-sdk/compare/v0.0.1-alpha.0...v0.1.0-alpha.1)
6
+
7
+
### Features
8
+
9
+
***api:** update via SDK Studio ([#4](https://github.com/hanzoai/python-sdk/issues/4)) ([e5137ed](https://github.com/hanzoai/python-sdk/commit/e5137ed411811a52ff9b7cc0e44a678ef3f3065e))
10
+
11
+
12
+
### Chores
13
+
14
+
* go live ([#1](https://github.com/hanzoai/python-sdk/issues/1)) ([c1f495e](https://github.com/hanzoai/python-sdk/commit/c1f495ea0e560ada8c76c571b42928bf8e1b5ee5))
Alternatively, you can build from source and install the wheel file:
@@ -121,7 +121,7 @@ the changes aren't made through the automated pipeline, you may want to make rel
121
121
122
122
### Publish with a GitHub workflow
123
123
124
-
You can release to package managers by using [the `Publish PyPI` GitHub action](https://github.com/stainless-sdks/Hanzo-AI-python/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.
124
+
You can release to package managers by using [the `Publish PyPI` GitHub action](https://github.com/hanzoai/python-sdk/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.
The Hanzo AI Python library provides convenient access to the Hanzo AI REST API from any Python 3.8+
5
+
The Hanzo Python library provides convenient access to the Hanzo REST API from any Python 3.8+
6
6
application. The library includes type definitions for all request params and response fields,
7
7
and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).
8
8
9
9
It is generated with [Stainless](https://www.stainless.com/).
10
10
11
11
## Documentation
12
12
13
-
The REST API documentation can be found on [docs.hanzo-ai.com](https://docs.Hanzo-AI.com). The full API of this library can be found in [api.md](api.md).
13
+
The REST API documentation can be found on [docs.hanzo.ai](https://docs.hanzo.ai). The full API of this library can be found in [api.md](api.md).
> Once this package is [published to PyPI](https://app.stainless.com/docs/guides/publish), this will become: `pip install --pre Hanzo_AI`
24
-
25
22
## Usage
26
23
27
24
The full API of this library can be found in [api.md](api.md).
28
25
29
26
```python
30
27
import os
31
-
fromHanzo_AIimportHanzoAI
28
+
fromhanzoaiimportHanzo
32
29
33
-
client =HanzoAI(
34
-
api_key=os.environ.get("HANZO_AI_API_KEY"), # This is the default and can be omitted
30
+
client =Hanzo(
31
+
api_key=os.environ.get("HANZO_API_KEY"), # This is the default and can be omitted
35
32
)
36
33
37
34
response = client.get_home()
38
35
```
39
36
40
37
While you can provide an `api_key` keyword argument,
41
38
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
42
-
to add `HANZO_AI_API_KEY="My API Key"` to your `.env` file
39
+
to add `HANZO_API_KEY="My API Key"` to your `.env` file
43
40
so that your API Key is not stored in source control.
44
41
45
42
## Async usage
46
43
47
-
Simply import `AsyncHanzoAI` instead of `HanzoAI` and use `await` with each API call:
44
+
Simply import `AsyncHanzo` instead of `Hanzo` and use `await` with each API call:
48
45
49
46
```python
50
47
import os
51
48
import asyncio
52
-
fromHanzo_AIimportAsyncHanzoAI
49
+
fromhanzoaiimportAsyncHanzo
53
50
54
-
client =AsyncHanzoAI(
55
-
api_key=os.environ.get("HANZO_AI_API_KEY"), # This is the default and can be omitted
51
+
client =AsyncHanzo(
52
+
api_key=os.environ.get("HANZO_API_KEY"), # This is the default and can be omitted
56
53
)
57
54
58
55
@@ -79,9 +76,9 @@ Typed requests and responses provide autocomplete and documentation within your
79
76
Nested parameters are dictionaries, typed using `TypedDict`, for example:
80
77
81
78
```python
82
-
fromHanzo_AIimportHanzoAI
79
+
fromhanzoaiimportHanzo
83
80
84
-
client =HanzoAI()
81
+
client =Hanzo()
85
82
86
83
model = client.model.create(
87
84
litellm_params={
@@ -129,9 +126,9 @@ Request parameters that correspond to file uploads can be passed as `bytes`, a [
129
126
130
127
```python
131
128
from pathlib import Path
132
-
fromHanzo_AIimportHanzoAI
129
+
fromhanzoaiimportHanzo
133
130
134
-
client =HanzoAI()
131
+
client =Hanzo()
135
132
136
133
client.audio.transcriptions.create(
137
134
file=Path("/path/to/file"),
@@ -142,27 +139,27 @@ The async client uses the exact same interface. If you pass a [`PathLike`](https
142
139
143
140
## Handling errors
144
141
145
-
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `Hanzo_AI.APIConnectionError` is raised.
142
+
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `hanzoai.APIConnectionError` is raised.
146
143
147
144
When the API returns a non-success status code (that is, 4xx or 5xx
148
-
response), a subclass of `Hanzo_AI.APIStatusError` is raised, containing `status_code` and `response` properties.
145
+
response), a subclass of `hanzoai.APIStatusError` is raised, containing `status_code` and `response` properties.
149
146
150
-
All errors inherit from `Hanzo_AI.APIError`.
147
+
All errors inherit from `hanzoai.APIError`.
151
148
152
149
```python
153
-
importHanzo_AI
154
-
fromHanzo_AIimportHanzoAI
150
+
importhanzoai
151
+
fromhanzoaiimportHanzo
155
152
156
-
client =HanzoAI()
153
+
client =Hanzo()
157
154
158
155
try:
159
156
client.get_home()
160
-
exceptHanzo_AI.APIConnectionError as e:
157
+
excepthanzoai.APIConnectionError as e:
161
158
print("The server could not be reached")
162
159
print(e.__cause__) # an underlying Exception, likely raised within httpx.
163
-
exceptHanzo_AI.RateLimitError as e:
160
+
excepthanzoai.RateLimitError as e:
164
161
print("A 429 status code was received; we should back off a bit.")
165
-
exceptHanzo_AI.APIStatusError as e:
162
+
excepthanzoai.APIStatusError as e:
166
163
print("Another non-200-range status code was received")
167
164
print(e.status_code)
168
165
print(e.response)
@@ -190,10 +187,10 @@ Connection errors (for example, due to a network connectivity problem), 408 Requ
190
187
You can use the `max_retries` option to configure or disable retry settings:
191
188
192
189
```python
193
-
fromHanzo_AIimportHanzoAI
190
+
fromhanzoaiimportHanzo
194
191
195
192
# Configure the default for all requests:
196
-
client =HanzoAI(
193
+
client =Hanzo(
197
194
# default is 2
198
195
max_retries=0,
199
196
)
@@ -208,16 +205,16 @@ By default requests time out after 1 minute. You can configure this with a `time
208
205
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:
@@ -235,10 +232,10 @@ Note that requests that time out are [retried twice by default](#retries).
235
232
236
233
We use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.
237
234
238
-
You can enable logging by setting the environment variable `HANZO_AI_LOG` to `info`.
235
+
You can enable logging by setting the environment variable `HANZO_LOG` to `info`.
239
236
240
237
```shell
241
-
$ exportHANZO_AI_LOG=info
238
+
$ exportHANZO_LOG=info
242
239
```
243
240
244
241
Or to `debug` for more verbose logging.
@@ -260,19 +257,19 @@ if response.my_field is None:
260
257
The "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,
261
258
262
259
```py
263
-
fromHanzo_AIimportHanzoAI
260
+
fromhanzoaiimportHanzo
264
261
265
-
client =HanzoAI()
262
+
client =Hanzo()
266
263
response = client.with_raw_response.get_home()
267
264
print(response.headers.get('X-My-Header'))
268
265
269
266
client = response.parse() # get the object that `get_home()` would have returned
270
267
print(client)
271
268
```
272
269
273
-
These methods return an [`APIResponse`](https://github.com/stainless-sdks/Hanzo-AI-python/tree/main/src/Hanzo_AI/_response.py) object.
270
+
These methods return an [`APIResponse`](https://github.com/hanzoai/python-sdk/tree/main/src/hanzoai/_response.py) object.
274
271
275
-
The async client returns an [`AsyncAPIResponse`](https://github.com/stainless-sdks/Hanzo-AI-python/tree/main/src/Hanzo_AI/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
272
+
The async client returns an [`AsyncAPIResponse`](https://github.com/hanzoai/python-sdk/tree/main/src/hanzoai/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
276
273
277
274
#### `.with_streaming_response`
278
275
@@ -334,10 +331,10 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c
By default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.
358
355
359
356
```py
360
-
fromHanzo_AIimportHanzoAI
357
+
fromhanzoaiimportHanzo
361
358
362
-
withHanzoAI() as client:
359
+
withHanzo() as client:
363
360
# make requests here
364
361
...
365
362
@@ -376,7 +373,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
376
373
377
374
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
378
375
379
-
We are keen for your feedback; please open an [issue](https://github.com/stainless-sdks/Hanzo-AI-python/issues) with questions, bugs, or suggestions.
376
+
We are keen for your feedback; please open an [issue](https://github.com/hanzoai/python-sdk/issues) with questions, bugs, or suggestions.
380
377
381
378
### Determining the installed version
382
379
@@ -385,8 +382,8 @@ If you've upgraded to the latest version but aren't seeing any new features you
385
382
You can determine the version that is being used at runtime with:
0 commit comments