# Finetunes ## List Finetunes `client.AI.Finetunes.List(ctx, query) (*FinetuneListResponse, error)` **get** `/accounts/{account_id}/ai/finetunes` Lists all fine-tuning jobs created by the account, including status and metrics. ### Parameters - `query FinetuneListParams` - `AccountID param.Field[string]` ### Returns - `type FinetuneListResponse struct{…}` - `ID string` - `CreatedAt Time` - `Model string` - `ModifiedAt Time` - `Name string` - `Description string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/ai" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) finetunes, err := client.AI.Finetunes.List(context.TODO(), ai.FinetuneListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", finetunes.ID) } ``` #### Response ```json { "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "created_at": "2019-12-27T18:11:19.117Z", "model": "model", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name", "description": "description" }, "success": true } ``` ## Create a new Finetune `client.AI.Finetunes.New(ctx, params) (*FinetuneNewResponse, error)` **post** `/accounts/{account_id}/ai/finetunes` Creates a new fine-tuning job for a Workers AI model using custom training data. ### Parameters - `params FinetuneNewParams` - `AccountID param.Field[string]` Path param - `Model param.Field[string]` Body param - `Name param.Field[string]` Body param - `Description param.Field[string]` Body param - `Public param.Field[bool]` Body param ### Returns - `type FinetuneNewResponse struct{…}` - `ID string` - `CreatedAt Time` - `Model string` - `ModifiedAt Time` - `Name string` - `Public bool` - `Description string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/ai" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) finetune, err := client.AI.Finetunes.New(context.TODO(), ai.FinetuneNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Model: cloudflare.F("model"), Name: cloudflare.F("name"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", finetune.ID) } ``` #### Response ```json { "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "created_at": "2019-12-27T18:11:19.117Z", "model": "model", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name", "public": true, "description": "description" }, "success": true } ``` # Assets ## Upload a Finetune Asset `client.AI.Finetunes.Assets.New(ctx, finetuneID, params) (*FinetuneAssetNewResponse, error)` **post** `/accounts/{account_id}/ai/finetunes/{finetune_id}/finetune-assets` Uploads training data assets for a Workers AI fine-tuning job. ### Parameters - `finetuneID string` - `params FinetuneAssetNewParams` - `AccountID param.Field[string]` Path param - `File param.Field[Reader]` Body param - `FileName param.Field[string]` Body param ### Returns - `type FinetuneAssetNewResponse struct{…}` - `Success bool` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/ai" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) asset, err := client.AI.Finetunes.Assets.New( context.TODO(), "bc451aef-f723-4b26-a6b2-901afd2e7a8a", ai.FinetuneAssetNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", asset.Success) } ``` #### Response ```json { "success": true } ``` # Public ## List Public Finetunes `client.AI.Finetunes.Public.List(ctx, params) (*SinglePage[FinetunePublicListResponse], error)` **get** `/accounts/{account_id}/ai/finetunes/public` Lists publicly available fine-tuned models that can be used with Workers AI. ### Parameters - `params FinetunePublicListParams` - `AccountID param.Field[string]` Path param - `Limit param.Field[float64]` Query param: Pagination Limit - `Offset param.Field[float64]` Query param: Pagination Offset - `OrderBy param.Field[string]` Query param: Order By Column Name ### Returns - `type FinetunePublicListResponse struct{…}` - `ID string` - `CreatedAt Time` - `Model string` - `ModifiedAt Time` - `Name string` - `Public bool` - `Description string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/ai" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.AI.Finetunes.Public.List(context.TODO(), ai.FinetunePublicListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "result": [ { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "created_at": "2019-12-27T18:11:19.117Z", "model": "model", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name", "public": true, "description": "description" } ], "success": true } ```