#tal-wordware_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1359292411536216185
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- tal-wordware_api, 17 hours ago, 5 messages
- tal-wordware_error, 1 day ago, 31 messages
Oh shoot so sorry. I'm digging into this now.
If helpful, here are the metering events coming in for customer stripe-18 in test mode, and the equivalent preview invoice showing no usage
Not entirely sure
We can probably go generating invoices for everyone and find the most recent, unless there's a better way at finding that out
So sorry.
So metered events can take a bit of time to flow through to being available, though creating a (real) invoice, or updating the Subscription, should trigger a 'recompute' and let you see them ~right away.
You can also use a Test Clock to be able to go forward in time and create the actual next Invoice, to confirm that the metered events land as expected.
Wait we're relying on preview invoices to know if users are out of credit, and the docs say preview invoices are eventually consistent with a max 1 minute delay. Is that not the case?
It says max 1 minute?
I can see if I can dig up the source, but this was the number I had
Ok. It says 'asynchronous' but isn't specific beyond that, at least as far as I know (but I could be wrong).
Did these work previously? If so when did they stop working?
I ran a series of simulations last night testing this that seemed to work fine
The openai line is our calculated results based on preview invoices and credit balance summaries
And that's not working today?
The lines below are my eyeball for what they should be, where I stopped updating them past the invoice expiration
Yes newly not working
Can you share the code behind that?
I'm rerunning the simulation I just sent you now
Here:
Ok this is working
Something is different between running this simulation, which works, and manually adding metering events through the dashboard, or through the typescript API, which doesn't
No the dashboard-added events don't show up in the invoices
But they do show up in the metering events activity page
meter is mtr_test_61QhYlTu7O8BceebX41LnmNuDWyYU1HM
price is price_1PbZBtLnmNuDWyYUqNRFVjzV
And you can see that price I'm reading from is connected to the meter I'm writing to
Wait, so this works in Python but not in Node?
seemingly
Something seems fishy
Both sets of events appear under the meter, but only the Python ones make it into the preview invoice
You're doing something with Credit Balances there too, that you aren't doing with the other, ya?
I created a new metering event via CLI while the simulation was running against the ephemeral customer created by the simulation
--event-name=llm_usage \
-d "payload[value]"=2500000000 \
-d "payload[stripe_customer_id]"=cus_S5xaVVqgtnukhp```
And did those get included?
It appeared in the dashboard but not the simulation results, which were calculated from preview invoices and credit balance summaries
Ah
Found something?
๐ Hi there. Taking over and gimme some time to catch up
Perfect timing lol, I get the sense @daring garnet had just figured this out ๐
There may be an issue with Stripe API v18 where metering events from the new API don't get metered against accounts correctly if the account hasn't been upgraded to version v18 in prod
Thought it's certainly possible it's not related to the API version
Hi there, normally the Meter events are asynced and can be reflected in 3 minutes. However if you use Test clock, you may want to wait for it reflected before moving up the Test clock
Looks like the delay is at least a few hours
I'm not seeing any new events since earlier today
We would want to look a bit closer into that. Are you seeing it in Live mode or Test mode, or both?
Or rather the metering events appear but they're not being priced into the invoices
Both
On Test mode do you use Test Clocks?
If you use Test Clocks and advance the simulated time for 10 mins, then 30 mins or more, do you see it is reflected on Upcoming Invoice?
Not currently using test clocks, I can try
Just created user Preview Invoices Test (cus_S5yezDgBXmDKTR) and used this:
--event-name=llm_usage \
-d "payload[value]"=1234567890 \
-d "payload[stripe_customer_id]"=cus_S5yezDgBXmDKTR
Looks like the usage was successfully logged
And incorporated into the upcoming invoice
Now I'm going to try with a different customer (cus_S5u0VTUGggLfMo)
^ Before
Created metering event with CLI:
--event-name=llm_usage \
-d "payload[value]"=1234567890 \
-d "payload[stripe_customer_id]"=cus_S5u0VTUGggLfMo```
And didn't work
I did exactly the same process with both, except the one that worked was with the test clock (didn't advance it though, left it at the same time), and the one that didn't work was with an existing customer on the same subscription type
Any idea what's going on?
Hmm so as long as Test clock chime in you suddenly have it working, but as of a normal/regular flow you never see the events
Weird...
It does make sense though, because I used Test Clock and that worked for me
I just bumped our API version in Workbench to 2025-03-31.basil
To see if that makes a difference
We've already switched all our requests over
Which version were you on before?
2023-10-16
Um I am on 2024-11-20.acacia and it's working for me
Can you try 2025-03-31.basil?
Sure. But before that, could you share the Subscription Id which didn't work for you?
sub_1RBiDSLnmNuDWyYUQ3Q4dySX
Umm I see
?
I mean I can see the meter is not reflected in your Upcoming Invoice. Trying again in on my end with 2025-03-31.basil
One thought I had is there could be some constraint on the preview invoice endpoint that causes it to break after too many calls, cause we're using it quite heavily
Like how heavy is it ๐ I think there isn't any constraint but trying to gather as much as I can
Hi, could you try (just try) to have a Price with much larger unit amount? ie $5 per usage
We bill for LLM token usage, and many models are a few cents per million tokens, so we internally represent prices in billionths of a dollar per token ๐
Ah you mean send a test metering event against a new test price with a much higher unit amount?
Yes
I'll do that, but if it's helpful you're totally free to add new products and prices on your end for testing
As long as it's in test and not live mode
We're robust to the existence of new products and new prices in existing products as long as the new prices aren't set to be default
We basically won't and shouldn't do anything on your account ๐
We only see the objects and the view as read-only
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Just sent a metering event, about $6.2B charged to Tom Smith
Ok that worked, though it took 30+ seconds
(to appear on the preview invoice)
Created the meter event via CLI on version 1.26.1 which is from 5 days ago
But I wonder if it's about the fact that Tom's new
Ok that worked and appeared on the prev inv after 50 seconds
So perhaps it's subscriptions created before the API version bump?
To sumarize:
- 2023-10-16 / Live mode -> not reflected
- 2023-10-16 / Test mode -> not reflected
- 2023-10-16 / Test mode + Test mode -> reflected
- 2025-03-31.basil / Test mode -> reflected
Does this look correct?
Hmm
If you report to any Subscription created before 2025-03-31, no matter which Price, mode, it won't be reflected?
Let's find one
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Mar 6
Just sent the metering event w/ CLI
Though that test customer also has a different seat-based subscription item to go with the usage-based subscription item we're metering on
Ok that wokred
*worked
Weird this is definitely something on and off
We're doing our next press launch on Thursday morning, can we rely on this?
That's close. Can we do another test? Looking back at sub_1RBjGhLnmNuDWyYUvjxvHPYq which you saw the issue earlier
Can you try again now? register one more usage
Alternatively do you know of another way of knowing how much of a customer's credit grants they've used in the current billing cycle or if they're out of credit grants? We're doing prepaid billing using credit grants
Sure here's before for sub_1RBjGhLnmNuDWyYUvjxvHPYq
Sent
(Could you share the sent request id as well? req_xxx)
Umm same Meter, just different Customer and different Subscription
The only thing I changed in the request via CLI was the stripe customer id
First and second
Now let's use cus_S5uv8L6MqJ0Vcd (the problematic one), would you be able to create a new Price + Subscription + Meter?
Keep using the exact same customer, but generate a completely different set of (Meter/Price/Sub)
Sorry for all the trouble. We are really stuck on own side as we can't reproduce, and seems it is also only 1 pattern in your account
No worries, just had to review a PR, doing this now
Done
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Worked!
Definitely still curious about this
Wait a minute
I could've sworn I saw the usage appear on here
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Just re-sent the request, and it worked again, we'll see if it disappears
Very strange. I re-ran the request from my request history, so you can see that it was sent and received, but it was at zero until I sent it again, and it may or may not have originally worked. Very odd
So the 2nd time after you saw it in above screenshot, is it still there?
Something stucked there and this cleared it probably?
Looks good now
For the test price + meter + existing customer
I can try a metering event matching our actual meters/prices
Now can you back to the original Meter which didn't work, send an event there
sub_1RBjGhLnmNuDWyYUvjxvHPYq
So I never removed the first one, just added the second and metered against it
just sent to the new one
*old one
Before
req_Q2m7tgRHOL6oS4
This is odd
So I thought
- Meter isn't the issue, because Meter works with different Customer
- Customer isn't the issue, because Customer works. with different Meter
Now can we test with the same customer, the same Meter but with a new Price?
If that also works, it means only a combination of this Customer + this Price + this Meter can rerproduce
Btw, do you have any other non-working example of Subscription? Beside sub_1QzmjrLnmNuDWyYU7ZFNDUof
Ty!
sub_1RBpgOLnmNuDWyYUwDIfhMNv
Sending request now
Before
So this should be interesting as there are now two prices connected to this same meter
^ New subscription with new price on old meter
Oh that works
^ Old subscription with old price on old meter
Uhhmm so we have been probing enough to say this is the combination of the exact Subscription sub_1RBjGhLnmNuDWyYUvjxvHPYq
Sorry the last question, did you notice this happen on any other Subscription as well?
Sorry I looked back and at a time you mentioned it worked in Python but not in Node. I wonder if you use Python, on the exact problematic Subscription + Meter + Customer, does it work for you?
To rule out the differences between programming language
(I believe languages doesn't matter though)