From e03896aa1752479c03352999087a5c2dab1e19a5 Mon Sep 17 00:00:00 2001
From: Mendy Man <mman@svix.com>
Date: Fri, 24 Jan 2025 16:40:33 -0500
Subject: [PATCH] python: Switch high-level API client to use pydantic

---
 python/svix/api/.codegen.json                 |   6 +
 python/svix/api/application.py                |  51 ++++---
 python/svix/api/authentication.py             |  24 ++--
 python/svix/api/background_task.py            |  15 +-
 python/svix/api/common.py                     |  16 ++-
 python/svix/api/endpoint.py                   | 128 ++++++++----------
 python/svix/api/event_type.py                 |  56 ++++----
 python/svix/api/integration.py                |  44 +++---
 python/svix/api/message.py                    |  18 +--
 python/svix/api/message_attempt.py            |  30 ++--
 .../svix/api/operational_webhook_endpoint.py  |  58 ++++----
 python/svix/api/statistics.py                 |  18 +--
 12 files changed, 224 insertions(+), 240 deletions(-)
 create mode 100644 python/svix/api/.codegen.json

diff --git a/python/svix/api/.codegen.json b/python/svix/api/.codegen.json
new file mode 100644
index 0000000000..b597dcf2a7
--- /dev/null
+++ b/python/svix/api/.codegen.json
@@ -0,0 +1,6 @@
+{
+  "file-generated-at": "2025-01-24T21:11:04.775124283+00:00",
+  "git-rev": "50ccb34db423dd808c94acef683f7225228dfbc5",
+  "openapi-codegen-version": "0.1.0",
+  "openapi.json-sha256": "9fa16f8eb28f617b8495cafc9bd529626145df7af01e5c09acdc2b98e39a4725"
+}
\ No newline at end of file
diff --git a/python/svix/api/application.py b/python/svix/api/application.py
index 0374b45bd1..3ab6e05615 100644
--- a/python/svix/api/application.py
+++ b/python/svix/api/application.py
@@ -2,11 +2,11 @@
 import typing as t
 from dataclasses import dataclass
 
-from ..internal.openapi_client import models
-from ..internal.openapi_client.models.application_in import ApplicationIn
-from ..internal.openapi_client.models.application_out import ApplicationOut
-from ..internal.openapi_client.models.application_patch import ApplicationPatch
-from ..internal.openapi_client.models.list_response_application_out import (
+from .. import models
+from ..models import (
+    ApplicationIn,
+    ApplicationOut,
+    ApplicationPatch,
     ListResponseApplicationOut,
 )
 from .common import ApiBase, BaseOptions, serialize_params
@@ -55,7 +55,7 @@ async def list(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseApplicationOut.from_dict(response.json())
+        return ListResponseApplicationOut.model_validate(response.json())
 
     async def create(
         self,
@@ -69,9 +69,9 @@ async def create(
             path_params={},
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=application_in.to_dict(),
+            json_body=application_in.model_dump_json(exclude_unset=True),
         )
-        return ApplicationOut.from_dict(response.json())
+        return ApplicationOut.model_validate(response.json())
 
     async def get_or_create(
         self,
@@ -84,9 +84,9 @@ async def get_or_create(
             path_params={},
             query_params={"get_if_exists": "true"},
             header_params=options._header_params(),
-            json_body=application_in.to_dict(),
+            json_body=application_in.model_dump_json(exclude_unset=True),
         )
-        return ApplicationOut.from_dict(response.json())
+        return ApplicationOut.model_validate(response.json())
 
     async def get(self, app_id: str) -> ApplicationOut:
         """Get an application."""
@@ -97,7 +97,7 @@ async def get(self, app_id: str) -> ApplicationOut:
                 "app_id": app_id,
             },
         )
-        return ApplicationOut.from_dict(response.json())
+        return ApplicationOut.model_validate(response.json())
 
     async def update(
         self, app_id: str, application_in: ApplicationIn
@@ -109,9 +109,9 @@ async def update(
             path_params={
                 "app_id": app_id,
             },
-            json_body=application_in.to_dict(),
+            json_body=application_in.model_dump_json(exclude_unset=True),
         )
-        return ApplicationOut.from_dict(response.json())
+        return ApplicationOut.model_validate(response.json())
 
     async def delete(self, app_id: str) -> None:
         """Delete an application."""
@@ -133,9 +133,9 @@ async def patch(
             path_params={
                 "app_id": app_id,
             },
-            json_body=application_patch.to_dict(),
+            json_body=application_patch.model_dump_json(exclude_unset=True),
         )
-        return ApplicationOut.from_dict(response.json())
+        return ApplicationOut.model_validate(response.json())
 
 
 class Application(ApiBase):
@@ -150,7 +150,7 @@ def list(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseApplicationOut.from_dict(response.json())
+        return ListResponseApplicationOut.model_validate(response.json())
 
     def create(
         self,
@@ -164,25 +164,24 @@ def create(
             path_params={},
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=application_in.to_dict(),
+            json_body=application_in.model_dump_json(exclude_unset=True),
         )
-        return ApplicationOut.from_dict(response.json())
+        return ApplicationOut.model_validate(response.json())
 
     def get_or_create(
         self,
         application_in: ApplicationIn,
         options: ApplicationCreateOptions = ApplicationCreateOptions(),
     ) -> ApplicationOut:
-        # ruff: noqa: F841
         response = self._request_sync(
             method="post",
             path="/api/v1/app",
             path_params={},
             query_params={"get_if_exists": "true"},
             header_params=options._header_params(),
-            json_body=application_in.to_dict(),
+            json_body=application_in.model_dump_json(exclude_unset=True),
         )
-        return ApplicationOut.from_dict(response.json())
+        return ApplicationOut.model_validate(response.json())
 
     def get(self, app_id: str) -> ApplicationOut:
         """Get an application."""
@@ -193,7 +192,7 @@ def get(self, app_id: str) -> ApplicationOut:
                 "app_id": app_id,
             },
         )
-        return ApplicationOut.from_dict(response.json())
+        return ApplicationOut.model_validate(response.json())
 
     def update(self, app_id: str, application_in: ApplicationIn) -> ApplicationOut:
         """Update an application."""
@@ -203,9 +202,9 @@ def update(self, app_id: str, application_in: ApplicationIn) -> ApplicationOut:
             path_params={
                 "app_id": app_id,
             },
-            json_body=application_in.to_dict(),
+            json_body=application_in.model_dump_json(exclude_unset=True),
         )
-        return ApplicationOut.from_dict(response.json())
+        return ApplicationOut.model_validate(response.json())
 
     def delete(self, app_id: str) -> None:
         """Delete an application."""
@@ -225,6 +224,6 @@ def patch(self, app_id: str, application_patch: ApplicationPatch) -> Application
             path_params={
                 "app_id": app_id,
             },
-            json_body=application_patch.to_dict(),
+            json_body=application_patch.model_dump_json(exclude_unset=True),
         )
-        return ApplicationOut.from_dict(response.json())
+        return ApplicationOut.model_validate(response.json())
diff --git a/python/svix/api/authentication.py b/python/svix/api/authentication.py
index 1041c35319..943529a053 100644
--- a/python/svix/api/authentication.py
+++ b/python/svix/api/authentication.py
@@ -4,12 +4,12 @@
 
 from deprecated import deprecated
 
-from ..internal.openapi_client.models.app_portal_access_in import AppPortalAccessIn
-from ..internal.openapi_client.models.app_portal_access_out import AppPortalAccessOut
-from ..internal.openapi_client.models.application_token_expire_in import (
+from ..models import (
     ApplicationTokenExpireIn,
+    AppPortalAccessIn,
+    AppPortalAccessOut,
+    DashboardAccessOut,
 )
-from ..internal.openapi_client.models.dashboard_access_out import DashboardAccessOut
 from .common import ApiBase, BaseOptions, serialize_params
 
 
@@ -77,9 +77,9 @@ async def app_portal_access(
             },
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=app_portal_access_in.to_dict(),
+            json_body=app_portal_access_in.model_dump_json(exclude_unset=True),
         )
-        return AppPortalAccessOut.from_dict(response.json())
+        return AppPortalAccessOut.model_validate(response.json())
 
     async def expire_all(
         self,
@@ -96,7 +96,7 @@ async def expire_all(
             },
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=application_token_expire_in.to_dict(),
+            json_body=application_token_expire_in.model_dump_json(exclude_unset=True),
         )
 
     @deprecated
@@ -117,7 +117,7 @@ async def dashboard_access(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return DashboardAccessOut.from_dict(response.json())
+        return DashboardAccessOut.model_validate(response.json())
 
     async def logout(
         self, options: AuthenticationLogoutOptions = AuthenticationLogoutOptions()
@@ -150,9 +150,9 @@ def app_portal_access(
             },
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=app_portal_access_in.to_dict(),
+            json_body=app_portal_access_in.model_dump_json(exclude_unset=True),
         )
-        return AppPortalAccessOut.from_dict(response.json())
+        return AppPortalAccessOut.model_validate(response.json())
 
     def expire_all(
         self,
@@ -169,7 +169,7 @@ def expire_all(
             },
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=application_token_expire_in.to_dict(),
+            json_body=application_token_expire_in.model_dump_json(exclude_unset=True),
         )
 
     @deprecated
@@ -190,7 +190,7 @@ def dashboard_access(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return DashboardAccessOut.from_dict(response.json())
+        return DashboardAccessOut.model_validate(response.json())
 
     def logout(
         self, options: AuthenticationLogoutOptions = AuthenticationLogoutOptions()
diff --git a/python/svix/api/background_task.py b/python/svix/api/background_task.py
index c5a46f80ec..f48b89d8d6 100644
--- a/python/svix/api/background_task.py
+++ b/python/svix/api/background_task.py
@@ -2,11 +2,8 @@
 import typing as t
 from dataclasses import dataclass
 
-from ..internal.openapi_client import models
-from ..internal.openapi_client.models.background_task_out import BackgroundTaskOut
-from ..internal.openapi_client.models.list_response_background_task_out import (
-    ListResponseBackgroundTaskOut,
-)
+from .. import models
+from ..models import BackgroundTaskOut, ListResponseBackgroundTaskOut
 from .common import ApiBase, BaseOptions, serialize_params
 
 
@@ -47,7 +44,7 @@ async def list(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseBackgroundTaskOut.from_dict(response.json())
+        return ListResponseBackgroundTaskOut.model_validate(response.json())
 
     async def get(self, task_id: str) -> BackgroundTaskOut:
         """Get a background task by ID."""
@@ -58,7 +55,7 @@ async def get(self, task_id: str) -> BackgroundTaskOut:
                 "task_id": task_id,
             },
         )
-        return BackgroundTaskOut.from_dict(response.json())
+        return BackgroundTaskOut.model_validate(response.json())
 
 
 class BackgroundTask(ApiBase):
@@ -73,7 +70,7 @@ def list(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseBackgroundTaskOut.from_dict(response.json())
+        return ListResponseBackgroundTaskOut.model_validate(response.json())
 
     def get(self, task_id: str) -> BackgroundTaskOut:
         """Get a background task by ID."""
@@ -84,4 +81,4 @@ def get(self, task_id: str) -> BackgroundTaskOut:
                 "task_id": task_id,
             },
         )
-        return BackgroundTaskOut.from_dict(response.json())
+        return BackgroundTaskOut.model_validate(response.json())
diff --git a/python/svix/api/common.py b/python/svix/api/common.py
index 3b716d20d5..34703e08e1 100644
--- a/python/svix/api/common.py
+++ b/python/svix/api/common.py
@@ -7,8 +7,8 @@
 
 import httpx
 
-from ..internal.openapi_client.client import AuthenticatedClient
-from ..internal.openapi_client.models import HttpError
+from .client import AuthenticatedClient
+from .http_error import HttpError
 
 
 def ensure_tz(x: t.Optional[datetime]) -> t.Optional[datetime]:
@@ -80,7 +80,7 @@ def _get_httpx_kwargs(
         path_params: t.Optional[t.Dict[str, str]],
         query_params: t.Optional[t.Dict[str, str]],
         header_params: t.Optional[t.Dict[str, str]],
-        json_body: t.Optional[t.Dict[str, t.Any]],
+        json_body: t.Optional[str],
     ) -> t.Dict[str, t.Any]:
         if path_params is not None:
             path = path.format(**path_params)
@@ -107,7 +107,11 @@ def _get_httpx_kwargs(
             httpx_kwargs["params"] = query_params
 
         if json_body is not None:
-            httpx_kwargs["json"] = json_body
+            encoded_body = json_body.encode("utf-8")
+            httpx_kwargs["content"] = encoded_body
+            headers["content-type"]= "application/json"
+            headers["content-length"]= str(len(encoded_body))
+
         return httpx_kwargs
 
     async def _request_asyncio(
@@ -117,7 +121,7 @@ async def _request_asyncio(
         path_params: t.Optional[t.Dict[str, str]] = None,
         query_params: t.Optional[t.Dict[str, str]] = None,
         header_params: t.Optional[t.Dict[str, str]] = None,
-        json_body: t.Optional[t.Dict[str, t.Any]] = None,
+        json_body: t.Optional[str] = None,
     ) -> httpx.Response:
         httpx_kwargs = self._get_httpx_kwargs(
             method,
@@ -150,7 +154,7 @@ def _request_sync(
         path_params: t.Optional[t.Dict[str, str]] = None,
         query_params: t.Optional[t.Dict[str, str]] = None,
         header_params: t.Optional[t.Dict[str, str]] = None,
-        json_body: t.Optional[t.Dict[str, t.Any]] = None,
+        json_body: t.Optional[str] = None,
     ) -> httpx.Response:
         httpx_kwargs = self._get_httpx_kwargs(
             method,
diff --git a/python/svix/api/endpoint.py b/python/svix/api/endpoint.py
index fcc34c1b21..bdee40de60 100644
--- a/python/svix/api/endpoint.py
+++ b/python/svix/api/endpoint.py
@@ -3,36 +3,28 @@
 from dataclasses import dataclass
 from datetime import datetime
 
-from ..internal.openapi_client import models
-from ..internal.openapi_client.models.endpoint_headers_in import EndpointHeadersIn
-from ..internal.openapi_client.models.endpoint_headers_out import EndpointHeadersOut
-from ..internal.openapi_client.models.endpoint_headers_patch_in import (
+from .. import models
+from ..models import (
+    EndpointHeadersIn,
+    EndpointHeadersOut,
     EndpointHeadersPatchIn,
-)
-from ..internal.openapi_client.models.endpoint_in import EndpointIn
-from ..internal.openapi_client.models.endpoint_out import EndpointOut
-from ..internal.openapi_client.models.endpoint_patch import EndpointPatch
-from ..internal.openapi_client.models.endpoint_secret_out import EndpointSecretOut
-from ..internal.openapi_client.models.endpoint_secret_rotate_in import (
+    EndpointIn,
+    EndpointOut,
+    EndpointPatch,
+    EndpointSecretOut,
     EndpointSecretRotateIn,
-)
-from ..internal.openapi_client.models.endpoint_stats import EndpointStats
-from ..internal.openapi_client.models.endpoint_transformation_in import (
+    EndpointStats,
     EndpointTransformationIn,
-)
-from ..internal.openapi_client.models.endpoint_transformation_out import (
     EndpointTransformationOut,
-)
-from ..internal.openapi_client.models.endpoint_update import EndpointUpdate
-from ..internal.openapi_client.models.event_example_in import EventExampleIn
-from ..internal.openapi_client.models.list_response_endpoint_out import (
+    EndpointUpdate,
+    EventExampleIn,
     ListResponseEndpointOut,
+    MessageOut,
+    RecoverIn,
+    RecoverOut,
+    ReplayIn,
+    ReplayOut,
 )
-from ..internal.openapi_client.models.message_out import MessageOut
-from ..internal.openapi_client.models.recover_in import RecoverIn
-from ..internal.openapi_client.models.recover_out import RecoverOut
-from ..internal.openapi_client.models.replay_in import ReplayIn
-from ..internal.openapi_client.models.replay_out import ReplayOut
 from .common import ApiBase, BaseOptions, serialize_params
 
 
@@ -145,7 +137,7 @@ async def list(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseEndpointOut.from_dict(response.json())
+        return ListResponseEndpointOut.model_validate(response.json())
 
     async def create(
         self,
@@ -164,9 +156,9 @@ async def create(
             },
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=endpoint_in.to_dict(),
+            json_body=endpoint_in.model_dump_json(exclude_unset=True),
         )
-        return EndpointOut.from_dict(response.json())
+        return EndpointOut.model_validate(response.json())
 
     async def get(self, app_id: str, endpoint_id: str) -> EndpointOut:
         """Get an endpoint."""
@@ -178,7 +170,7 @@ async def get(self, app_id: str, endpoint_id: str) -> EndpointOut:
                 "endpoint_id": endpoint_id,
             },
         )
-        return EndpointOut.from_dict(response.json())
+        return EndpointOut.model_validate(response.json())
 
     async def update(
         self, app_id: str, endpoint_id: str, endpoint_update: EndpointUpdate
@@ -191,9 +183,9 @@ async def update(
                 "app_id": app_id,
                 "endpoint_id": endpoint_id,
             },
-            json_body=endpoint_update.to_dict(),
+            json_body=endpoint_update.model_dump_json(exclude_unset=True),
         )
-        return EndpointOut.from_dict(response.json())
+        return EndpointOut.model_validate(response.json())
 
     async def delete(self, app_id: str, endpoint_id: str) -> None:
         """Delete an endpoint."""
@@ -217,9 +209,9 @@ async def patch(
                 "app_id": app_id,
                 "endpoint_id": endpoint_id,
             },
-            json_body=endpoint_patch.to_dict(),
+            json_body=endpoint_patch.model_dump_json(exclude_unset=True),
         )
-        return EndpointOut.from_dict(response.json())
+        return EndpointOut.model_validate(response.json())
 
     async def get_headers(self, app_id: str, endpoint_id: str) -> EndpointHeadersOut:
         """Get the additional headers to be sent with the webhook."""
@@ -231,7 +223,7 @@ async def get_headers(self, app_id: str, endpoint_id: str) -> EndpointHeadersOut
                 "endpoint_id": endpoint_id,
             },
         )
-        return EndpointHeadersOut.from_dict(response.json())
+        return EndpointHeadersOut.model_validate(response.json())
 
     async def update_headers(
         self, app_id: str, endpoint_id: str, endpoint_headers_in: EndpointHeadersIn
@@ -244,7 +236,7 @@ async def update_headers(
                 "app_id": app_id,
                 "endpoint_id": endpoint_id,
             },
-            json_body=endpoint_headers_in.to_dict(),
+            json_body=endpoint_headers_in.model_dump_json(exclude_unset=True),
         )
 
     async def patch_headers(
@@ -261,7 +253,7 @@ async def patch_headers(
                 "app_id": app_id,
                 "endpoint_id": endpoint_id,
             },
-            json_body=endpoint_headers_patch_in.to_dict(),
+            json_body=endpoint_headers_patch_in.model_dump_json(exclude_unset=True),
         )
 
     async def recover(
@@ -283,9 +275,9 @@ async def recover(
             },
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=recover_in.to_dict(),
+            json_body=recover_in.model_dump_json(exclude_unset=True),
         )
-        return RecoverOut.from_dict(response.json())
+        return RecoverOut.model_validate(response.json())
 
     async def replay_missing(
         self,
@@ -307,9 +299,9 @@ async def replay_missing(
             },
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=replay_in.to_dict(),
+            json_body=replay_in.model_dump_json(exclude_unset=True),
         )
-        return ReplayOut.from_dict(response.json())
+        return ReplayOut.model_validate(response.json())
 
     async def get_secret(self, app_id: str, endpoint_id: str) -> EndpointSecretOut:
         """Get the endpoint's signing secret.
@@ -324,7 +316,7 @@ async def get_secret(self, app_id: str, endpoint_id: str) -> EndpointSecretOut:
                 "endpoint_id": endpoint_id,
             },
         )
-        return EndpointSecretOut.from_dict(response.json())
+        return EndpointSecretOut.model_validate(response.json())
 
     async def rotate_secret(
         self,
@@ -345,7 +337,7 @@ async def rotate_secret(
             },
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=endpoint_secret_rotate_in.to_dict(),
+            json_body=endpoint_secret_rotate_in.model_dump_json(exclude_unset=True),
         )
 
     async def send_example(
@@ -365,9 +357,9 @@ async def send_example(
             },
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=event_example_in.to_dict(),
+            json_body=event_example_in.model_dump_json(exclude_unset=True),
         )
-        return MessageOut.from_dict(response.json())
+        return MessageOut.model_validate(response.json())
 
     async def get_stats(
         self,
@@ -386,7 +378,7 @@ async def get_stats(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return EndpointStats.from_dict(response.json())
+        return EndpointStats.model_validate(response.json())
 
     async def transformation_get(
         self, app_id: str, endpoint_id: str
@@ -400,7 +392,7 @@ async def transformation_get(
                 "endpoint_id": endpoint_id,
             },
         )
-        return EndpointTransformationOut.from_dict(response.json())
+        return EndpointTransformationOut.model_validate(response.json())
 
     async def transformation_partial_update(
         self,
@@ -416,7 +408,7 @@ async def transformation_partial_update(
                 "app_id": app_id,
                 "endpoint_id": endpoint_id,
             },
-            json_body=endpoint_transformation_in.to_dict(),
+            json_body=endpoint_transformation_in.model_dump_json(exclude_unset=True),
         )
 
 
@@ -434,7 +426,7 @@ def list(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseEndpointOut.from_dict(response.json())
+        return ListResponseEndpointOut.model_validate(response.json())
 
     def create(
         self,
@@ -453,9 +445,9 @@ def create(
             },
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=endpoint_in.to_dict(),
+            json_body=endpoint_in.model_dump_json(exclude_unset=True),
         )
-        return EndpointOut.from_dict(response.json())
+        return EndpointOut.model_validate(response.json())
 
     def get(self, app_id: str, endpoint_id: str) -> EndpointOut:
         """Get an endpoint."""
@@ -467,7 +459,7 @@ def get(self, app_id: str, endpoint_id: str) -> EndpointOut:
                 "endpoint_id": endpoint_id,
             },
         )
-        return EndpointOut.from_dict(response.json())
+        return EndpointOut.model_validate(response.json())
 
     def update(
         self, app_id: str, endpoint_id: str, endpoint_update: EndpointUpdate
@@ -480,9 +472,9 @@ def update(
                 "app_id": app_id,
                 "endpoint_id": endpoint_id,
             },
-            json_body=endpoint_update.to_dict(),
+            json_body=endpoint_update.model_dump_json(exclude_unset=True),
         )
-        return EndpointOut.from_dict(response.json())
+        return EndpointOut.model_validate(response.json())
 
     def delete(self, app_id: str, endpoint_id: str) -> None:
         """Delete an endpoint."""
@@ -506,9 +498,9 @@ def patch(
                 "app_id": app_id,
                 "endpoint_id": endpoint_id,
             },
-            json_body=endpoint_patch.to_dict(),
+            json_body=endpoint_patch.model_dump_json(exclude_unset=True),
         )
-        return EndpointOut.from_dict(response.json())
+        return EndpointOut.model_validate(response.json())
 
     def get_headers(self, app_id: str, endpoint_id: str) -> EndpointHeadersOut:
         """Get the additional headers to be sent with the webhook."""
@@ -520,7 +512,7 @@ def get_headers(self, app_id: str, endpoint_id: str) -> EndpointHeadersOut:
                 "endpoint_id": endpoint_id,
             },
         )
-        return EndpointHeadersOut.from_dict(response.json())
+        return EndpointHeadersOut.model_validate(response.json())
 
     def update_headers(
         self, app_id: str, endpoint_id: str, endpoint_headers_in: EndpointHeadersIn
@@ -533,7 +525,7 @@ def update_headers(
                 "app_id": app_id,
                 "endpoint_id": endpoint_id,
             },
-            json_body=endpoint_headers_in.to_dict(),
+            json_body=endpoint_headers_in.model_dump_json(exclude_unset=True),
         )
 
     def patch_headers(
@@ -550,7 +542,7 @@ def patch_headers(
                 "app_id": app_id,
                 "endpoint_id": endpoint_id,
             },
-            json_body=endpoint_headers_patch_in.to_dict(),
+            json_body=endpoint_headers_patch_in.model_dump_json(exclude_unset=True),
         )
 
     def recover(
@@ -572,9 +564,9 @@ def recover(
             },
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=recover_in.to_dict(),
+            json_body=recover_in.model_dump_json(exclude_unset=True),
         )
-        return RecoverOut.from_dict(response.json())
+        return RecoverOut.model_validate(response.json())
 
     def replay_missing(
         self,
@@ -596,9 +588,9 @@ def replay_missing(
             },
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=replay_in.to_dict(),
+            json_body=replay_in.model_dump_json(exclude_unset=True),
         )
-        return ReplayOut.from_dict(response.json())
+        return ReplayOut.model_validate(response.json())
 
     def get_secret(self, app_id: str, endpoint_id: str) -> EndpointSecretOut:
         """Get the endpoint's signing secret.
@@ -613,7 +605,7 @@ def get_secret(self, app_id: str, endpoint_id: str) -> EndpointSecretOut:
                 "endpoint_id": endpoint_id,
             },
         )
-        return EndpointSecretOut.from_dict(response.json())
+        return EndpointSecretOut.model_validate(response.json())
 
     def rotate_secret(
         self,
@@ -634,7 +626,7 @@ def rotate_secret(
             },
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=endpoint_secret_rotate_in.to_dict(),
+            json_body=endpoint_secret_rotate_in.model_dump_json(exclude_unset=True),
         )
 
     def send_example(
@@ -654,9 +646,9 @@ def send_example(
             },
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=event_example_in.to_dict(),
+            json_body=event_example_in.model_dump_json(exclude_unset=True),
         )
-        return MessageOut.from_dict(response.json())
+        return MessageOut.model_validate(response.json())
 
     def get_stats(
         self,
@@ -675,7 +667,7 @@ def get_stats(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return EndpointStats.from_dict(response.json())
+        return EndpointStats.model_validate(response.json())
 
     def transformation_get(
         self, app_id: str, endpoint_id: str
@@ -689,7 +681,7 @@ def transformation_get(
                 "endpoint_id": endpoint_id,
             },
         )
-        return EndpointTransformationOut.from_dict(response.json())
+        return EndpointTransformationOut.model_validate(response.json())
 
     def transformation_partial_update(
         self,
@@ -705,5 +697,5 @@ def transformation_partial_update(
                 "app_id": app_id,
                 "endpoint_id": endpoint_id,
             },
-            json_body=endpoint_transformation_in.to_dict(),
+            json_body=endpoint_transformation_in.model_dump_json(exclude_unset=True),
         )
diff --git a/python/svix/api/event_type.py b/python/svix/api/event_type.py
index 5e68f64b16..5ebddf2162 100644
--- a/python/svix/api/event_type.py
+++ b/python/svix/api/event_type.py
@@ -2,18 +2,14 @@
 import typing as t
 from dataclasses import dataclass
 
-from ..internal.openapi_client import models
-from ..internal.openapi_client.models.event_type_import_open_api_in import (
+from .. import models
+from ..models import (
     EventTypeImportOpenApiIn,
-)
-from ..internal.openapi_client.models.event_type_import_open_api_out import (
     EventTypeImportOpenApiOut,
-)
-from ..internal.openapi_client.models.event_type_in import EventTypeIn
-from ..internal.openapi_client.models.event_type_out import EventTypeOut
-from ..internal.openapi_client.models.event_type_patch import EventTypePatch
-from ..internal.openapi_client.models.event_type_update import EventTypeUpdate
-from ..internal.openapi_client.models.list_response_event_type_out import (
+    EventTypeIn,
+    EventTypeOut,
+    EventTypePatch,
+    EventTypeUpdate,
     ListResponseEventTypeOut,
 )
 from .common import ApiBase, BaseOptions, serialize_params
@@ -93,7 +89,7 @@ async def list(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseEventTypeOut.from_dict(response.json())
+        return ListResponseEventTypeOut.model_validate(response.json())
 
     async def create(
         self,
@@ -111,9 +107,9 @@ async def create(
             path_params={},
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=event_type_in.to_dict(),
+            json_body=event_type_in.model_dump_json(exclude_unset=True),
         )
-        return EventTypeOut.from_dict(response.json())
+        return EventTypeOut.model_validate(response.json())
 
     async def import_openapi(
         self,
@@ -131,9 +127,9 @@ async def import_openapi(
             path_params={},
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=event_type_import_open_api_in.to_dict(),
+            json_body=event_type_import_open_api_in.model_dump_json(exclude_unset=True),
         )
-        return EventTypeImportOpenApiOut.from_dict(response.json())
+        return EventTypeImportOpenApiOut.model_validate(response.json())
 
     async def get(self, event_type_name: str) -> EventTypeOut:
         """Get an event type."""
@@ -144,7 +140,7 @@ async def get(self, event_type_name: str) -> EventTypeOut:
                 "event_type_name": event_type_name,
             },
         )
-        return EventTypeOut.from_dict(response.json())
+        return EventTypeOut.model_validate(response.json())
 
     async def update(
         self, event_type_name: str, event_type_update: EventTypeUpdate
@@ -156,9 +152,9 @@ async def update(
             path_params={
                 "event_type_name": event_type_name,
             },
-            json_body=event_type_update.to_dict(),
+            json_body=event_type_update.model_dump_json(exclude_unset=True),
         )
-        return EventTypeOut.from_dict(response.json())
+        return EventTypeOut.model_validate(response.json())
 
     async def delete(
         self,
@@ -191,9 +187,9 @@ async def patch(
             path_params={
                 "event_type_name": event_type_name,
             },
-            json_body=event_type_patch.to_dict(),
+            json_body=event_type_patch.model_dump_json(exclude_unset=True),
         )
-        return EventTypeOut.from_dict(response.json())
+        return EventTypeOut.model_validate(response.json())
 
 
 class EventType(ApiBase):
@@ -208,7 +204,7 @@ def list(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseEventTypeOut.from_dict(response.json())
+        return ListResponseEventTypeOut.model_validate(response.json())
 
     def create(
         self,
@@ -226,9 +222,9 @@ def create(
             path_params={},
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=event_type_in.to_dict(),
+            json_body=event_type_in.model_dump_json(exclude_unset=True),
         )
-        return EventTypeOut.from_dict(response.json())
+        return EventTypeOut.model_validate(response.json())
 
     def import_openapi(
         self,
@@ -246,9 +242,9 @@ def import_openapi(
             path_params={},
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=event_type_import_open_api_in.to_dict(),
+            json_body=event_type_import_open_api_in.model_dump_json(exclude_unset=True),
         )
-        return EventTypeImportOpenApiOut.from_dict(response.json())
+        return EventTypeImportOpenApiOut.model_validate(response.json())
 
     def get(self, event_type_name: str) -> EventTypeOut:
         """Get an event type."""
@@ -259,7 +255,7 @@ def get(self, event_type_name: str) -> EventTypeOut:
                 "event_type_name": event_type_name,
             },
         )
-        return EventTypeOut.from_dict(response.json())
+        return EventTypeOut.model_validate(response.json())
 
     def update(
         self, event_type_name: str, event_type_update: EventTypeUpdate
@@ -271,9 +267,9 @@ def update(
             path_params={
                 "event_type_name": event_type_name,
             },
-            json_body=event_type_update.to_dict(),
+            json_body=event_type_update.model_dump_json(exclude_unset=True),
         )
-        return EventTypeOut.from_dict(response.json())
+        return EventTypeOut.model_validate(response.json())
 
     def delete(
         self,
@@ -306,6 +302,6 @@ def patch(
             path_params={
                 "event_type_name": event_type_name,
             },
-            json_body=event_type_patch.to_dict(),
+            json_body=event_type_patch.model_dump_json(exclude_unset=True),
         )
-        return EventTypeOut.from_dict(response.json())
+        return EventTypeOut.model_validate(response.json())
diff --git a/python/svix/api/integration.py b/python/svix/api/integration.py
index 6c0d987f3b..48ce859658 100644
--- a/python/svix/api/integration.py
+++ b/python/svix/api/integration.py
@@ -4,12 +4,12 @@
 
 from deprecated import deprecated
 
-from ..internal.openapi_client import models
-from ..internal.openapi_client.models.integration_in import IntegrationIn
-from ..internal.openapi_client.models.integration_key_out import IntegrationKeyOut
-from ..internal.openapi_client.models.integration_out import IntegrationOut
-from ..internal.openapi_client.models.integration_update import IntegrationUpdate
-from ..internal.openapi_client.models.list_response_integration_out import (
+from .. import models
+from ..models import (
+    IntegrationIn,
+    IntegrationKeyOut,
+    IntegrationOut,
+    IntegrationUpdate,
     ListResponseIntegrationOut,
 )
 from .common import ApiBase, BaseOptions, serialize_params
@@ -72,7 +72,7 @@ async def list(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseIntegrationOut.from_dict(response.json())
+        return ListResponseIntegrationOut.model_validate(response.json())
 
     async def create(
         self,
@@ -89,9 +89,9 @@ async def create(
             },
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=integration_in.to_dict(),
+            json_body=integration_in.model_dump_json(exclude_unset=True),
         )
-        return IntegrationOut.from_dict(response.json())
+        return IntegrationOut.model_validate(response.json())
 
     async def get(self, app_id: str, integ_id: str) -> IntegrationOut:
         """Get an integration."""
@@ -103,7 +103,7 @@ async def get(self, app_id: str, integ_id: str) -> IntegrationOut:
                 "integ_id": integ_id,
             },
         )
-        return IntegrationOut.from_dict(response.json())
+        return IntegrationOut.model_validate(response.json())
 
     async def update(
         self, app_id: str, integ_id: str, integration_update: IntegrationUpdate
@@ -116,9 +116,9 @@ async def update(
                 "app_id": app_id,
                 "integ_id": integ_id,
             },
-            json_body=integration_update.to_dict(),
+            json_body=integration_update.model_dump_json(exclude_unset=True),
         )
-        return IntegrationOut.from_dict(response.json())
+        return IntegrationOut.model_validate(response.json())
 
     async def delete(self, app_id: str, integ_id: str) -> None:
         """Delete an integration."""
@@ -142,7 +142,7 @@ async def get_key(self, app_id: str, integ_id: str) -> IntegrationKeyOut:
                 "integ_id": integ_id,
             },
         )
-        return IntegrationKeyOut.from_dict(response.json())
+        return IntegrationKeyOut.model_validate(response.json())
 
     async def rotate_key(
         self,
@@ -161,7 +161,7 @@ async def rotate_key(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return IntegrationKeyOut.from_dict(response.json())
+        return IntegrationKeyOut.model_validate(response.json())
 
 
 class Integration(ApiBase):
@@ -178,7 +178,7 @@ def list(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseIntegrationOut.from_dict(response.json())
+        return ListResponseIntegrationOut.model_validate(response.json())
 
     def create(
         self,
@@ -195,9 +195,9 @@ def create(
             },
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=integration_in.to_dict(),
+            json_body=integration_in.model_dump_json(exclude_unset=True),
         )
-        return IntegrationOut.from_dict(response.json())
+        return IntegrationOut.model_validate(response.json())
 
     def get(self, app_id: str, integ_id: str) -> IntegrationOut:
         """Get an integration."""
@@ -209,7 +209,7 @@ def get(self, app_id: str, integ_id: str) -> IntegrationOut:
                 "integ_id": integ_id,
             },
         )
-        return IntegrationOut.from_dict(response.json())
+        return IntegrationOut.model_validate(response.json())
 
     def update(
         self, app_id: str, integ_id: str, integration_update: IntegrationUpdate
@@ -222,9 +222,9 @@ def update(
                 "app_id": app_id,
                 "integ_id": integ_id,
             },
-            json_body=integration_update.to_dict(),
+            json_body=integration_update.model_dump_json(exclude_unset=True),
         )
-        return IntegrationOut.from_dict(response.json())
+        return IntegrationOut.model_validate(response.json())
 
     def delete(self, app_id: str, integ_id: str) -> None:
         """Delete an integration."""
@@ -248,7 +248,7 @@ def get_key(self, app_id: str, integ_id: str) -> IntegrationKeyOut:
                 "integ_id": integ_id,
             },
         )
-        return IntegrationKeyOut.from_dict(response.json())
+        return IntegrationKeyOut.model_validate(response.json())
 
     def rotate_key(
         self,
@@ -267,4 +267,4 @@ def rotate_key(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return IntegrationKeyOut.from_dict(response.json())
+        return IntegrationKeyOut.model_validate(response.json())
diff --git a/python/svix/api/message.py b/python/svix/api/message.py
index c3c652b87c..1c27635ad2 100644
--- a/python/svix/api/message.py
+++ b/python/svix/api/message.py
@@ -3,11 +3,7 @@
 from dataclasses import dataclass
 from datetime import datetime
 
-from ..internal.openapi_client.models.list_response_message_out import (
-    ListResponseMessageOut,
-)
-from ..internal.openapi_client.models.message_in import MessageIn
-from ..internal.openapi_client.models.message_out import MessageOut
+from ..models import ListResponseMessageOut, MessageIn, MessageOut
 from .common import ApiBase, BaseOptions, serialize_params
 
 
@@ -134,7 +130,7 @@ async def list(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseMessageOut.from_dict(response.json())
+        return ListResponseMessageOut.model_validate(response.json())
 
     async def create(
         self,
@@ -159,7 +155,7 @@ async def create(
             },
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=message_in.to_dict(),
+            json_body=message_in.model_dump_json(exclude_unset=True),
         )
         ret = response.json()
         ret["payload"] = message_in.payload
@@ -179,7 +175,7 @@ async def get(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return MessageOut.from_dict(response.json())
+        return MessageOut.model_validate(response.json())
 
     async def expunge_content(self, app_id: str, msg_id: str) -> None:
         """Delete the given message's payload.
@@ -219,7 +215,7 @@ def list(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseMessageOut.from_dict(response.json())
+        return ListResponseMessageOut.model_validate(response.json())
 
     def create(
         self,
@@ -244,7 +240,7 @@ def create(
             },
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=message_in.to_dict(),
+            json_body=message_in.model_dump_json(exclude_unset=True),
         )
         ret = response.json()
         ret["payload"] = message_in.payload
@@ -264,7 +260,7 @@ def get(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return MessageOut.from_dict(response.json())
+        return MessageOut.model_validate(response.json())
 
     def expunge_content(self, app_id: str, msg_id: str) -> None:
         """Delete the given message's payload.
diff --git a/python/svix/api/message_attempt.py b/python/svix/api/message_attempt.py
index 74358e68d9..0acb7f831f 100644
--- a/python/svix/api/message_attempt.py
+++ b/python/svix/api/message_attempt.py
@@ -3,17 +3,13 @@
 from dataclasses import dataclass
 from datetime import datetime
 
-from ..internal.openapi_client import models
-from ..internal.openapi_client.models.list_response_endpoint_message_out import (
+from .. import models
+from ..models import (
     ListResponseEndpointMessageOut,
-)
-from ..internal.openapi_client.models.list_response_message_attempt_out import (
     ListResponseMessageAttemptOut,
-)
-from ..internal.openapi_client.models.list_response_message_endpoint_out import (
     ListResponseMessageEndpointOut,
+    MessageAttemptOut,
 )
-from ..internal.openapi_client.models.message_attempt_out import MessageAttemptOut
 from .common import ApiBase, BaseOptions, serialize_params
 
 
@@ -192,7 +188,7 @@ async def list_by_endpoint(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseMessageAttemptOut.from_dict(response.json())
+        return ListResponseMessageAttemptOut.model_validate(response.json())
 
     async def list_by_msg(
         self,
@@ -216,7 +212,7 @@ async def list_by_msg(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseMessageAttemptOut.from_dict(response.json())
+        return ListResponseMessageAttemptOut.model_validate(response.json())
 
     async def list_attempted_messages(
         self,
@@ -243,7 +239,7 @@ async def list_attempted_messages(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseEndpointMessageOut.from_dict(response.json())
+        return ListResponseEndpointMessageOut.model_validate(response.json())
 
     async def get(self, app_id: str, msg_id: str, attempt_id: str) -> MessageAttemptOut:
         """`msg_id`: Use a message id or a message `eventId`"""
@@ -256,7 +252,7 @@ async def get(self, app_id: str, msg_id: str, attempt_id: str) -> MessageAttempt
                 "attempt_id": attempt_id,
             },
         )
-        return MessageAttemptOut.from_dict(response.json())
+        return MessageAttemptOut.model_validate(response.json())
 
     async def expunge_content(self, app_id: str, msg_id: str, attempt_id: str) -> None:
         """Deletes the given attempt's response body.
@@ -293,7 +289,7 @@ async def list_attempted_destinations(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseMessageEndpointOut.from_dict(response.json())
+        return ListResponseMessageEndpointOut.model_validate(response.json())
 
     async def resend(
         self,
@@ -340,7 +336,7 @@ def list_by_endpoint(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseMessageAttemptOut.from_dict(response.json())
+        return ListResponseMessageAttemptOut.model_validate(response.json())
 
     def list_by_msg(
         self,
@@ -364,7 +360,7 @@ def list_by_msg(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseMessageAttemptOut.from_dict(response.json())
+        return ListResponseMessageAttemptOut.model_validate(response.json())
 
     def list_attempted_messages(
         self,
@@ -391,7 +387,7 @@ def list_attempted_messages(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseEndpointMessageOut.from_dict(response.json())
+        return ListResponseEndpointMessageOut.model_validate(response.json())
 
     def get(self, app_id: str, msg_id: str, attempt_id: str) -> MessageAttemptOut:
         """`msg_id`: Use a message id or a message `eventId`"""
@@ -404,7 +400,7 @@ def get(self, app_id: str, msg_id: str, attempt_id: str) -> MessageAttemptOut:
                 "attempt_id": attempt_id,
             },
         )
-        return MessageAttemptOut.from_dict(response.json())
+        return MessageAttemptOut.model_validate(response.json())
 
     def expunge_content(self, app_id: str, msg_id: str, attempt_id: str) -> None:
         """Deletes the given attempt's response body.
@@ -441,7 +437,7 @@ def list_attempted_destinations(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseMessageEndpointOut.from_dict(response.json())
+        return ListResponseMessageEndpointOut.model_validate(response.json())
 
     def resend(
         self,
diff --git a/python/svix/api/operational_webhook_endpoint.py b/python/svix/api/operational_webhook_endpoint.py
index 5eb7f2f6a5..4bcb88bfb6 100644
--- a/python/svix/api/operational_webhook_endpoint.py
+++ b/python/svix/api/operational_webhook_endpoint.py
@@ -2,23 +2,13 @@
 import typing as t
 from dataclasses import dataclass
 
-from ..internal.openapi_client import models
-from ..internal.openapi_client.models.list_response_operational_webhook_endpoint_out import (
+from .. import models
+from ..models import (
     ListResponseOperationalWebhookEndpointOut,
-)
-from ..internal.openapi_client.models.operational_webhook_endpoint_in import (
     OperationalWebhookEndpointIn,
-)
-from ..internal.openapi_client.models.operational_webhook_endpoint_out import (
     OperationalWebhookEndpointOut,
-)
-from ..internal.openapi_client.models.operational_webhook_endpoint_secret_in import (
     OperationalWebhookEndpointSecretIn,
-)
-from ..internal.openapi_client.models.operational_webhook_endpoint_secret_out import (
     OperationalWebhookEndpointSecretOut,
-)
-from ..internal.openapi_client.models.operational_webhook_endpoint_update import (
     OperationalWebhookEndpointUpdate,
 )
 from .common import ApiBase, BaseOptions, serialize_params
@@ -80,7 +70,7 @@ async def list(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseOperationalWebhookEndpointOut.from_dict(response.json())
+        return ListResponseOperationalWebhookEndpointOut.model_validate(response.json())
 
     async def create(
         self,
@@ -94,9 +84,11 @@ async def create(
             path_params={},
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=operational_webhook_endpoint_in.to_dict(),
+            json_body=operational_webhook_endpoint_in.model_dump_json(
+                exclude_unset=True
+            ),
         )
-        return OperationalWebhookEndpointOut.from_dict(response.json())
+        return OperationalWebhookEndpointOut.model_validate(response.json())
 
     async def get(self, endpoint_id: str) -> OperationalWebhookEndpointOut:
         """Get an operational webhook endpoint."""
@@ -107,7 +99,7 @@ async def get(self, endpoint_id: str) -> OperationalWebhookEndpointOut:
                 "endpoint_id": endpoint_id,
             },
         )
-        return OperationalWebhookEndpointOut.from_dict(response.json())
+        return OperationalWebhookEndpointOut.model_validate(response.json())
 
     async def update(
         self,
@@ -121,9 +113,11 @@ async def update(
             path_params={
                 "endpoint_id": endpoint_id,
             },
-            json_body=operational_webhook_endpoint_update.to_dict(),
+            json_body=operational_webhook_endpoint_update.model_dump_json(
+                exclude_unset=True
+            ),
         )
-        return OperationalWebhookEndpointOut.from_dict(response.json())
+        return OperationalWebhookEndpointOut.model_validate(response.json())
 
     async def delete(self, endpoint_id: str) -> None:
         """Delete an operational webhook endpoint."""
@@ -147,7 +141,7 @@ async def get_secret(self, endpoint_id: str) -> OperationalWebhookEndpointSecret
                 "endpoint_id": endpoint_id,
             },
         )
-        return OperationalWebhookEndpointSecretOut.from_dict(response.json())
+        return OperationalWebhookEndpointSecretOut.model_validate(response.json())
 
     async def rotate_secret(
         self,
@@ -166,7 +160,9 @@ async def rotate_secret(
             },
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=operational_webhook_endpoint_secret_in.to_dict(),
+            json_body=operational_webhook_endpoint_secret_in.model_dump_json(
+                exclude_unset=True
+            ),
         )
 
 
@@ -183,7 +179,7 @@ def list(
             query_params=options._query_params(),
             header_params=options._header_params(),
         )
-        return ListResponseOperationalWebhookEndpointOut.from_dict(response.json())
+        return ListResponseOperationalWebhookEndpointOut.model_validate(response.json())
 
     def create(
         self,
@@ -197,9 +193,11 @@ def create(
             path_params={},
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=operational_webhook_endpoint_in.to_dict(),
+            json_body=operational_webhook_endpoint_in.model_dump_json(
+                exclude_unset=True
+            ),
         )
-        return OperationalWebhookEndpointOut.from_dict(response.json())
+        return OperationalWebhookEndpointOut.model_validate(response.json())
 
     def get(self, endpoint_id: str) -> OperationalWebhookEndpointOut:
         """Get an operational webhook endpoint."""
@@ -210,7 +208,7 @@ def get(self, endpoint_id: str) -> OperationalWebhookEndpointOut:
                 "endpoint_id": endpoint_id,
             },
         )
-        return OperationalWebhookEndpointOut.from_dict(response.json())
+        return OperationalWebhookEndpointOut.model_validate(response.json())
 
     def update(
         self,
@@ -224,9 +222,11 @@ def update(
             path_params={
                 "endpoint_id": endpoint_id,
             },
-            json_body=operational_webhook_endpoint_update.to_dict(),
+            json_body=operational_webhook_endpoint_update.model_dump_json(
+                exclude_unset=True
+            ),
         )
-        return OperationalWebhookEndpointOut.from_dict(response.json())
+        return OperationalWebhookEndpointOut.model_validate(response.json())
 
     def delete(self, endpoint_id: str) -> None:
         """Delete an operational webhook endpoint."""
@@ -250,7 +250,7 @@ def get_secret(self, endpoint_id: str) -> OperationalWebhookEndpointSecretOut:
                 "endpoint_id": endpoint_id,
             },
         )
-        return OperationalWebhookEndpointSecretOut.from_dict(response.json())
+        return OperationalWebhookEndpointSecretOut.model_validate(response.json())
 
     def rotate_secret(
         self,
@@ -269,5 +269,7 @@ def rotate_secret(
             },
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=operational_webhook_endpoint_secret_in.to_dict(),
+            json_body=operational_webhook_endpoint_secret_in.model_dump_json(
+                exclude_unset=True
+            ),
         )
diff --git a/python/svix/api/statistics.py b/python/svix/api/statistics.py
index c717c36c03..a9b300154a 100644
--- a/python/svix/api/statistics.py
+++ b/python/svix/api/statistics.py
@@ -2,11 +2,7 @@
 import typing as t
 from dataclasses import dataclass
 
-from ..internal.openapi_client.models.aggregate_event_types_out import (
-    AggregateEventTypesOut,
-)
-from ..internal.openapi_client.models.app_usage_stats_in import AppUsageStatsIn
-from ..internal.openapi_client.models.app_usage_stats_out import AppUsageStatsOut
+from ..models import AggregateEventTypesOut, AppUsageStatsIn, AppUsageStatsOut
 from .common import ApiBase, BaseOptions, serialize_params
 
 
@@ -38,9 +34,9 @@ async def aggregate_app_stats(
             path_params={},
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=app_usage_stats_in.to_dict(),
+            json_body=app_usage_stats_in.model_dump_json(exclude_unset=True),
         )
-        return AppUsageStatsOut.from_dict(response.json())
+        return AppUsageStatsOut.model_validate(response.json())
 
     async def aggregate_event_types(self) -> AggregateEventTypesOut:
         """Creates a background task to calculate the listed event types for all apps in the organization.
@@ -50,7 +46,7 @@ async def aggregate_event_types(self) -> AggregateEventTypesOut:
         response = await self._request_asyncio(
             method="put", path="/api/v1/stats/usage/event-types", path_params={}
         )
-        return AggregateEventTypesOut.from_dict(response.json())
+        return AggregateEventTypesOut.model_validate(response.json())
 
 
 class Statistics(ApiBase):
@@ -69,9 +65,9 @@ def aggregate_app_stats(
             path_params={},
             query_params=options._query_params(),
             header_params=options._header_params(),
-            json_body=app_usage_stats_in.to_dict(),
+            json_body=app_usage_stats_in.model_dump_json(exclude_unset=True),
         )
-        return AppUsageStatsOut.from_dict(response.json())
+        return AppUsageStatsOut.model_validate(response.json())
 
     def aggregate_event_types(self) -> AggregateEventTypesOut:
         """Creates a background task to calculate the listed event types for all apps in the organization.
@@ -81,4 +77,4 @@ def aggregate_event_types(self) -> AggregateEventTypesOut:
         response = self._request_sync(
             method="put", path="/api/v1/stats/usage/event-types", path_params={}
         )
-        return AggregateEventTypesOut.from_dict(response.json())
+        return AggregateEventTypesOut.model_validate(response.json())