Cook the spaghetti in boiling salted water until al dente. In the meantime, peel the garlic and onion, chop finely and sauté in hot olive oil. Pour the cream on, stir in the cream cheese. Cut the ham into small cubes and add to the sauce. Season to taste with pepper and chili powder.
If the sauce is too thick, thin it with a little vegetable stock. Drain the spaghetti, arrange on deep plates and pour the sauce over them.