**Full name**: projects.locations.schemas.schemaVersions.generate

Generates a schema version.

### HTTP request

Choose a location:
<button value="global" default="">global</button> <button value="us">us</button> <button value="eu">eu</button> <button value="asia-south1">asia-south1</button> <button value="asia-southeast1">asia-southeast1</button> <button value="northamerica-northeast1">northamerica-northeast1</button> <button value="australia-southeast1">australia-southeast1</button> <button value="europe-west2">europe-west2</button> <button value="europe-west3">europe-west3</button>   
`POST https://documentai.googleapis.com/v1/{parent}/schemaVersions:generate`

<br />

### Path parameters

| Parameters ||
|---|---|
| `parent` | `string` Required. The parent (project, location and schema) under which to generate the SchemaVersion. Format: `projects/{project}/locations/{location}/schemas/{schema}` It takes the form `projects/{project}/locations/{location}/schemas/{schema}`. |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "generateSchemaVersionParams": { object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/projects.locations.schemas.schemaVersions/generate#GenerateSchemaVersionParams`) }, // Union field `source` can be only one of the following: "inlineDocuments": { object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/projects.locations.schemas.schemaVersions/generate#Documents`) }, "rawDocuments": { object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/projects.locations.schemas.schemaVersions/generate#RawDocuments`) }, "gcsDocuments": { object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/GcsDocuments`) }, "gcsPrefix": { object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/GcsPrefix`) }, "baseSchemaVersion": string // End of list of possible types for union field `source`. } ``` |

| Fields ||
|---|---|
| `generateSchemaVersionParams` | ``object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/projects.locations.schemas.schemaVersions/generate#GenerateSchemaVersionParams`)`` Optional. User specified parameters for the schema generation. |
| Union field `source`. Source of the documents which will be used for schema generation. `source` can be only one of the following: ||
| `inlineDocuments` | ``object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/projects.locations.schemas.schemaVersions/generate#Documents`)`` The set of documents specified inline. For each document, its `uri` or `content` field must be set. |
| `rawDocuments` | ``object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/projects.locations.schemas.schemaVersions/generate#RawDocuments`)`` The set of raw documents. |
| `gcsDocuments` | ``object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/GcsDocuments`)`` The set of documents placed on Cloud Storage. |
| `gcsPrefix` | ``object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/GcsPrefix`)`` The common prefix of documents placed on Cloud Storage. |
| `baseSchemaVersion` | `string` The base schema version name to use for the schema generation. Format: `projects/{project}/locations/{location}/schemas/{schema}/schemaVersions/{schemaVersion}` |

### Response body

Response message for schemaVersions.generate.

If successful, the response body contains data with the following structure:

| JSON representation |
|---|
| ``` { "schemaVersion": { object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/projects.locations.schemas.schemaVersions#SchemaVersion`) } } ``` |

| Fields ||
|---|---|
| `schemaVersion` | ``object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/projects.locations.schemas.schemaVersions#SchemaVersion`)`` The schema version generated by the model. |

### Authorization scopes

Requires the following OAuth scope:

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

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 `parent` resource:

- `documentai.schemaVersions.create`

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

## Documents

A set of inline documents.

| JSON representation |
|---|
| ``` { "documents": [ { object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/Document`) } ] } ``` |

| Fields ||
|---|---|
| `documents[]` | ``object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/Document`)`` The list of documents. |

## RawDocuments

Specifies a set of raw documents.

| JSON representation |
|---|
| ``` { "documents": [ { object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/RawDocument`) } ] } ``` |

| Fields ||
|---|---|
| `documents[]` | ``object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/RawDocument`)`` Specifies raw document content and mime type. |

## GenerateSchemaVersionParams

The parameters for the schema generation.

| JSON representation |
|---|
| ``` { "prompt": string, "history": { object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/projects.locations.schemas.schemaVersions/generate#SchemaGenerationHistory`) } } ``` |

| Fields ||
|---|---|
| `prompt` | `string` Optional. The prompt used for the schema generation. |
| `history` | ``object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/projects.locations.schemas.schemaVersions/generate#SchemaGenerationHistory`)`` Optional. Previous prompt-answers in a chronological order. |

## SchemaGenerationHistory

The history of schema generation iterations.

| JSON representation |
|---|
| ``` { "iterations": [ { object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/projects.locations.schemas.schemaVersions/generate#SchemaGenerationIteration`) } ] } ``` |

| Fields ||
|---|---|
| `iterations[]` | ``object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/projects.locations.schemas.schemaVersions/generate#SchemaGenerationIteration`)`` Required. Previous prompt-answers in a chronological order. |

## SchemaGenerationIteration

A single iteration of the schema generation.

| JSON representation |
|---|
| ``` { "prompt": string, "generatedSchema": { object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/projects.locations.schemas.schemaVersions#SchemaVersion`) }, "adjustedSchema": { object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/projects.locations.schemas.schemaVersions#SchemaVersion`) } } ``` |

| Fields ||
|---|---|
| `prompt` | `string` Optional. The prompt used for the iteration. |
| `generatedSchema` | ``object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/projects.locations.schemas.schemaVersions#SchemaVersion`)`` Required. The schema version generated by the model. |
| `adjustedSchema` | ``object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1/projects.locations.schemas.schemaVersions#SchemaVersion`)`` Optional. The previous schema version adjusted by the model. |