How do I charge my customers for API usage?
- Use an API Gateway:
As @_j mentioned above, you should not, under any circumstances, share your own OpenAI credentials with your end customer/developer.
I recommend first creating an API Gateway layer on top of OpenAI that proxies the upstream API calls and allows you to generate your own API Keys for each customer.
Each of the major cloud providers has its own API Gateway and will allow you to proxy the OpenAI calls. Microsoft Azure has an example of this on their site: azure-openai-api-from-specification
- Create an API Product
@cesarer is correct to ask if a usage based revenue model is the best fit in this case. It will add additional complexity where a simple subscription (flat-fee) may be preferred. Here are some common API Product revenue models:
i) Flat-fee
If your call costs to OpenAI are static, you could use this as a basis and add your 25% markup.
ii) Usage Based
If your costs vary depending on which API is being called, then you may need to move to a usage-based revenue model. Here, you can say how much each API call costs and charge accordingly.
iii) Flat fee plus Overage
Many developers prefer this revenue model. They get a good deal on the API calls they make that are included in the plan, but the API does not stop working if they exceed their quota. They just get charged on an API call basis for the rest of the billing period, usually at a higher rate.
You code your own API Products and bake them into your application, or you may find it easier to use an existing API Portal Platform that allows you to monetize API products.
- Tracking API Usage
As developers make API calls to your product, you need to be able to charge them accordingly. Assuming you have connected an API Gateway as mentioned above, you can now monitor the logs for each of your API Consumers, usually identified via their API Key.
If you want to avoid coding this, some API Portal will monitor the API usage and bill your customers on your behalf.