Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(llma): include decision and embedding models in the OpenRouter cost sync (#115992)

Bernat Torresc25e3ca21055
diff --git a/nodejs/src/ingestion/pipelines/ai/costs/scripts/update-ai-costs.test.ts b/nodejs/src/ingestion/pipelines/ai/costs/scripts/update-ai-costs.test.ts
index 9803eb00f3a9..7af19856c485 100644
--- a/nodejs/src/ingestion/pipelines/ai/costs/scripts/update-ai-costs.test.ts
+++ b/nodejs/src/ingestion/pipelines/ai/costs/scripts/update-ai-costs.test.ts
@@ -1468,6 +1468,14 @@ describe('fetchOpenRouterCosts()', () => {
json: () => Promise.resolve(url.includes('/endpoints') ? endpointsPayload : listPayload),
})) as never)
+ it('asks for decision and embedding models as well as text models', async () => {
+ jest.spyOn(console, 'log').mockImplementation(() => {})
+ const fetchSpy = mockFetch()
+ await fetchOpenRouterCosts()
+ const listUrl = new URL(fetchSpy.mock.calls[0][0])
+ expect(listUrl.searchParams.get('output_modalities')).toBe('text,decisions,embeddings')
+ })
+
it('reads per-endpoint pricing, not just the list payload', async () => {
// Pins that production hands the loop the real reader, not a fake.
jest.spyOn(console, 'log').mockImplementation(() => {})
diff --git a/nodejs/src/ingestion/pipelines/ai/costs/scripts/update-ai-costs.ts b/nodejs/src/ingestion/pipelines/ai/costs/scripts/update-ai-costs.ts
index 5eacab7b5975..20f6b8ae17d4 100644
--- a/nodejs/src/ingestion/pipelines/ai/costs/scripts/update-ai-costs.ts
+++ b/nodejs/src/ingestion/pipelines/ai/costs/scripts/update-ai-costs.ts
@@ -666,8 +666,9 @@ export const readEndpointsFromOpenRouter: EndpointFetcher = async (modelId) => {
}
export const fetchOpenRouterCosts = async (): Promise<RunTotals> => {
+ // Unfiltered, OpenRouter lists text-output models only, leaving out decision models (such as TypeSafe's Jev) and embedding models.
// eslint-disable-next-line no-restricted-globals
- const res = await fetch('https://openrouter.ai/api/v1/models', {})
+ const res = await fetch('https://openrouter.ai/api/v1/models?output_modalities=text,decisions,embeddings', {})
if (!res.ok) {
throw new Error(`Failed to fetch OpenRouter models: ${res.status} ${res.statusText}`)
}