diff --git a/examples/export-stripe-node/app.ts b/examples/export-stripe-node/app.ts index b63808d20..972da6423 100644 --- a/examples/export-stripe-node/app.ts +++ b/examples/export-stripe-node/app.ts @@ -79,11 +79,10 @@ async function reportUsage( // Query usage from OpenMeter for billing period // Change window size if you want to report hourly - const resp = await openmeter.meters.values(meterSlug, { - subject, + const resp = await openmeter.meters.query(meterSlug, { + subject: [subject], from, to, - windowSize: WindowSize.DAY }) // We asked for the whole day with window daily size so we will have only one usage record which is the total for that day diff --git a/examples/ingest-fastify-node/app.ts b/examples/ingest-fastify-node/app.ts index 77f55100c..fc0bef9c2 100644 --- a/examples/ingest-fastify-node/app.ts +++ b/examples/ingest-fastify-node/app.ts @@ -30,8 +30,8 @@ server.get('/', { Querystring: { subject?: string; from?: string; to?: string, windowSize?: WindowSize } }> ) => { - const values = await openmeter.meters.values('m1', { - subject: req.query.subject, + const values = await openmeter.meters.query('m1', { + subject: req.query.subject ? [req.query.subject] : undefined, from: req.query.from ? new Date(req.query.from) : undefined, to: req.query.to ? new Date(req.query.to) : undefined, windowSize: req.query.windowSize diff --git a/examples/ingest-openai-node/app.ts b/examples/ingest-openai-node/app.ts index 6b03cec85..fe5e0b263 100644 --- a/examples/ingest-openai-node/app.ts +++ b/examples/ingest-openai-node/app.ts @@ -94,13 +94,6 @@ async function query() { // groupBy: { 'model': 'gpt-4' } // } // ] - - // If you need the total across all models, you can use the following: - const total = values.reduce( - (total: number, { value }) => total + (value || 0), - 0 - ) - console.log(`Total token usage across all models: ${total}`) } main()