Method: locations.generateSyntheticData

Full name: projects.locations.generateSyntheticData

Generates synthetic (artificial) data based on a description

Endpoint

post https://aiplatform.googleapis.com/v1/{location}:generateSyntheticData

Path parameters

location string

Required. The geographic location where the synthetic data generation request is processed. This should be in the format projects/{project}/locations/{location}. For example, projects/my-project/locations/us-central1.

Request body

The request body contains data with the following structure:

Fields
count integer

Required. The number of synthetic examples to generate. For this stateless API, you can generate up to 50 examples in a single request.

outputFieldSpecs[] object (OutputFieldSpec)

Required. Defines the schema of each synthetic example to be generated, defined by a list of fields.

examples[] object (SyntheticExample)

Optional. A list of few-shot examples that help the model understand the desired style, tone, and format of the generated synthetic data. Providing these few-shot examples can significantly improve the quality and relevance of the output.

strategy Union type
Specifies how the synthetic data should be generated. Choose one of the available strategies. strategy can be only one of the following:
taskDescription object (TaskDescriptionStrategy)

Generates synthetic data based on a high-level description of the task or data you want.

Response body

The response message for the locations.generateSyntheticData method, containing the synthetic examples generated by the Gen AI evaluation service.

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

Fields
syntheticExamples[] object (SyntheticExample)

A list of generated synthetic examples, each containing a complete synthetic data instance generated based on your request.

JSON representation
{
  "syntheticExamples": [
    {
      object (SyntheticExample)
    }
  ]
}

TaskDescriptionStrategy

Defines a generation strategy based on a general task description.

Fields
taskDescription string

Required. A general description of the type of synthetic data you want to generate. For example, "Generate customer reviews for a new smartphone."

JSON representation
{
  "taskDescription": string
}

OutputFieldSpec

Specifies the properties of a single field that are included in each generated synthetic example. This helps the model understand what kind of data to generate for each field.

Fields
fieldName string

Required. The name of this field in the generated synthetic data, such as "emailSubject" or "customer_review".

guidance string

Optional. Specific instructions for the large language model on how to generate content for this particular field. While the LLM can sometimes infer content from the field name, providing explicit guidance is preferred. For example, for a field named "review", the guidance could be "A positive review about a coffee maker."

fieldType enum (FieldType)

Optional. The data type of the field. Defaults to CONTENT if not set.

JSON representation
{
  "fieldName": string,
  "guidance": string,
  "fieldType": enum (FieldType)
}

FieldType

The type of data expected for this field. This helps the model generate content in the correct format.

Enums
FIELD_TYPE_UNSPECIFIED The field type is not specified. Defaults to CONTENT.
CONTENT The field can contain any type of content, including text, images, and audio.
TEXT The field contains only text.
IMAGE The field contains image data.
AUDIO The field contains audio data.

SyntheticExample

A single instance of generated synthetic data. Each example is made up of one or more named fields, as defined in OutputFieldSpec. These examples are used as few-shot examples to show the model what you want (in GenerateSyntheticDataRequest.examples) and to return generated examples in the response (in GenerateSyntheticDataResponse.synthetic_examples).

Fields
fields[] object (SyntheticField)

Required. A list of fields that constitute an example.

JSON representation
{
  "fields": [
    {
      object (SyntheticField)
    }
  ]
}

SyntheticField

Represents a single named field within a synthetic example, consisting of a name and the actual content.

Fields
fieldName string

Optional. The name of the specific field, such as "productName" or "reviewText".

content object (Content)

Required. The actual content or value for this field. This can be text, images, or other types of data.

JSON representation
{
  "fieldName": string,
  "content": {
    object (Content)
  }
}