[GCP Billing & Vertex AI] Solving Gemini Cost Allocation in a Single Project: Vertex AI Dynamic Billing Labels in Action A developer solved Gemini cost allocation within a single GCP project by switching from API Keys to Vertex AI calls and using dynamic request labels. By adding custom labels like client_id to each Vertex AI generateContent request, the team enabled per-client billing breakdown in GCP reports. The refactoring involved modifying 19 call points across 11 files in a LINE Bot project. When developing enterprise-level LLM services or operating multi-tenant platforms, the question most frequently asked by finance and operations teams is: "We have many different business lines and LINE Bots connected within the same GCP project. Every day, the Gemini Key costs all appear under the Gemini API category. Is there a way for us to split the costs based on different Gemini Keys or different users?" Direct answer to your question: In Google Cloud Billing reports, it is not possible to directly display costs "based on different API Key names." The smallest attribution dimensions for Google Cloud billing reports are "Project," "Service," and "SKU Product Line Item ." The system does not treat individual API Key strings as independent billing items. For the billing system, whether you create 10 or 100 API Keys within the same project, they will all be lumped together as a single Gemini API total. If architectural constraints force you to stay within the same project, the most recommended approach is: switch to Vertex AI calls and use "Request Labels." If you are currently using a Google AI Studio API Key, it cannot pass billing labels within a single project. However, if you change your code to call the Vertex AI Gemini API still within the same project , Vertex AI supports dynamically including custom labels with each request. When sending each request e.g., calling generateContent , include specific metadata in the API Request: { "contents": { ... }, "labels": { "client id": "info helper", "api key group": "marketing team" } } These custom labels are passed directly to the GCP billing system. Later, when you go to the GCP Billing report and select your set label key e.g., client id in "Group by," you can clearly see the costs for different labels representing different services, clients, or users within the same project To fulfill this requirement, we audited the current API call architecture of the LINE Bot project and performed the following refactoring. Through scanning, we found that the vast majority of calls in the project use Vertex AI 14 out of 17 clients use vertexai=True , with only a few exceptions: main.py , Batch service in batch service.py , and TTS speech synthesis in tts tool.py . IMPORTANT The labels parameter is only supported by Vertex AI. If this parameter is included under an API Key vertexai=False , it will cause the SDK to throw an error. Therefore, we only modified the 11 files that use Vertex AI. For the google-genai Python SDK, we have two main modification scenarios: GenerateContentConfig If the original call already includes a Config, we just need to pass an additional labels={"client id": "info helper"} into the config: Before e.g., loader/gh tools.py response = client.models.generate content model="gemini-2.5-flash", contents=prompt, config=types.GenerateContentConfig temperature=0, max output tokens=2048, After response = client.models.generate content model="gemini-2.5-flash", contents=prompt, config=types.GenerateContentConfig temperature=0, max output tokens=2048, labels={"client id": "info helper"}, Include billing label If the original call is very simple e.g., searchtool.py or youtube gcp.py , we need to proactively include a GenerateContentConfig containing labels: Before e.g., loader/searchtool.py response = client.models.generate content model="gemini-3.1-flash-lite-preview", contents=prompt, After response = client.models.generate content model="gemini-3.1-flash-lite-preview", contents=prompt, config=types.GenerateContentConfig labels={"client id": "info helper"}, Add config to include label , We performed precise modifications on a total of 19 call points across the following 11 files, and used Python's AST module ast.parse and Flake8 for syntax and formatting checks before submission: create chat config to add labels to both general Q&A and Grounding conversations.When refactoring calls without Config for youtube gcp.py and youtube tool.py , since these two files originally only used named imports for specific types: python from google.genai.types import HttpOptions, Part When we write types.GenerateContentConfig ... in the code, the system throws a NameError: name 'types' is not defined error. Solution: We need to correct the import statement and directly import GenerateContentConfig : python Before from google.genai.types import HttpOptions, Part After from google.genai.types import HttpOptions, Part, GenerateContentConfig And use it directly in the call without the types. prefix: config=GenerateContentConfig labels={"client id": "info helper"} This modification successfully injected the client id=info helper label into all Vertex AI API calls within the LINE Bot project. labels , GCP billing data usually has a 24 to 48-hour delay before taking effect. client id . info helper as a separate billing row, perfectly solving the problem of separating project costs for reimbursement and statistics