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
***ci:** release-doctor — report correct token name ([6ddb78b](https://github.com/hyperspell/python-sdk/commit/6ddb78b355f8e36a85fcfaf1592618bae5c67473))
22
+
***client:** don't send Content-Type header on GET requests ([f7a04b5](https://github.com/hyperspell/python-sdk/commit/f7a04b5a47aa9a6fc338498a34db4074824c198e))
***ci:** change upload type ([c01d519](https://github.com/hyperspell/python-sdk/commit/c01d519131a2c4620c9454c4e634c2e39053b00c))
29
+
***ci:** only run for pushes and fork pull requests ([991d685](https://github.com/hyperspell/python-sdk/commit/991d6859286e86aa022eb83aab8ecc6e337798f4))
30
+
***internal:** bump pinned h11 dep ([1ce5781](https://github.com/hyperspell/python-sdk/commit/1ce57814e1d392b0c6a51b75c1dd92550f9399c3))
31
+
***internal:** codegen related update ([f7cd6c7](https://github.com/hyperspell/python-sdk/commit/f7cd6c7b1feafef059ecdf6be0bb9adbd5f28929))
32
+
***package:** mark python 3.13 as supported ([b04d1e6](https://github.com/hyperspell/python-sdk/commit/b04d1e6c7d2dbd8852963ee8f08596ed332e04ec))
33
+
***readme:** fix version rendering on pypi ([a109225](https://github.com/hyperspell/python-sdk/commit/a1092259c98715d17ce95259420baf3c3d325db8))
34
+
***tests:** skip some failing tests on the latest python versions ([9eebf62](https://github.com/hyperspell/python-sdk/commit/9eebf628b254b4f463ea7b899dcef53af5362228))
35
+
3
36
## 0.18.0 (2025-06-19)
4
37
5
38
Full Changelog: [v0.16.0...v0.18.0](https://github.com/hyperspell/python-sdk/compare/v0.16.0...v0.18.0)
The Hyperspell Python library provides convenient access to the Hyperspell REST API from any Python 3.8+
6
7
application. The library includes type definitions for all request params and response fields,
@@ -31,10 +32,10 @@ client = Hyperspell(
31
32
api_key=os.environ.get("HYPERSPELL_TOKEN"), # This is the default and can be omitted
32
33
)
33
34
34
-
document_status= client.documents.add(
35
+
memory_status= client.memories.add(
35
36
text="text",
36
37
)
37
-
print(document_status.id)
38
+
print(memory_status.id)
38
39
```
39
40
40
41
While you can provide an `api_key` keyword argument,
@@ -57,17 +58,50 @@ client = AsyncHyperspell(
57
58
58
59
59
60
asyncdefmain() -> None:
60
-
document_status=await client.documents.add(
61
+
memory_status=await client.memories.add(
61
62
text="text",
62
63
)
63
-
print(document_status.id)
64
+
print(memory_status.id)
64
65
65
66
66
67
asyncio.run(main())
67
68
```
68
69
69
70
Functionality between the synchronous and asynchronous clients is otherwise identical.
70
71
72
+
### With aiohttp
73
+
74
+
By default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.
75
+
76
+
You can enable this by installing `aiohttp`:
77
+
78
+
```sh
79
+
# install from PyPI
80
+
pip install hyperspell[aiohttp]
81
+
```
82
+
83
+
Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
84
+
85
+
```python
86
+
import asyncio
87
+
from hyperspell import DefaultAioHttpClient
88
+
from hyperspell import AsyncHyperspell
89
+
90
+
91
+
asyncdefmain() -> None:
92
+
asyncwith AsyncHyperspell(
93
+
api_key="My API Key",
94
+
http_client=DefaultAioHttpClient(),
95
+
) as client:
96
+
memory_status =await client.memories.add(
97
+
text="text",
98
+
)
99
+
print(memory_status.id)
100
+
101
+
102
+
asyncio.run(main())
103
+
```
104
+
71
105
## Using types
72
106
73
107
Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:
@@ -88,14 +122,14 @@ from hyperspell import Hyperspell
88
122
89
123
client = Hyperspell()
90
124
91
-
all_documents= []
125
+
all_memories= []
92
126
# Automatically fetches more pages as needed.
93
-
fordocumentin client.documents.list(
127
+
formemoryin client.memories.list(
94
128
collection="REPLACE_ME",
95
129
):
96
-
# Do something with document here
97
-
all_documents.append(document)
98
-
print(all_documents)
130
+
# Do something with memory here
131
+
all_memories.append(memory)
132
+
print(all_memories)
99
133
```
100
134
101
135
Or, asynchronously:
@@ -108,13 +142,13 @@ client = AsyncHyperspell()
108
142
109
143
110
144
asyncdefmain() -> None:
111
-
all_documents= []
145
+
all_memories= []
112
146
# Iterate through items across all pages, issuing requests as needed.
113
-
asyncfordocumentin client.documents.list(
147
+
asyncformemoryin client.memories.list(
114
148
collection="REPLACE_ME",
115
149
):
116
-
all_documents.append(document)
117
-
print(all_documents)
150
+
all_memories.append(memory)
151
+
print(all_memories)
118
152
119
153
120
154
asyncio.run(main())
@@ -123,7 +157,7 @@ asyncio.run(main())
123
157
Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:
124
158
125
159
```python
126
-
first_page =await client.documents.list(
160
+
first_page =await client.memories.list(
127
161
collection="REPLACE_ME",
128
162
)
129
163
if first_page.has_next_page():
@@ -137,13 +171,13 @@ if first_page.has_next_page():
document= response.parse() # get the object that `documents.add()` would have returned
319
-
print(document.id)
352
+
memory= response.parse() # get the object that `memories.add()` would have returned
353
+
print(memory.id)
320
354
```
321
355
322
356
These methods return an [`APIResponse`](https://github.com/hyperspell/python-sdk/tree/main/src/hyperspell/_response.py) object.
@@ -330,7 +364,7 @@ The above interface eagerly reads the full response body when you make the reque
330
364
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
331
365
332
366
```python
333
-
with client.documents.with_streaming_response.add(
0 commit comments