@@ -42,6 +42,33 @@ pub struct OndeModel {
4242 pub format : Option < String > ,
4343 pub approx_size_bytes : Option < i64 > ,
4444 pub description : Option < String > ,
45+ /// `true` if this row was self-registered by a client (e.g. a fine-tune
46+ /// pushed to Hugging Face) rather than one of the official catalog
47+ /// models. Private to the registering user — other clients never see it.
48+ #[ serde( default ) ]
49+ pub custom : bool ,
50+ }
51+
52+ /// Parameters for registering a new model into the catalog via
53+ /// [`create_model`]. The new row is private to the calling user.
54+ #[ derive( Debug , Clone , Serialize ) ]
55+ pub struct CreateModelParams < ' a > {
56+ pub hf_repo_id : & ' a str ,
57+ pub name : & ' a str ,
58+ pub org : & ' a str ,
59+ pub family : & ' a str ,
60+ pub parameter_class : & ' a str ,
61+ pub format : & ' a str ,
62+ pub gguf_file : Option < & ' a str > ,
63+ pub modality : Option < & ' a str > ,
64+ pub description : Option < & ' a str > ,
65+ pub approx_size_bytes : Option < i64 > ,
66+ }
67+
68+ // POST /models body shape: { "gresiq_model": { ... } }
69+ #[ derive( Serialize ) ]
70+ struct CreateModelBody < ' a > {
71+ gresiq_model : CreateModelParams < ' a > ,
4572}
4673
4774// The models endpoint wraps its array: { "models": [...] }.
@@ -181,6 +208,33 @@ pub async fn list_models(
181208 . models )
182209}
183210
211+ /// Register a new model into the catalog, private to the calling user.
212+ ///
213+ /// Typical use: right after uploading a fine-tuned GGUF to Hugging Face, so
214+ /// it can then be targeted by [`assign_model`].
215+ ///
216+ /// `POST /v1/client/gresiq/models` — body: `{ "gresiq_model": { ... } }`
217+ pub async fn create_model (
218+ environment : & Environment ,
219+ app_id : & str ,
220+ app_secret : & str ,
221+ access_token : & str ,
222+ params : CreateModelParams < ' _ > ,
223+ ) -> Result < OndeModel , GresiqError > {
224+ let url = endpoint ( environment, "models" , app_id, app_secret) ;
225+ let body = CreateModelBody {
226+ gresiq_model : params,
227+ } ;
228+ let response = reqwest:: Client :: new ( )
229+ . post ( & url)
230+ . header ( "Authorization" , bearer ( access_token) )
231+ . header ( "Content-Type" , "application/json" )
232+ . json ( & body)
233+ . send ( )
234+ . await ?;
235+ Ok ( check ( response) . await ?. json :: < OndeModel > ( ) . await ?)
236+ }
237+
184238/// Rename an existing app.
185239///
186240/// `PATCH /v1/client/gresiq/apps/{onde_app_id}` — body: `{ "gresiq_app": { "name": "..." } }`
0 commit comments