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
{{ message }}
Repository navigation
Commit 51c4025
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+44-16Lines changed: 44 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@ The Maisa Python library provides convenient access to the Maisa REST API from a
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
+
It is generated with [Stainless](https://www.stainlessapi.com/).
10
+
9
11
## Documentation
10
12
11
13
The REST API documentation can be found [on docs.maisa.ai](https://docs.maisa.ai/). The full API of this library can be found in [api.md](api.md).
@@ -22,13 +24,9 @@ pip install --pre maisa
22
24
The full API of this library can be found in [api.md](api.md).
23
25
24
26
```python
25
-
import os
26
27
from maisa import Maisa
27
28
28
-
client = Maisa(
29
-
# This is the default and can be omitted
30
-
api_key=os.environ.get("MAISA_API_KEY"),
31
-
)
29
+
client = Maisa()
32
30
33
31
text_summary = client.capabilities.summarize(
34
32
text="Example long text...",
@@ -46,14 +44,10 @@ so that your API Key is not stored in source control.
46
44
Simply import `AsyncMaisa` instead of `Maisa` and use `await` with each API call:
47
45
48
46
```python
49
-
import os
50
47
import asyncio
51
48
from maisa import AsyncMaisa
52
49
53
-
client = AsyncMaisa(
54
-
# This is the default and can be omitted
55
-
api_key=os.environ.get("MAISA_API_KEY"),
56
-
)
50
+
client = AsyncMaisa()
57
51
58
52
59
53
asyncdefmain() -> None:
@@ -70,10 +64,10 @@ Functionality between the synchronous and asynchronous clients is otherwise iden
70
64
71
65
## Using types
72
66
73
-
Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev), which provide helper methods for things like:
67
+
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:
74
68
75
-
- Serializing back into JSON, `model.model_dump_json(indent=2, exclude_unset=True)`
76
-
- Converting to a dictionary, `model.model_dump(exclude_unset=True)`
69
+
- Serializing back into JSON, `model.to_json()`
70
+
- Converting to a dictionary, `model.to_dict()`
77
71
78
72
Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.
79
73
@@ -235,6 +229,41 @@ with client.capabilities.with_streaming_response.summarize(
235
229
236
230
The context manager is required so that the response will reliably be closed.
237
231
232
+
### Making custom/undocumented requests
233
+
234
+
This library is typed for convenient access the documented API.
235
+
236
+
If you need to access undocumented endpoints, params, or response properties, the library can still be used.
237
+
238
+
#### Undocumented endpoints
239
+
240
+
To make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other
241
+
http verbs. Options on the client will be respected (such as retries) will be respected when making this
242
+
request.
243
+
244
+
```py
245
+
import httpx
246
+
247
+
response = client.post(
248
+
"/foo",
249
+
cast_to=httpx.Response,
250
+
body={"my_param": True},
251
+
)
252
+
253
+
print(response.headers.get("x-foo"))
254
+
```
255
+
256
+
#### Undocumented request params
257
+
258
+
If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request
259
+
options.
260
+
261
+
#### Undocumented response properties
262
+
263
+
To access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You
264
+
can also get all the extra fields on the Pydantic model as a dict with
"functools.lru_cache".msg = "This function does not retain type information for the wrapped function's arguments; The `lru_cache` function from `_utils` should be used instead"
0 commit comments