How to log the usage token? #2434
Replies: 1 comment
-
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: The To log the Here are the steps to create a custom event converter:
Here is an example of a custom event converter that extracts the from google.adk.a2a.converters.event_converter import EventConverter
class MyEventConverter(EventConverter):
def convert(self, event: dict) -> dict:
# Your custom logic to extract usage_metadata
if "usage_metadata" in event:
event["usage_metadata"] = event["usage_metadata"]
return event After creating your custom converter, you need to configure your ADK pipeline to use it. You can do this by updating your pipeline configuration file (e.g., For more information on creating and using custom plugins, please refer to the ADK documentation on plugins. [1] We are closing this discussion for now. Please feel free to reopen it if you have any more questions. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I can see the usage token is returned by Gemini API under "usage_metadata". However it is not logged by the DatabaseSessionService and it seems not passed to the yielded events. How to access and log this for each interactions? Currently using v1.8.0 Thanks.
Beta Was this translation helpful? Give feedback.
All reactions