@@ -150,6 +150,63 @@ def get(self, key: str) -> Model:
150150 resp = self ._client ._request ("GET" , f"/v1/models/{ key } " )
151151 return self ._prepare_model (resp .json ())
152152
153+ def create ( # pylint: disable=arguments-differ disable=too-many-arguments
154+ self ,
155+ owner : str ,
156+ name : str ,
157+ * ,
158+ visibility : str ,
159+ hardware : str ,
160+ description : Optional [str ] = None ,
161+ github_url : Optional [str ] = None ,
162+ paper_url : Optional [str ] = None ,
163+ license_url : Optional [str ] = None ,
164+ cover_image_url : Optional [str ] = None ,
165+ ) -> Model :
166+ """
167+ Create a model.
168+
169+ Args:
170+ owner: The name of the user or organization that will own the model.
171+ name: The name of the model.
172+ visibility: Whether the model should be public or private.
173+ hardware: The SKU for the hardware used to run the model. Possible values can be found by calling `replicate.hardware.list()`.
174+ description: A description of the model.
175+ github_url: A URL for the model's source code on GitHub.
176+ paper_url: A URL for the model's paper.
177+ license_url: A URL for the model's license.
178+ cover_image_url: A URL for the model's cover image.
179+
180+ Returns:
181+ The created model.
182+ """
183+
184+ body = {
185+ "owner" : owner ,
186+ "name" : name ,
187+ "visibility" : visibility ,
188+ "hardware" : hardware ,
189+ }
190+
191+ if description is not None :
192+ body ["description" ] = description
193+
194+ if github_url is not None :
195+ body ["github_url" ] = github_url
196+
197+ if paper_url is not None :
198+ body ["paper_url" ] = paper_url
199+
200+ if license_url is not None :
201+ body ["license_url" ] = license_url
202+
203+ if cover_image_url is not None :
204+ body ["cover_image_url" ] = cover_image_url
205+
206+ resp = self ._client ._request ("POST" , "/v1/models" , json = body )
207+
208+ return self ._prepare_model (resp .json ())
209+
153210 def _prepare_model (self , attrs : Union [Model , Dict ]) -> Model :
154211 if isinstance (attrs , BaseModel ):
155212 attrs .id = f"{ attrs .owner } /{ attrs .name } "
0 commit comments