Skip to content

[Feature] Track token usage metrics for embedding models #858

Description

@joeyutong

Search before asking

  • I searched in the issues and found nothing similar.

Description

Embedding model calls currently do not consistently report token usage metrics.

Chat models already have a token accounting path: provider usage is attached to the chat response and later recorded as model-level token metrics. Embedding models return only vectors, so provider usage returned by OpenAI-compatible or DashScope-style embedding APIs can be dropped before it reaches the metrics layer.

Affected paths include:

  • Direct Java or Python embedding model calls.
  • Vector store and RAG paths that auto-generate embeddings during add, update, or query.
  • Cross-language resource paths where the wrapper may receive an action metric group but the provider-side embedding resource performs the actual request.

This makes it harder to validate and compare embedding model cost/usage, especially when a job mixes chat, embedding, and vector store operations. Embedding metrics do not need completionTokens, but should expose input-side token usage, for example promptTokens and totalTokens, under the same model/provider metric dimensions used by chat metrics where possible.

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature[Issue Type] New features or improvements to existing features.priority/majorDefault priority of the PR or issue.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions