Skip to main content

Using types

Nested request parameters are TypedDicts. Responses are Pydantic models which also provide helper methods for things like:
  • Serializing back into JSON, model.to_json()
  • Converting to a dictionary, model.to_dict()
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.

Nested params

Nested parameters are dictionaries, typed using TypedDict, for example:

File uploads

Request parameters that correspond to file uploads can be passed as bytes, or a PathLike instance or a tuple of (filename, contents, media type).
The async client uses the exact same interface. If you pass a PathLike instance, the file contents will be read asynchronously automatically.