Use the web API, specifically: limelm.pkey.generate.
You can generate any number of product keys with any number of allowed activations. If you want a more complete solution (i.e. an order page that sends the customer a product key after they've purchased your software) then see "How to generate product keys after an order"