Create a feature view instance

You can create a feature view within an existing online store instance. Whilecreating a feature view, you can associate features with it in the followingways:

After you create a feature view, Vertex AI Feature Store syncs thelatest feature values from the BigQuery data source. If you set thequery parameterrun_sync_immediately=true, then Vertex AI Feature Storesyncs the feature values when you create the feature view. Otherwise,Vertex AI Feature Store syncs the feature values according to thesync schedule specified for the feature view.

Before you begin

Authenticate toVertex AI, unless you've done so already.

Select the tab for how you plan to use the samples on this page:

Console

When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.

Python

To use the Python samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.

    Install the Google Cloud CLI.

    If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

    If you're using a local shell, then create local authentication credentials for your user account:

    gcloudauthapplication-defaultlogin

    You don't need to do this if you're using Cloud Shell.

    If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.

For more information, see Set up authentication for a local development environment.

REST

To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.

    Install the Google Cloud CLI.

    If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

For more information, seeAuthenticate for using REST in the Google Cloud authentication documentation.

Sync feature data in a feature view

Vertex AI Feature Store can refresh or sync the feature values from theBigQuery data source to the feature view. You can specify the type ofdata sync for a feature view by using theFeatureView.sync_configparameter.

Note: If your online store instance uses Bigtable online serving, the featurerecords that you delete from the BigQuery source tableare retained in the corresponding feature views, even when you sync the data.To delete those feature records, you mustdelete the feature view.

Vertex AI Feature Store supports the following types of data sync:

  • Scheduled data sync: You can specify the schedule or frequency for thedata sync. You can choose this scheduled data sync for a feature view,regardless of the online serving type specified for the online store instance.

    If your feature view is configured to use scheduled data sync, you canoptionally skip the wait until the next scheduled sync operation, by manuallyinitiating the data sync. For more information about manually triggering a datasync, seeSync feature data to online store.

    During online serving, if you want to serve only the latest feature values,including null values, you must use the following setup:

    1. Register your feature data source by creating a feature groupwith thedense parameter set totrue.

    2. Choose Bigtable online serving when youcreate the online store instance.

    3. Choose scheduled data sync when you create your feature views.

  • Continuous data sync: The feature data is refreshed whenever the featuredata in the BigQuery data source is updated. You can choose this typeof data sync for a feature view only if all of the following conditions are fulfilled:

    • The online store instance is configured for Bigtable online serving.

    • The feature view is associated with feature groups and feature resources.

    • The BigQuery data source is located in any of the followingregions:

      • eu

      • us

      • us-central1

    Continuous data sync has the following limitations:

    • You can't update a feature view if you select continuous data sync for it.

    • Only new feature records are synced from the BigQuerydata source. Continuous data sync doesn't sync feature records that youupdate or delete in BigQuery.

    • The feature group in the Feature Registry source must havea BigQuery table as its source.

Optimize costs during scheduled data sync

A data sync operation might involve costs for BigQuery resource usage. Followthese guidelines to optimize these costs and improve performance during a datasync:

  • Don't configure the sync schedule to run more frequently than the frequencyat which the data is expected to change in the BigQuery source.

  • Optimize the size of the feature data source in BigQuery. Whilecreating the feature view, only include the data that you need for onlineserving.

  • Avoid running complex aggregations in BigQuery. Run aSELECT *query on the table or view to estimate the volume and duration of dataprocessing.

  • While setting the scaling options for the online store, setmax_node_countto a value that's high enough to cover high loads during a data sync.

  • Schedule the sync for different feature views at different times within thesame online store.

  • If your BigQuery table contains extensive historical data,consider partitioning the table using timestamps and specify a time range forretrieving the feature data. This minimizes the retrieval of obsolete featuredata during sync.

  • Bigtable utilization increases during data syncs. For feature viewscreated within online stores for Bigtable online serving, schedule sync jobsduring off-peak times for best performance.

Configure the service account for a feature view

Each feature view uses a service account to access the source data inBigQuery during sync.Vertex AI Feature Store assigns theBigQuery Data ViewerIdentity and Access Management (IAM) role to this service account.

By default, a feature view uses the service account configured for your project.With this configuration, any user with permission to create a feature view inyour project can access the feature data in BigQuery.

Alternatively, you can configure the feature view to use its own serviceaccount. Vertex AI Feature Store then sets up a dedicated serviceaccount for the feature view. With this configuration, you can restrict accessto feature data in BigQuery or grant access to additional users.You can specify the service account configuration by using theFeatureView.service_agent_typeparameter. Note that Vertex AI Feature Store generates a unique serviceaccount email address for each feature view configured to have a dedicatedservice account.

If a feature view is configured to have a dedicated service account, you canview the service account email address in either of the following ways:

Configure vector retrieval for a feature view

You can configure vector retrieval for a feature view within an online storecreated for Optimized online serving by using theFeatureView.index_config parameter.For information about how to prepare or update the BigQuery data source to support embeddingsby including theembedding column, seeData source preparation guidelines.

Note that you can configure vector retrieval and manage embeddings only if the featureview is created by specifying a BigQuery source URI and not fromfeature groups and features from Feature Registry.

For more information about how to search for approximate nearest neighbors usingembeddings in Vertex AI Feature Store, seeSearch using embeddings.

Create a feature view from feature groups

You can create a feature view based on feature data registered using featuregroups and features. To associate multiple BigQuery data sourceswith the same feature view, you can specify multiple feature groups.

If you create a feature view by specifying feature groups and features:

  • Your data source must have afeature_timestamp column and can contain historical data.

  • Vertex AI Feature Store serves only the latest feature valuesbased on the feature timestamp.

  • You can't configure embedding management for the feature view.

Create a feature view with the default service account configuration

Use the following sample to create a feature view by associating multiple feature groupswithout specifying a service account configuration.

REST

To create aFeatureViewresource, send aPOST request by using thefeatureViews.createmethod.

Before using any of the request data, make the following replacements:

  • LOCATION_ID: Region where you want to create the feature view, such asus-central1.
  • PROJECT_ID: Your project ID.
  • FEATUREONLINESTORE_NAME: The name of the online store instance where you want to create the feature view.
  • FEATUREVIEW_NAME: The name of the new feature view instance that you want to create.
  • FEATUREGROUP_NAME_A andFEATUREGROUP_NAME_B: The names of the feature groups from which you want to add features to the feature view.
  • FEATURE_ID_A1 andFEATURE_ID_A2: Feature IDs from the feature groupFEATUREGROUP_NAME_A that you want to add to the feature view.
  • FEATURE_ID_B1 andFEATURE_ID_B2: Feature IDs from the feature groupFEATUREGROUP_NAME_B that you want to add to the feature view.
  • SYNC_CONFIG: Enter one of the following sync configurations for the feature view:
    • To use scheduled data sync, provide the sync schedule in the following format:
      "cron": "cron_schedule_expression"
      Replace `cron_schedule_expression` with the cron schedule expression representing the frequency for syncing data to the feature view. For more information, seecron.
    • To use continuous data sync, enter the following:
      "continuous": true You can use continuous data sync only if the online store instance containing the feature view is configured for Bigtable online serving.

HTTP method and URL:

POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews?feature_view_id=FEATUREVIEW_NAME

Request JSON body:

{  "feature_registry_source": {    "feature_groups": [      {        "feature_group_id": "FEATUREGROUP_NAME_A",        "feature_ids": [ "FEATURE_ID_A1", "FEATURE_ID_A2" ]      },      {        "feature_group_id": "FEATUREGROUP_NAME_B",        "feature_ids": [ "FEATURE_ID_B1", "FEATURE_ID_B2" ]      }    ]  },  "sync_config": {SYNC_CONFIG  }}

To send your request, choose one of these options:

curl

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews?feature_view_id=FEATUREVIEW_NAME"

PowerShell

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews?feature_view_id=FEATUREVIEW_NAME" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME/operations/OPERATION_ID",  "metadata": {    "@type": "type.googleapis.com/google.cloud.aiplatform.v1.CreateFeatureViewOperationMetadata",    "genericMetadata": {      "createTime": "2023-09-15T02:11:29.458820Z",      "updateTime": "2023-09-15T02:11:29.458820Z"    }  }}

Create a feature view that uses a dedicated service account

Use the following sample to create a feature view from feature groups byconfiguring a dedicated service account.

REST

To create aFeatureViewresource, send aPOST request by using thefeatureViews.createmethod.

Before using any of the request data, make the following replacements:

  • LOCATION_ID: Region where you want to create the feature view, such asus-central1.
  • PROJECT_ID: Your project ID.
  • FEATUREONLINESTORE_NAME: The name of the online store instance where you want to create the feature view.
  • FEATUREVIEW_NAME: The name of the new feature view instance that you want to create.
  • FEATUREGROUP_NAME_A andFEATUREGROUP_NAME_B: The names of the feature groups from which you want to add features to the feature view.
  • FEATURE_ID_A1 andFEATURE_ID_A2: Feature IDs from the feature groupFEATUREGROUP_NAME_A that you want to add to the feature view.
  • FEATURE_ID_B1 andFEATURE_ID_B2: Feature IDs from the feature groupFEATUREGROUP_NAME_B that you want to add to the feature view.
  • SYNC_CONFIG: Enter one of the following sync configurations for the feature view:
    • To use scheduled data sync, provide the sync schedule in the following format:
      "cron": "cron_schedule_expression"
      Replace `cron_schedule_expression` with the cron schedule expression representing the frequency for syncing data to the feature view. For more information, seecron.
    • To use continuous data sync, enter the following:
      "continuous": true You can use continuous data sync only if the online store instance containing the feature view is configured for Bigtable online serving.
  • SERVICE_AGENT_TYPE: Service account configuration for the feature view. To use a dedicated service account for the feature view, enterSERVICE_AGENT_TYPE_FEATURE_VIEW.

HTTP method and URL:

POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews?feature_view_id=FEATUREVIEW_NAME

Request JSON body:

{  "feature_registry_source": {    "feature_groups": [      {        "feature_group_id": "FEATUREGROUP_NAME_A",        "feature_ids": [ "FEATURE_ID_A1", "FEATURE_ID_A2" ]      },      {        "feature_group_id": "FEATUREGROUP_NAME_B",        "feature_ids": [ "FEATURE_ID_B1", "FEATURE_ID_B2" ]      }    ]  },  "sync_config": {SYNC_CONFIG  },  "service_agent_type": "SERVICE_AGENT_TYPE",}

To send your request, choose one of these options:

curl

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews?feature_view_id=FEATUREVIEW_NAME"

PowerShell

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews?feature_view_id=FEATUREVIEW_NAME" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME/operations/OPERATION_ID",  "metadata": {    "@type": "type.googleapis.com/google.cloud.aiplatform.v1.CreateFeatureViewOperationMetadata",    "genericMetadata": {      "createTime": "2023-09-15T02:11:29.458820Z",      "updateTime": "2023-09-15T02:11:29.458820Z"    }  }}

Create a feature view from a BigQuery source

If you want to serve features online without registering your BigQuerydata source using feature groups and features, you can create a feature view byspecifying the URI of the BigQuery data source.

If you create a feature view by specifying the data source:

  • You can't include afeature_timestamp column in the BigQuery table or view.

  • You can't include historical feature values in the data source. Every row mustcontain a unique entity ID.

Create a feature view that uses the default service account and doesn't support embeddings

Use the following samples to create a feature view that doesn't support embeddings,by directly associating a BigQuery data source and without specifying aservice account configuration.

Python

To learn how to install or update the Vertex AI SDK for Python, seeInstall the Vertex AI SDK for Python. For more information, see thePython API reference documentation.

fromgoogle.cloudimportaiplatformfromvertexai.resources.previewimportfeature_storefromtypingimportListdefcreate_feature_view_from_bq_source(project:str,location:str,existing_feature_online_store_id:str,feature_view_id:str,bq_table_uri:str,entity_id_columns:List[str],):aiplatform.init(project=project,location=location)fos=feature_store.FeatureOnlineStore(existing_feature_online_store_id)fv=fos.create_feature_view(name=feature_view_id,source=feature_store.utils.FeatureViewBigQuerySource(uri=bq_table_uri,entity_id_columns=entity_id_columns),)returnfv
  • project: Your project ID.
  • location: Region where you want to create the feature view, such asus-central1.
  • existing_feature_online_store_id: The name of the online store instance where you want to create the feature view.
  • feature_view_id: The name of the new feature view instance that you want to create.
  • bq_table_uri: URI of the BigQuery source table or view.
  • entity_id_columns: The names of the columns containing the entity IDs. You can specify either one column or multiple columns.
    • To specify only one entity ID column, specify the column name in the following format:
      "entity_id_column_name".
    • To specify multiple entity ID columns, specify the column names in the following format:
      ["entity_id_column_1_name", "entity_id_column_2_name", ...].

REST

To create aFeatureViewresource, send aPOST request by using thefeatureViews.createmethod.

Before using any of the request data, make the following replacements:

  • LOCATION_ID: Region where you want to create the feature view, such asus-central1.
  • PROJECT_ID: Your project ID.
  • FEATUREONLINESTORE_NAME: The name of the online store instance where you want to create the feature view.
  • FEATUREVIEW_NAME: The name of the new feature view that you want to create.
  • PROJECT_NAME: Your project name.
  • DATASET_NAME: Your BigQuery dataset name.
  • TABLE_NAME: The name of the table from your BigQuery dataset.
  • ENTITY_ID_COLUMNS: The names of the column(s) containing the entity IDs. You can specify either one column or multiple columns.
    • To specify only one entity ID column, specify the column name in the following format:
      "entity_id_column_name"
    • To specify multiple entity ID columns, specify the column names in the following format:
      ["entity_id_column_1_name", "entity_id_column_2_name", ...]
  • CRON: Cron schedule expression representing the frequency for syncing data to the feature view. For more information, seecron.

HTTP method and URL:

POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews?feature_view_id=FEATUREVIEW_NAME

Request JSON body:

{  "big_query_source": {    "uri": "bq://PROJECT_NAME.DATASET_NAME.TABLE_NAME",    "entity_id_columns": "ENTITY_ID_COLUMNS"  },  "sync_config": {    "cron": "CRON"  }}

To send your request, choose one of these options:

curl

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews?feature_view_id=FEATUREVIEW_NAME"

PowerShell

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews?feature_view_id=FEATUREVIEW_NAME" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME/operations/OPERATION_ID",  "metadata": {    "@type": "type.googleapis.com/google.cloud.aiplatform.v1.CreateFeatureViewOperationMetadata",    "genericMetadata": {      "createTime": "2023-09-15T02:11:29.458820Z",      "updateTime": "2023-09-15T02:11:29.458820Z"    }  }}

Create a feature view that uses the default service account and supports embeddings

Use the following samples to create a feature view with embedding support bydirectly associating a BigQuery data source and with the defaultservice account configuration.

Python

To learn how to install or update the Vertex AI SDK for Python, seeInstall the Vertex AI SDK for Python. For more information, see thePython API reference documentation.

fromgoogle.cloudimportaiplatformfromvertexai.resources.previewimportfeature_storefromtypingimportListdefcreate_feature_view_from_bq_source_with_embedding_management(project:str,location:str,existing_feature_online_store_id:str,feature_view_id:str,bq_table_uri:str,entity_id_columns:List[str],embedding_column:str,embedding_dimensions:int,):aiplatform.init(project=project,location=location)fos=feature_store.FeatureOnlineStore(existing_feature_online_store_id)bigquery_source=feature_store.utils.FeatureViewBigQuerySource(uri=bq_table_uri,entity_id_columns=entity_id_columns,)index_config=feature_store.utils.IndexConfig(embedding_column=embedding_column,dimensions=embedding_dimensions,algorithm_config=feature_store.utils.TreeAhConfig(),)fv=fos.create_feature_view(name=feature_view_id,source=bigquery_source,index_config=index_config,)returnfv
  • project: Your project ID.
  • location: Region where you want to create the feature view, such asus-central1.
  • existing_feature_online_store_id: The name of the online store instance where you want to create the feature view.
  • feature_view_id: The name of the new feature view instance that you want to create.
  • bq_table_uri: URI of the BigQuery source table or view.
  • entity_id_columns: The names of the columns containing the entity IDs. You can specify either one column or multiple columns.
    • To specify only one entity ID column, specify the column name in the following format:
      "entity_id_column_name".
    • To specify multiple entity ID columns, specify the column names in the following format:
      ["entity_id_column_1_name", "entity_id_column_2_name", ...].
  • embedding_column: The name of the column containing the source data to create the index for vector search. This is required only if you want to manage embeddings with the feature view.
  • embedding_dimensions: Optional. The size, expressed as number of dimensions, of an embedding in the embedding column.

REST

To create aFeatureViewresource, send aPOST request by using thefeatureViews.createmethod.

Before using any of the request data, make the following replacements:

  • LOCATION_ID: Region where you want to create the feature view, such asus-central1.
  • PROJECT_ID: Your project ID.
  • FEATUREONLINESTORE_NAME: The name of the online store instance where you want to create the feature view.
  • FEATUREVIEW_NAME: The name of the new feature view that you want to create.
  • PROJECT_NAME: Your project name.
  • DATASET_NAME: Your BigQuery dataset name.
  • TABLE_NAME: The name of the table from your BigQuery dataset.
  • ENTITY_ID_COLUMNS: The names of the column(s) containing the entity IDs. You can specify either one column or multiple columns.
    • To specify only one entity ID column, specify the column name in the following format:
      "entity_id_column_name"
    • To specify multiple entity ID columns, specify the column names in the following format:
      ["entity_id_column_1_name", "entity_id_column_2_name", ...]
  • CRON: Cron schedule expression representing the frequency for syncing data to the feature view. For more information, seecron.
  • EMBEDDING_COLUMN: The name of the column containing the source data to create the index for vector search. This is required only if you want to manage embeddings with the feature view.
  • FILTER_COLUMN_1 andFILTER_COLUMN_2: Optional: The names of the columns used to filter the vector search results.
  • CROWDING_COLUMN: Optional: The name of the column containing the crowding attributes.
  • EMBEDDING_DIMENSION: Optional: The size, expressed as number of dimensions, of an embedding in the embedding column.

HTTP method and URL:

POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews?feature_view_id=FEATUREVIEW_NAME

Request JSON body:

{  "big_query_source": {    "uri": "bq://PROJECT_NAME.DATASET_NAME.TABLE_NAME",    "entity_id_columns": "ENTITY_ID_COLUMNS"  },  "sync_config": {    "cron": "CRON"  },  "index_config": {    "embedding_column": "EMBEDDING_COLUMN",    "filter_columns": ["FILTER_COLUMN_1", "FILTER_COLUMN_2"],    "crowding_column": "CROWDING_COLUMN",    "embedding_dimension":EMBEDDING_DIMENSION    "tree_ah_config": {}  }}

To send your request, choose one of these options:

curl

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews?feature_view_id=FEATUREVIEW_NAME"

PowerShell

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews?feature_view_id=FEATUREVIEW_NAME" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME/operations/OPERATION_ID",  "metadata": {    "@type": "type.googleapis.com/google.cloud.aiplatform.v1.CreateFeatureViewOperationMetadata",    "genericMetadata": {      "createTime": "2023-09-15T02:11:29.458820Z",      "updateTime": "2023-09-15T02:11:29.458820Z"    }  }}

Create a feature view with a dedicated service account and without embedding management

Use the following sample to create a feature view without embedding support bydirectly associating a BigQuery data source and specifying a serviceaccount configuration.

REST

To create aFeatureViewresource with embeddings support, send aPOST request by using thefeatureViews.createmethod and specifying theFeatureView.index_configparameter. Note that you can use embedding management only if the online store is configured for Optimized online serving.

Before using any of the request data, make the following replacements:

  • LOCATION_ID: Region where you want to create the feature view, such asus-central1.
  • PROJECT_ID: Your project ID.
  • FEATUREONLINESTORE_NAME: The name of the online store instance where you want to create the feature view.
  • FEATUREVIEW_NAME: The name of the new feature view that you want to create.
  • PROJECT_NAME: Your project name.
  • DATASET_NAME: Your BigQuery dataset name.
  • TABLE_NAME: The name of the table from your BigQuery dataset.
  • ENTITY_ID_COLUMNS: The names of the column(s) containing the entity IDs. You can specify either one column or multiple columns.
    • To specify only one entity ID column, specify the column name in the following format:
      "entity_id_column_name"
    • To specify multiple entity ID columns, specify the column names in the following format:
      ["entity_id_column_1_name", "entity_id_column_2_name", ...]
  • CRON: Cron schedule expression representing the frequency for syncing data to the feature view. For more information, seecron.
  • SERVICE_AGENT_TYPE: Service account configuration for the feature view. To use a dedicated service account for the feature view, enterSERVICE_AGENT_TYPE_FEATURE_VIEW.

HTTP method and URL:

POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews?feature_view_id=FEATUREVIEW_NAME

Request JSON body:

{  "big_query_source": {    "uri": "bq://PROJECT_NAME.DATASET_NAME.TABLE_NAME",    "entity_id_columns": "ENTITY_ID_COLUMNS"  },  "sync_config": {    "cron": "CRON"  },  "service_agent_type": "SERVICE_AGENT_TYPE",}

To send your request, choose one of these options:

curl

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews?feature_view_id=FEATUREVIEW_NAME"

PowerShell

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews?feature_view_id=FEATUREVIEW_NAME" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME/operations/OPERATION_ID",  "metadata": {    "@type": "type.googleapis.com/google.cloud.aiplatform.v1.CreateFeatureViewOperationMetadata",    "genericMetadata": {      "createTime": "2023-09-15T02:11:29.458820Z",      "updateTime": "2023-09-15T02:11:29.458820Z"    }  }}

Create a feature view with embedding management and a dedicated service account

Use the following sample to create a feature view with embedding support bydirectly associating a BigQuery data source and specifying a serviceaccount configuration.

REST

To create aFeatureViewresource with embeddings support, send aPOST request by using thefeatureViews.createmethod and specifying theFeatureView.index_configparameter. Note that you can use embedding management only if the online store is configured for Optimized online serving.

Before using any of the request data, make the following replacements:

  • LOCATION_ID: Region where you want to create the feature view, such asus-central1.
  • PROJECT_ID: Your project ID.
  • FEATUREONLINESTORE_NAME: The name of the online store instance where you want to create the feature view.
  • FEATUREVIEW_NAME: The name of the new feature view that you want to create.
  • PROJECT_NAME: Your project name.
  • DATASET_NAME: Your BigQuery dataset name.
  • TABLE_NAME: The name of the table from your BigQuery dataset.
  • ENTITY_ID_COLUMNS: The names of the column(s) containing the entity IDs. You can specify either one column or multiple columns.
    • To specify only one entity ID column, specify the column name in the following format:
      "entity_id_column_name"
    • To specify multiple entity ID columns, specify the column names in the following format:
      ["entity_id_column_1_name", "entity_id_column_2_name", ...]
  • CRON: Cron schedule expression representing the frequency for syncing data to the feature view. For more information, seecron.
  • SERVICE_AGENT_TYPE: Service account configuration for the feature view. To use a dedicated service account for the feature view, enterSERVICE_AGENT_TYPE_FEATURE_VIEW.
  • EMBEDDING_COLUMN: The name of the column containing the source data to create the index for vector search. This is required only if you want to manage embeddings with the feature view.
  • FILTER_COLUMN_1 andFILTER_COLUMN_2: Optional: The names of the columns used to filter the vector search results.
  • CROWDING_COLUMN: Optional: The name of the column containing the crowding attributes.
  • EMBEDDING_DIMENSION: Optional: The size, expressed as number of dimensions, of an embedding in the embedding column.

HTTP method and URL:

POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews?feature_view_id=FEATUREVIEW_NAME

Request JSON body:

{  "big_query_source": {    "uri": "bq://PROJECT_NAME.DATASET_NAME.TABLE_NAME",    "entity_id_columns": "ENTITY_ID_COLUMNS"  },  "sync_config": {    "cron": "CRON"  },  "service_agent_type": "SERVICE_AGENT_TYPE",  "index_config": {    "embedding_column": "EMBEDDING_COLUMN",    "filter_columns": ["FILTER_COLUMN_1", "FILTER_COLUMN_2"],    "crowding_column": "CROWDING_COLUMN",    "embedding_dimension":EMBEDDING_DIMENSION    "tree_ah_config": {}  }}

To send your request, choose one of these options:

curl

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews?feature_view_id=FEATUREVIEW_NAME"

PowerShell

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews?feature_view_id=FEATUREVIEW_NAME" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME/operations/OPERATION_ID",  "metadata": {    "@type": "type.googleapis.com/google.cloud.aiplatform.v1.CreateFeatureViewOperationMetadata",    "genericMetadata": {      "createTime": "2023-09-15T02:11:29.458820Z",      "updateTime": "2023-09-15T02:11:29.458820Z"    }  }}

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.