Guinea Pigs, known to enthusiasts and professionals as cavies, are herbivores - they eat plant matter. Grassy hay is at the top of the list. Timothy hay is among the best options, though alfalfa can be fed in small quantities. Alfalfa, a legume not a grass, has more protein and carbohydrates, so it's more commonly fed briefly to young pups and nursing sows.
One popular way to provide what they want and need is in the form of pellets. This is convenient and can provide good nutrition, provided they're free of dyes and other potentially harmful compounds. Pellets should be timothy or orchard grass, not chiefly alfalfa. It can vary depending on the size and metabolism of your cavy, but 3-4 ounces per day of grass hay pellets is plenty.
Pellets that contain animal fat are not recommended. Similarly, nuts provide excess fat and are generally too rich for all but pups. Corn is not among the plants that form a normal part of the cavy diet. Rice, too, is not one of the grains that should be fed to a guinea pig.
It's sometimes safe to allow your guinea pig to forage outside for food. But there are often plants or flowers in the area that can be harmful. Buttercup, hemlock, foxglove, tulips, onions and many more are poisonous to cavies. Unless you are familiar with what they are and can keep your pet away from them, it's safer to control their diet.
One alternative is to grow a small patch of wheat grass or other beneficial plant and allow them to enjoy eating outside. Ensure the plants are not contaminated with dog feces, mold or anything else that can be harmful to your cavy.
Like humans, cavies don't manufacture their own vitamin C and so must get it from their diet. They need between 10-30 mg/kg of body weight daily. When for whatever reason they don't get enough from their food, supplements can be used, if given carefully.
It's best not to add vitamin C to their water supply. They drink in irregular intervals so dosage is difficult to calculate that way. Also, it changes the taste of the water and the cavy may consume less water than it needs. In addition, ascorbic acid degrades rapidly in water, so the vitamin will lose potency soon after being offered.
Cavies do drink water, though, and a plain drink with lots of minerals is just fine. A drip feeder allows them to self-regulate the amount they want without the risk of them dumping over a bowl. An occasional, small amount of unsweetened cranberry juice can provide vitamin C and cavies like it.
Vegetables, fed in limited quantities, are a nice addition to their diet. Romaine lettuce is a good choice. Small pieces of carrot are fine, but don't expect them to consume very much. Corn husks and spinach are two more possibilities. Cabbage, broccoli and other cruciferous vegetables may give them gas and should be avoided.
Certain fruits are appreciated, like cantaloupe, but no more than a few chunks per day. Apple, blueberries, strawberries and several others are safe and tasty.