[[["易于理解","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-18。"],[[["\u003cp\u003eEvery Google Cloud API request requires a quota project, which is the project used for quota enforcement and is sometimes also referred to as the billing project.\u003c/p\u003e\n"],["\u003cp\u003eFor resource-based APIs, the quota project is always the project that contains the resource being accessed, and this cannot be changed.\u003c/p\u003e\n"],["\u003cp\u003eFor client-based APIs, the quota project is determined by a hierarchy of options, such as the environment variable, API key association, gcloud CLI shared project, or the project associated with the service account or workforce identity federation user.\u003c/p\u003e\n"],["\u003cp\u003eIf no quota project is identified for a client-based API request, the request will fail, highlighting the importance of setting the quota project correctly.\u003c/p\u003e\n"],["\u003cp\u003eThe gcloud CLI may fall back on the "gcloud CLI shared project" if a quota project is not set, but this can lead to quota depletion and request failures.\u003c/p\u003e\n"]]],[],null,["# Quota project overview\n\nThis document describes the *quota project* and how the quota project is\ndetermined. Make sure that your quota project is set correctly to help avoid\nerrors and failed requests to the Cloud APIs.\n\nYou must specify a quota project because every request to a Google Cloud API is\ncounted against a quota and because quotas are enforced by project. For more\ninformation, see [How to set the quota\nproject](/docs/quotas/set-quota-project)\n.\n\nNote for gcloud CLI users: the *quota project* is sometimes referred\nto as the *billing project* . This is because the [`billing_project`\nflag](/sdk/gcloud/reference#--billing-project)\ntakes precedence over the [`billing/quota_project`\nproperty](/sdk/gcloud/reference/config/set#quota_project) in your\ngcloud CLI configuration.\n\nHow the quota project is determined\n-----------------------------------\n\nHow the quota project is determined depends on the type of API method that you\nuse: *resource-based API* or *client-based API*. In rare cases, a service might\nhave both types of API methods.\n\n### Resource-based APIs\n\nFor resource-based Cloud APIs, the project that provides quota for\nan API call is also the project that contains the resource that is being\naccessed. For example, when you create a Compute Engine instance, you must\nspecify the project for that new instance. The project then contains the newly\ncreated instance. Later, if you perform operations on the Compute Engine\ninstance, the project that contains the instance provides the quota for the\nrequest. This applies regardless of whether you use the Google Cloud CLI, REST\nAPI, or client libraries.\n\nYou cannot change the quota project used by a request to a resource-based API.\nThe request always uses the project that contains the resource that the request\nis operating on.\n\n### Client-based APIs\n\nIf an API is not a resource-based API, it's a client-based API. For example, the\nCloud Translation API is a commonly used client-based API.\n\nRequests can fail if you make a request to a client-based API and the quota\nproject cannot be identified. The quota project can be set in multiple ways and\nis verified by checking the following options. They appear in the order of\nprecedence:\n\n- **Specified in request** : The quota project that was specified in the\n [request](/docs/quotas/set-quota-project#set-project-programmatically).\n (When using client libraries, you can also use [environment\n variables](/docs/quotas/set-quota-project#set-project-variable)\n in your requests.)\n\n- **API key**: If you use an API key to provide credentials for a\n request, the project associated with the API key is used as the quota\n project.\n\n- **Google Cloud CLI credentials**: If you use the gcloud CLI\n to get your access token, and you've authenticated to the\n gcloud CLI with your user credentials, the gcloud CLI\n shared project is sometimes used as the quota project. However, not all\n client-based APIs fall back on the shared project.\n\n- **Service account**: If the principal for the API call is a service\n account, including by impersonation, the project associated with the service\n account is used as the quota project.\n\n- **Workforce identity federation** : If the principal for the API is a\n workforce identity federation user, the\n [workforce pools user project](/iam/docs/workforce-identity-federation#workforce-pools-user-project)\n is used as the quota project.\n\nIf none of the previous checks yield a quota project, the request fails.\n\n#### About the gcloud CLI shared project for client-based APIs\n\nIf you use the gcloud CLI to make a request to a client-based API\nwithout setting the quota project, the request might fall back on the\n*gcloud CLI shared project*, or the request might fail. The\ngcloud CLI shared project is used by all gcloud CLI\nrequests in all projects, so if many other gcloud CLI requests are\nalso using this project as their quota project, the quota for the shared project\nmight temporarily be depleted. If this happens, your request fails with an\nout-of-quota error message.\n\n#### Identify the current quota project for client-based APIs\n\nThe method for identifying the quota project depends on how your project is\nconfigured:\n\n- If an API method is configured to use a resource-based API, the client\n project uses the resource project as the quota project.\n\n- If a user project override is in place, use the\n [`gcloud [command] --log-http` command](/sdk/gcloud/reference#--log-http)\n to print a log and check the quota project that appears in the\n `x-goog-user-project` field.\n\n- If an API key was used for authentication, use the\n [`gcloud [command] --log-http` command](/sdk/gcloud/reference#--log-http)\n to print a log and check the quota project that appears in the\n `x-goog-api-key` field.\n\nFor other configurations, the quota project doesn't appear in HTTP headers.\n\nDetermine if an API is resource-based or client-based\n-----------------------------------------------------\n\nIt can be difficult to determine which type of API you're using. However,\nactivation and quotas are enforced in the same way. For example, if a service\naccount from project A calls a read method in project B, and neither project has\nthe API enabled, the `API not enabled` error message indicates which project is\nchecked for activation. The project checked for activation is the same project\nchecked for\n[rate quota](/docs/quotas/overview#types_of_quota).\n\nWhat's next\n-----------\n\n- Learn how to set the [quota\n project](/docs/quotas/set-quota-project)\n\n- Learn more about [Application Default\n Credentials](/docs/authentication/application-default-credentials)\n\n- Get more information about\n [authentication](/docs/authentication)\n\n- Understand [quotas](/docs/quotas/overview)\n\n- For gcloud CLI users:\n\n - For more information about gcloud CLI configurations, see the [`gcloud config`](/sdk/gcloud/reference/config) reference documentation\n - For more information about the `--billing_project` flag, see the [Google Cloud SDK reference](/sdk/gcloud/reference#--billing-project)"]]