Replies: 1 comment
-
Hi @fgmacedo Thank you very much for contacting us! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
One good example of how to help users of your library to integrate and to validate requests, is to use custom models or objects to ensure the declared properties are correct.
Example of Python API SDK with type hints: OpenAI
One good example of this is the OpenAI Python SDK:
Given the
Completions
as an API example:See how the params are declared:
messages: Iterable[ChatCompletionMessageParam]
.And ChatCompletionMessageParam is a type alias:
Union of distinct
TypedDict
, that act like normal python dicts but with type hints, likeChatCompletionSystemMessageParam
:See TypedDict: Type Hints for Dictionaries with a Fixed Set of Keys.
Beta Was this translation helpful? Give feedback.
All reactions