A new 24-hour "ATM" in Los Angeles is holding late-night sugar cravings at bay by dispensing cupcakes instead of money.

Sprinkles in Beverly Hills started the cupcake craze back in 2005, and now it's reigniting the frenzy with its new cupcake ATM. This pink vending machine, located next door to the shop, makes the designer cute cakes ($4 each) readily available to the snack-hungry masses 24 hours a day, seven days a week.

It makes sense that Sprinkles founder Candace Nelson, the woman who came up with the idea of the world's first cupcake-only bakery, was the one with the foresight to realise the value of 24-hour cupcake accessibility. "I was pregnant with my second child and I thought, I'm the owner of a cupcake bakery and even I can't get a cupcake in the middle of the night."

Cupcake fiends can choose from eight flavours, which include popular Sprinkles signatures like Red Velvet and Chocolate Marshmallow, as well as special flavours of the day. Once the request is submitted via the machine's touchscreen and a credit card swiped (the machine doesn't actually accept cash), a robotic arm retrieves the individually boxed cupcake. The entire journey from shelf to dispenser door is captured by video camera and displayed on the screen. However, the machine only handles one item per transaction, making it more suited to satisfying spontaneous cravings rather than supplying cupcake parties.

Since the vending machine, which holds 600 cupcakes, dispensed about 1,000 cakes a day when it first opened in March and continues to attract a 50-people long queue today (even when the cupcakery is open), there's never any danger of receiving a stale cupcake. And the flavours never run out as the bakers work from 2 am to 12 am every day to keep the machine stocked.

There are also vegan and gluten-free cupcakes, doggie cupcakes, cupcake mixes and apparel for sale through the machine.

The cupcake ATM in Beverly Hills is the first of 10 slated to open at Sprinkles' locations in cities like New York City, Washington DC and Chicago. The Beverly Hills location also just opened an ice cream shop, Sprinkles Ice Cream, which features red velvet waffle cones and ice-cream sandwiches made with cupcake tops.