@@ -24,6 +24,9 @@ examples:
2424 # create from a template
2525 runpodctl serverless create --template-id <id> --gpu-id "NVIDIA GeForce RTX 4090"
2626
27+ # create from a template and attach a model
28+ runpodctl serverless create --template-id <id> --gpu-id ADA_24 --model-reference https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct:main
29+
2730 # create from a hub repo
2831 runpodctl hub search vllm # find the hub id
2932 runpodctl serverless create --hub-id <id> --gpu-id "NVIDIA GeForce RTX 4090"
4649 createDataCenterIDs string
4750 createNetworkVolumeID string
4851 createEnvVars []string
52+ createModelReferences []string
4953)
5054
5155func init () {
@@ -60,6 +64,7 @@ func init() {
6064 createCmd .Flags ().StringVar (& createDataCenterIDs , "data-center-ids" , "" , "comma-separated list of data center ids" )
6165 createCmd .Flags ().StringVar (& createNetworkVolumeID , "network-volume-id" , "" , "network volume id to attach" )
6266 createCmd .Flags ().StringSliceVar (& createEnvVars , "env" , nil , "env vars in KEY=VALUE format; overrides hub defaults (repeatable)" )
67+ createCmd .Flags ().StringArrayVar (& createModelReferences , "model-reference" , nil , "model reference to attach to the endpoint (repeatable)" )
6368}
6469
6570func runCreate (cmd * cobra.Command , args []string ) error {
@@ -69,6 +74,13 @@ func runCreate(cmd *cobra.Command, args []string) error {
6974 if createTemplateID != "" && createHubID != "" {
7075 return fmt .Errorf ("--template-id and --hub-id are mutually exclusive; use one or the other" )
7176 }
77+ if createHubID != "" && len (createModelReferences ) > 0 {
78+ return fmt .Errorf ("--model-reference is only supported with --template-id" )
79+ }
80+ computeType := strings .ToUpper (strings .TrimSpace (createComputeType ))
81+ if len (createModelReferences ) > 0 && computeType != "" && computeType != "GPU" {
82+ return fmt .Errorf ("--model-reference is only supported with --compute-type GPU" )
83+ }
7284
7385 client , err := api .NewClient ()
7486 if err != nil {
@@ -79,7 +91,7 @@ func runCreate(cmd *cobra.Command, args []string) error {
7991 req := & api.EndpointCreateRequest {
8092 Name : createName ,
8193 TemplateID : createTemplateID ,
82- ComputeType : strings . ToUpper ( strings . TrimSpace ( createComputeType )) ,
94+ ComputeType : computeType ,
8395 GpuCount : createGpuCount ,
8496 WorkersMin : createWorkersMin ,
8597 WorkersMax : createWorkersMax ,
@@ -211,6 +223,18 @@ func runCreate(cmd *cobra.Command, args []string) error {
211223 req .DataCenterIDs = strings .Split (createDataCenterIDs , "," )
212224 }
213225
226+ if len (createModelReferences ) > 0 {
227+ gqlReq := buildTemplateEndpointGQLInput (req , gpuTypeID , createDataCenterIDs , createModelReferences )
228+ endpoint , err := client .CreateEndpointGQL (gqlReq )
229+ if err != nil {
230+ output .Error (err )
231+ return fmt .Errorf ("failed to create endpoint: %w" , err )
232+ }
233+
234+ format := output .ParseFormat (cmd .Flag ("output" ).Value .String ())
235+ return output .Print (endpoint , & output.Config {Format : format })
236+ }
237+
214238 endpoint , err := client .CreateEndpoint (req )
215239 if err != nil {
216240 output .Error (err )
@@ -221,6 +245,21 @@ func runCreate(cmd *cobra.Command, args []string) error {
221245 return output .Print (endpoint , & output.Config {Format : format })
222246}
223247
248+ func buildTemplateEndpointGQLInput (req * api.EndpointCreateRequest , gpuTypeID , locations string , modelReferences []string ) * api.EndpointCreateGQLInput {
249+ // saveEndpoint derives GPU by default when instanceIds is omitted; computeType is not part of EndpointInput.
250+ return & api.EndpointCreateGQLInput {
251+ Name : req .Name ,
252+ TemplateID : req .TemplateID ,
253+ GpuIDs : gpuTypeID ,
254+ GpuCount : req .GpuCount ,
255+ WorkersMin : req .WorkersMin ,
256+ WorkersMax : req .WorkersMax ,
257+ Locations : locations ,
258+ NetworkVolumeID : req .NetworkVolumeID ,
259+ ModelReferences : modelReferences ,
260+ }
261+ }
262+
224263func randomString (n int ) string {
225264 const letters = "abcdefghijklmnopqrstuvwxyz0123456789"
226265 b := make ([]byte , n )
0 commit comments