POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/features?feature_id=FEATURE_NAME
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-19。"],[],[],null,["# Create a feature\n\nYou can create a feature after you [create a feature group and associate a\nBigQuery table or BigQuery view with it](/vertex-ai/docs/featurestore/latest/create-featuregroup).\nYou can create multiple features for a feature group and associate each feature\nwith a specific column in the BigQuery data source. For information\nabout how to use BigQuery, refer to the\n[BigQuery documentation](/bigquery/docs).\n\nFor example, if the feature group `featuregroup1` is associated with the\nBigQuery table `datasource_1` containing feature values in columns\n`fval1` and `fval2`, then you can create feature `feature_1` under\n`featuregroup1` and associate it with the feature values in column `fval1`.\nSimilarly, you can create another feature named `feature_2` and associate it\nwith the feature values in column `fval2`.\n\nA feature group must have a feature data source associated with it before you\ncan create features. If the feature group doesn't have an associated data source,\nyou must associate a BigQuery data source by\n[updating the feature group](/vertex-ai/docs/featurestore/latest/update-featuregroup), before you\ncan create features within it.\n\nTo understand whether it's mandatory, optional, or inadvisable for you to register\nyour feature data using feature groups and features, see the following:\n\n- [Why use feature groups and features?](/vertex-ai/docs/featurestore/latest/create-featuregroup#why_use_feature_groups_and_features)\n\n- [When not to use feature groups and features.](/vertex-ai/docs/featurestore/latest/create-featuregroup#when_not_to_use_feature_groups_and_features)\n\nBefore you begin\n----------------\n\n\nto\nVertex AI, unless you've done so already.\n\n\nSelect the tab for how you plan to use the samples on this page: \n\n### Console\n\n\nWhen you use the Google Cloud console to access Google Cloud services and\nAPIs, you don't need to set up authentication.\n\n### Python\n\n\nTo use the Python samples on this page in a local\ndevelopment environment, install and initialize the gcloud CLI, and\nthen set up Application Default Credentials with your user credentials.\n\n1. [Install](/sdk/docs/install) the Google Cloud CLI.\n2. If you're using an external identity provider (IdP), you must first [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n3. If you're using a local shell, then create local authentication credentials for your user account: \n\n```bash\ngcloud auth application-default login\n```\n4. You don't need to do this if you're using Cloud Shell.\n5. 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](/iam/docs/workforce-log-in-gcloud).\n\n\nFor more information, see\n[Set up authentication for a local development environment](/vertex-ai/docs/authentication#local-development).\n\n### REST\n\n\nTo use the REST API samples on this page in a local development environment, you use the\ncredentials you provide to the gcloud CLI.\n\n1. [Install](/sdk/docs/install) the Google Cloud CLI.\n2. If you're using an external identity provider (IdP), you must first [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n\nFor more information, see\n[Authenticate for using REST](/docs/authentication/rest)\nin the Google Cloud authentication documentation.\n\nCreate a feature within a feature group\n---------------------------------------\n\nUse the following samples to create a feature within a feature group and\nassociate a column containing feature values from the BigQuery\ndata source registered for the feature group. \n\n### Console\n\nUse the following instructions to add features to an existing feature group using the Google Cloud console.\n\n1. In the Vertex AI section of the Google Cloud console, go\n to the **Feature Store** page.\n\n [Go to the Feature Store page](https://console.cloud.google.com/vertex-ai/feature-store)\n2. In the **Feature groups** section, click\n more_vert in the\n row corresponding to the feature group where you want to add a feature,\n and then click **Add features**.\n\n3. For each feature, enter a **Feature name** and click the corresponding BigQuery source column name in the list. To add more features, click **Add another feature**.\n\n4. Click **Create**.\n\n### Python\n\nTo learn how to install or update the Vertex AI SDK for Python, see [Install the Vertex AI SDK for Python](/vertex-ai/docs/start/use-vertex-ai-python-sdk).\n\nFor more information, see the\n[Python API reference documentation](/python/docs/reference/aiplatform/latest).\n\n\n from google.cloud import aiplatform\n from vertexai.resources.preview import feature_store\n\n\n def create_feature_sample(\n project: str,\n location: str,\n existing_feature_group_id: str,\n feature_id: str,\n version_column_name: str,\n ):\n aiplatform.init(project=project, location=location)\n feature_group = feature_store.FeatureGroup(existing_feature_group_id)\n feature = feature_group.create_feature(\n name=feature_id, version_column_name=version_column_name\n )\n return feature\n\n- `project`: Your project ID.\n- `location`: Region where the feature group is located, such as `us-central1`.\n- `existing_feature_group_id`: The name of the existing feature group where you want to create the feature.\n- `version_column_name`: Optional: The column from the BigQuery table or view that you want to associate with the feature. If you don't specify this parameter, it's set to \u003cvar translate=\"no\"\u003eFEATURE_NAME\u003c/var\u003e, by default.\n- `feature_id`: The name of the new feature you want to create\n\n### REST\n\n\nTo create a [`Feature`](/vertex-ai/docs/reference/rest/v1/projects.locations.featureGroups.features#resource:-feature) resource, send a `POST` request by using the\n[features.create](/vertex-ai/docs/reference/rest/v1/projects.locations.featureGroups.features/create)\nmethod.\n\n\nBefore using any of the request data,\nmake the following replacements:\n\n- \u003cvar translate=\"no\"\u003eLOCATION_ID\u003c/var\u003e: Region where the feature group is located, such as `us-central1`.\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: Your project ID.\n- \u003cvar translate=\"no\"\u003eFEATUREGROUP_NAME\u003c/var\u003e: The name of the feature group where you want to create the feature.\n- \u003cvar translate=\"no\"\u003eFEATURE_NAME\u003c/var\u003e: The name of the new feature you want to create.\n- \u003cvar translate=\"no\"\u003eVERSION_COLUMN_NAME\u003c/var\u003e: Optional: The column from the BigQuery table or view that you want to associate with the feature. If you don't specify this parameter, it's set to \u003cvar translate=\"no\"\u003eFEATURE_NAME\u003c/var\u003e, by default.\n\n\nHTTP method and URL:\n\n```\nPOST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/features?feature_id=FEATURE_NAME\n```\n\n\nRequest JSON body:\n\n```\n{\n \"version_column_name\": \"VERSION_COLUMN_NAME\"\n}\n```\n\nTo send your request, choose one of these options: \n\n#### curl\n\n| **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) , or by using [Cloud Shell](/shell/docs), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nSave the request body in a file named `request.json`,\nand execute the following command:\n\n```\ncurl -X POST \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json; charset=utf-8\" \\\n -d @request.json \\\n \"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/features?feature_id=FEATURE_NAME\"\n```\n\n#### PowerShell\n\n| **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nSave the request body in a file named `request.json`,\nand execute the following command:\n\n```\n$cred = gcloud auth print-access-token\n$headers = @{ \"Authorization\" = \"Bearer $cred\" }\n\nInvoke-WebRequest `\n -Method POST `\n -Headers $headers `\n -ContentType: \"application/json; charset=utf-8\" `\n -InFile request.json `\n -Uri \"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/features?feature_id=FEATURE_NAME\" | Select-Object -Expand Content\n```\n\nYou should receive a JSON response similar to the following:\n\n```\n{\n \"name\": \"projects/PROJECT_NUMBER/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/features/FEATURE_NAME/operations/OPERATION_ID\",\n \"metadata\": {\n \"@type\": \"type.googleapis.com/google.cloud.aiplatform.v1.UpdateFeatureOperationMetadata\",\n \"genericMetadata\": {\n \"createTime\": \"2023-09-18T02:36:22.870679Z\",\n \"updateTime\": \"2023-09-18T02:36:22.870679Z\"\n }\n }\n}\n```\n\n\u003cbr /\u003e\n\nWhat's next\n-----------\n\n- Learn how to [list all features in a feature group](/vertex-ai/docs/featurestore/latest/list-features).\n\n- Learn how to [update a feature](/vertex-ai/docs/featurestore/latest/update-feature).\n\n- Learn how to [delete a feature](/vertex-ai/docs/featurestore/latest/delete-feature).\n\n- Learn how to [update a feature group](/vertex-ai/docs/featurestore/latest/update-featuregroup).\n\n- Set up [feature monitoring](/vertex-ai/docs/featurestore/latest/monitor-features) for features in a feature group.\n\n- [Online serving types](/vertex-ai/docs/featurestore/latest/online-serving-types) in Vertex AI Feature Store."]]