[[["易于理解","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-09-04。"],[],[],null,["# Manage BigQuery costs for Conversational Analytics API agents\n\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis page describes how to monitor and manage BigQuery costs for your Conversational Analytics API agents, which incur costs by running queries against your BigQuery data. You can use the following methods to control spending and prevent unexpected expenses:\n\n- [Set quotas for projects and users](#set-quotas) to apply broad spending limits for an entire project or for individual users.\n- [Limit costs for individual queries](#limit-individual-queries) by setting a `big_query_max_billed_bytes` value in the agent's configuration.\n\nBefore you begin\n----------------\n\nBefore you implement the cost controls that are described on this page, you must meet the following requirements:\n\n- You must have a Google Cloud project with billing enabled.\n- You must have the necessary Identity and Access Management (IAM) permissions to manage quotas and billing for your Google Cloud project.\n\nSet quotas for projects and users\n---------------------------------\n\nYou can set spending limits for a Google Cloud project or for individual users by applying standard [BigQuery quotas](/bigquery/quotas). These limits help you control overall costs and prevent individual users from overspending.\n\nFor agents that might incur high costs, such as an agent that is built on a very large or unpartitioned table, the recommended practice is to first isolate the agent in its own [dedicated project](#set-up-a-dedicated-project-for-your-agent). You can then apply a [project-level quota](#set-a-quota-for-the-project) to cap the project's maximum daily cost, a [user-level quota](#set-a-quota-for-users) to ensure fair use among users, or both project-level and user-level quotas.\n\n### Set up a dedicated project for your agent\n\nTo set up a dedicated project for your Conversational Analytics API agent or agents, follow these steps:\n\n1. In the Google Cloud console, [create a new Google Cloud project](/resource-manager/docs/creating-managing-projects#creating_a_project). This project will be dedicated to your agent or agents.\n2. Make sure that billing is enabled for the new project.\n3. Confirm that the agent is configured to use this new project for billing. When you configure the agent, you'll need to specify the project ID of this new project.\n\n### Set a quota for the project\n\nAfter you have set up a dedicated Google Cloud project, you can apply a quota to control costs for the entire project. To set a project-level quota, follow these steps:\n\n1. In the Google Cloud project for your agent, navigate to **IAM \\& Admin \\\u003e Quotas**.\n\n [Go to Quotas](https://console.cloud.google.com/iam-admin/quotas)\n2. Filter for the BigQuery API service, and select the **Query usage per day** quota.\n\n3. Edit the quota to your chosen daily limit (for example, 10 TiB). This limit creates a hard stop that prevents the project from exceeding the specified daily cost.\n\n### Set a quota for users\n\nTo prevent any individual user from generating a large bill, you can set a per-user quota by following these steps:\n\n1. In the Google Cloud project for your agent, navigate to **IAM \\& Admin \\\u003e Quotas**.\n\n [Go to Quotas](https://console.cloud.google.com/iam-admin/quotas)\n2. Filter for the **BigQuery API** service and select the **Query usage per day per user** quota.\n\n3. Edit the quota to your chosen daily limit (for example, 1 TiB per user per day). This limit ensures that no single user can consume an excessive amount of resources.\n\nLimit costs for individual queries\n----------------------------------\n\nTo prevent any individual user query from generating a large, unexpected bill, you can set a per-query cost limit by configuring the `big_query_max_billed_bytes` parameter on an agent.\n\nBefore the agent runs any query, the agent performs a trial run to estimate the cost of the query. If the estimated bytes to be scanned exceed the `big_query_max_billed_bytes` value, then the agent blocks the query and sends an error message to the user.\n\nYou can set the `big_query_max_billed_bytes` parameter within the `published_context` field when you create or configure an agent [with HTTP](/gemini/docs/conversational-analytics-api/build-agent-http#create_a_data_agent) or [with the Python SDK](/gemini/docs/conversational-analytics-api/build-agent-sdk#create_a_data_agent). The following example, shown in `textproto` format, illustrates the structure of a request that configures a 100 MB limit for an agent that answers questions about San Francisco street trees: \n\n parent: \"projects/sample-project-name/locations/global\"\n data_agent_id: \"sample-agent-id\"\n data_agent {\n name: \"projects/sample-project-name/locations/global/dataAgents/sample-agent-id\"\n data_analytics_agent {\n published_context {\n system_instruction: \"This agent provides information about street trees in San Francisco, including their species, location, and planting date.\"\n options {\n datasource {\n big_query_max_billed_bytes {\n value: 104857600 #100MB\n }\n }\n }\n datasource_references {\n bq {\n table_references {\n project_id: \"bigquery-public-data\"\n dataset_id: \"san_francisco\"\n table_id: \"street_trees\"\n }\n }\n }\n }\n }\n }\n\nIn this example, the `big_query_max_billed_bytes` parameter is set to `104857600` bytes (100 MB). This value establishes a limit for any queries that are run by the `sample-agent-id` agent on the `bigquery-public-data.san_francisco.street_trees` BigQuery table.\n\nFor interactive examples of how to create and configure agents, see the [Colaboratory notebooks](/gemini/docs/conversational-analytics-api/overview#interactive-colab-notebooks). For detailed information about API fields, consult the [API reference](/gemini/docs/conversational-analytics-api/reference/rest).\n\nLimitations\n-----------\n\nKeep the following limitations in mind when you're managing costs for your Conversational Analytics API agents:\n\n- These cost management tools apply only to projects that use [on-demand billing](/bigquery/pricing#on_demand_pricing) and not to projects that use [slot reservations](/bigquery/pricing#reservations_pricing).\n- Setting quotas for individual agents isn't supported. As described in [Set quotas for projects and users](#set-quotas), the recommended practice is to isolate the agent in its own project, and then apply project-level or per-user quotas to that project.\n- Tracking costs for individual agents by using [BigQuery labels](/bigquery/docs/labels-intro) isn't supported."]]