- [HTTP request](https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1alpha/projects.locations.collections.dataStores/trainCustomModel#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1alpha/projects.locations.collections.dataStores/trainCustomModel#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1alpha/projects.locations.collections.dataStores/trainCustomModel#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1alpha/projects.locations.collections.dataStores/trainCustomModel#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1alpha/projects.locations.collections.dataStores/trainCustomModel#body.response_body)
- [Authorization scopes](https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1alpha/projects.locations.collections.dataStores/trainCustomModel#body.aspect)
- [IAM Permissions](https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1alpha/projects.locations.collections.dataStores/trainCustomModel#body.aspect_1)
- [GcsTrainingInput](https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1alpha/projects.locations.collections.dataStores/trainCustomModel#GcsTrainingInput)
  - [JSON representation](https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1alpha/projects.locations.collections.dataStores/trainCustomModel#GcsTrainingInput.SCHEMA_REPRESENTATION)

Trains a custom model.

### HTTP request

Choose an endpoint:
global us   
`POST https://discoveryengine.googleapis.com/v1alpha/{dataStore=projects/*/locations/*/collections/*/dataStores/*}:trainCustomModel`

<br />

The URLs use [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Path parameters

| Parameters ||
|---|---|
| `dataStore` | `string` Required. The resource name of the Data Store, such as `projects/*/locations/global/collections/default_collection/dataStores/default_data_store`. This field is used to identify the data store where to train the models. |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "modelType": string, "errorConfig": { object (`https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1alpha/ImportErrorConfig`) }, "modelId": string, // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "gcsTrainingInput": { object (`https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1alpha/projects.locations.collections.dataStores/trainCustomModel#GcsTrainingInput`) } // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| `modelType` | `string` Model to be trained. Supported values are: - **search-tuning**: Fine tuning the search system based on data provided. |
| `errorConfig` | ``object (`https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1alpha/ImportErrorConfig`)`` The desired location of errors incurred during the data ingestion and training. |
| `modelId` | `string` If not provided, a UUID will be generated. |
| Model training input. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `gcsTrainingInput` | ``object (`https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1alpha/projects.locations.collections.dataStores/trainCustomModel#GcsTrainingInput`)`` Cloud Storage training input. |
| End of mutually exclusive fields. ||

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/Shared.Types/ListOperationsResponse#Operation`.

### Authorization scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/cloud-platform`
- `https://www.googleapis.com/auth/discoveryengine.readwrite`
- `https://www.googleapis.com/auth/discoveryengine.serving.readwrite`

For more information, see the [Authentication Overview](https://docs.cloud.google.com/docs/authentication#authorization-gcp).

### IAM Permissions

Requires the following [IAM](https://cloud.google.com/iam/docs) permission on the `dataStore` resource:

- `discoveryengine.dataStores.trainCustomModel`

For more information, see the [IAM documentation](https://cloud.google.com/iam/docs).

## GcsTrainingInput

Cloud Storage training data input.

| JSON representation |
|---|
| ``` { "corpusDataPath": string, "queryDataPath": string, "trainDataPath": string, "testDataPath": string } ``` |

| Fields ||
|---|---|
| `corpusDataPath` | `string` The Cloud Storage corpus data which could be associated in train data. The data path format is `gs://<bucket_to_data>/<jsonl_file_name>`. A newline delimited jsonl/ndjson file. For search-tuning model, each line should have the Id, title and text. Example: `{"Id": "doc1", title: "relevant doc", "text": "relevant text"}` |
| `queryDataPath` | `string` The gcs query data which could be associated in train data. The data path format is `gs://<bucket_to_data>/<jsonl_file_name>`. A newline delimited jsonl/ndjson file. For search-tuning model, each line should have the Id and text. Example: {"Id": "query1", "text": "example query"} |
| `trainDataPath` | `string` Cloud Storage training data path whose format should be `gs://<bucket_to_data>/<tsv_file_name>`. The file should be in tsv format. Each line should have the docId and queryId and score (number). For search-tuning model, it should have the query-id corpus-id score as tsv file header. The score should be a number in `[0, inf+)`. The larger the number is, the more relevant the pair is. Example: - `query-id\tcorpus-id\tscore` - `query1\tdoc1\t1` |
| `testDataPath` | `string` Cloud Storage test data. Same format as trainDataPath. If not provided, a random 80/20 train/test split will be performed on trainDataPath. |