1414 ReadmeResourceWithStreamingResponse ,
1515 AsyncReadmeResourceWithStreamingResponse ,
1616)
17- from ...types import model_create_params , model_search_params
17+ from ...types import model_list_params , model_create_params , model_search_params
1818from ..._types import Body , Omit , Query , Headers , NoneType , NotGiven , omit , not_given
1919from ..._utils import maybe_transform , async_maybe_transform
2020from .examples import (
@@ -209,6 +209,8 @@ def create(
209209 def list (
210210 self ,
211211 * ,
212+ sort_by : Literal ["model_created_at" , "latest_version_created_at" ] | Omit = omit ,
213+ sort_direction : Literal ["asc" , "desc" ] | Omit = omit ,
212214 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
213215 # The extra values given here take precedence over values defined on the client or passed to this method.
214216 extra_headers : Headers | None = None ,
@@ -231,12 +233,56 @@ def list(
231233
232234 See the [`models.get`](#models.get) docs for more details about the model
233235 object.
236+
237+ ## Sorting
238+
239+ You can sort the results using the `sort_by` and `sort_direction` query
240+ parameters.
241+
242+ For example, to get the most recently created models:
243+
244+ ```console
245+ curl -s \\
246+ -H "Authorization: Bearer $REPLICATE_API_TOKEN" \\
247+ "https://api.replicate.com/v1/models?sort_by=model_created_at&sort_direction=desc"
248+ ```
249+
250+ Available sorting options:
251+
252+ - `model_created_at`: Sort by when the model was first created
253+ - `latest_version_created_at`: Sort by when the model's latest version was
254+ created (default)
255+
256+ Sort direction can be `asc` (ascending) or `desc` (descending, default).
257+
258+ Args:
259+ sort_by: Field to sort models by. Defaults to `latest_version_created_at`.
260+
261+ sort_direction: Sort direction. Defaults to `desc` (descending, newest first).
262+
263+ extra_headers: Send extra headers
264+
265+ extra_query: Add additional query parameters to the request
266+
267+ extra_body: Add additional JSON properties to the request
268+
269+ timeout: Override the client-level default timeout for this request, in seconds
234270 """
235271 return self ._get_api_list (
236272 "/models" ,
237273 page = SyncCursorURLPage [ModelListResponse ],
238274 options = make_request_options (
239- extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
275+ extra_headers = extra_headers ,
276+ extra_query = extra_query ,
277+ extra_body = extra_body ,
278+ timeout = timeout ,
279+ query = maybe_transform (
280+ {
281+ "sort_by" : sort_by ,
282+ "sort_direction" : sort_direction ,
283+ },
284+ model_list_params .ModelListParams ,
285+ ),
240286 ),
241287 model = ModelListResponse ,
242288 )
@@ -608,6 +654,8 @@ async def create(
608654 def list (
609655 self ,
610656 * ,
657+ sort_by : Literal ["model_created_at" , "latest_version_created_at" ] | Omit = omit ,
658+ sort_direction : Literal ["asc" , "desc" ] | Omit = omit ,
611659 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
612660 # The extra values given here take precedence over values defined on the client or passed to this method.
613661 extra_headers : Headers | None = None ,
@@ -630,12 +678,56 @@ def list(
630678
631679 See the [`models.get`](#models.get) docs for more details about the model
632680 object.
681+
682+ ## Sorting
683+
684+ You can sort the results using the `sort_by` and `sort_direction` query
685+ parameters.
686+
687+ For example, to get the most recently created models:
688+
689+ ```console
690+ curl -s \\
691+ -H "Authorization: Bearer $REPLICATE_API_TOKEN" \\
692+ "https://api.replicate.com/v1/models?sort_by=model_created_at&sort_direction=desc"
693+ ```
694+
695+ Available sorting options:
696+
697+ - `model_created_at`: Sort by when the model was first created
698+ - `latest_version_created_at`: Sort by when the model's latest version was
699+ created (default)
700+
701+ Sort direction can be `asc` (ascending) or `desc` (descending, default).
702+
703+ Args:
704+ sort_by: Field to sort models by. Defaults to `latest_version_created_at`.
705+
706+ sort_direction: Sort direction. Defaults to `desc` (descending, newest first).
707+
708+ extra_headers: Send extra headers
709+
710+ extra_query: Add additional query parameters to the request
711+
712+ extra_body: Add additional JSON properties to the request
713+
714+ timeout: Override the client-level default timeout for this request, in seconds
633715 """
634716 return self ._get_api_list (
635717 "/models" ,
636718 page = AsyncCursorURLPage [ModelListResponse ],
637719 options = make_request_options (
638- extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
720+ extra_headers = extra_headers ,
721+ extra_query = extra_query ,
722+ extra_body = extra_body ,
723+ timeout = timeout ,
724+ query = maybe_transform (
725+ {
726+ "sort_by" : sort_by ,
727+ "sort_direction" : sort_direction ,
728+ },
729+ model_list_params .ModelListParams ,
730+ ),
639731 ),
640732 model = ModelListResponse ,
641733 )
0 commit comments