You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 33be4ef
Browse filesBrowse the repository at this point in the historyBrowse files
fix(genkit): bare model name and provider on model spans so Future AGI prices them
gen_ai.request.model carried the registered action name
("googleai/gemini-3.5-flash"). fi-collector prices a span by an exact
model-name lookup in its litellm table, which lists "gemini-3.5-flash",
so every Genkit model span showed cost 0 and no provider.
Model spans now get the vendor model id without the plugin namespace on
gen_ai.request.model and gen_ai.response.model, and gen_ai.provider.name
from the namespace for the model plugins whose namespaces were read from
their published packages (googleai -> google, vertexai -> vertexai,
openai, deepseek, xai, anthropic, ollama, mistral -> mistralai, groq,
aws-bedrock -> aws, azure-openai -> azure). Other namespaces leave the
provider unset. The full registered name stays on genkit:name.
Live check with gemini-3.5-flash: model gemini-3.5-flash, provider
google, cost 0.000234 / 0.000357 / 0.000147 in ClickHouse and the UI
(was 0). README: replace the retired gemini-2.5-flash example, document
the provider map and how cost is computed.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copy file name to clipboardExpand all lines: typescript/packages/traceai_genkit/README.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,7 +96,8 @@ Cost: the Future AGI export adds no Google Cloud cost. The Firebase / Google Clo
96
96
| Future AGI key | Source | Where |
97
97
|---|---|---|
98
98
|`fi.span.kind`, `gen_ai.span.kind`| table above | every Genkit span |
99
-
|`gen_ai.request.model`|`genkit:name` of the model action span (the registered name, e.g. `googleai/gemini-2.5-flash`; not parsed) | model spans |
99
+
|`gen_ai.request.model`, `gen_ai.response.model`|`genkit:name` of the model action span without its plugin namespace: `googleai/gemini-3.5-flash` becomes `gemini-3.5-flash`, the name Future AGI's price table uses. The full registered name stays on `genkit:name`. Genkit reports no resolved model version, so both keys hold the requested model | model spans |
100
+
|`gen_ai.provider.name`| the plugin namespace: `googleai` → `google`, `vertexai` → `vertexai`, `openai` → `openai`, `anthropic` → `anthropic`, `deepseek` → `deepseek`, `xai` → `xai`, `ollama` → `ollama`, `mistral` → `mistralai`, `groq` → `groq`, `aws-bedrock` → `aws`, `azure-openai` → `azure`. Any other namespace: not set | model spans |
100
101
|`gen_ai.usage.input_tokens` / `output_tokens` / `total_tokens`|`usage.inputTokens` / `outputTokens` / `totalTokens` in the model span's `genkit:output`| model spans only |
101
102
|`gen_ai.usage.output_tokens.reasoning` / `gen_ai.usage.cache_read_tokens`|`usage.thoughtsTokens` / `cachedContentTokens`, when the model plugin reports them (the Google AI / Vertex AI plugin does; Gemini's `outputTokens` excludes thinking tokens, which are in `totalTokens`) | model spans only |
102
103
|`gen_ai.response.finish_reasons`|`finishReason` in the model span's `genkit:output`| model spans |
@@ -106,7 +107,7 @@ Cost: the Future AGI export adds no Google Cloud cost. The Firebase / Google Clo
106
107
|`input.value` / `output.value` (+ `application/json` mime types) |`genkit:input` / `genkit:output`| only with `captureContent: true`|
107
108
|`genkit:*`| passed through, except the content keys below | every Genkit span |
108
109
109
-
Unavailable at 1.42.0, and not set: provider, cost, user id (unless the app sets it), retriever documents, and the other `GenerationUsage` fields (the character / image / video / audio counters, `custom`). Those stay inside `genkit:output`.
110
+
Cost is not set by this package: fi-collector prices each model span from its tokens and `gen_ai.request.model` (an exact lookup in its litellm price table), so a model the table lists, such as `gemini-3.5-flash`, gets a cost and one it does not list shows none. Unavailable at 1.42.0, and not set: user id (unless the app sets it), retriever documents, and the other `GenerationUsage` fields (the character / image / video / audio counters, `custom`). Those stay inside `genkit:output`.
110
111
111
112
Tokens are written only on model call spans. The `generate` span's `genkit:output` repeats the last turn's usage; it stays inside that JSON and is not promoted. If any non-model span carries a key the collector promotes (`gen_ai.usage.*`, `llm.token_count.*`, `llm.usage.*`, `gen_ai.cost.*`, `llm.cost.*`; the cost prefixes cover the parts such as `gen_ai.cost.input` and `llm.cost.completion` as well as the totals), the processor moves it to `genkit.usage.<key>`, so the trace-wide token and cost sums equal the model calls.
0 commit comments