OpenAI compatibility for labels

Hi there, I what to add custom metadata for cost accounting via OpenAI compatibility API. I would like to know if the metadata field defined in the OpenAI compatibility API has the same effect as the labels field as defined generateContent API .

Hey @lvqier ,

Welcome to Forum!

Great question! The metadata field in the OpenAI-compatible API doesn’t behave exactly like the labels field in generateContent . If you’re using it for cost tracking or analytics, it’s best to confirm with the Gemini API docs or support to ensure it’s properly logged and interpreted.

Thanks!

Hi @Deepakishore ,
Thanks for reply!
I can confirm that the Gemini API docs do not mention anything about this. Are there any approach to find out how to do cost tracking in the OpenAI-compatible API ?

Hey @lvqier — thanks for confirming! Since the docs don’t cover this clearly, one workaround is to log your requests manually with custom metadata on your backend. You can tag each request with a user ID or project label and track token usage separately. It’s not built-in, but it gives you control over cost tracking until official support improves.

Hello,

Welcome to the Forum!

Could you please share your code where you are passing the metadata argument in OpenAI compatibility?