Usage limits
Usage limits allow you to see and manage model usage and cost on a per user basis.
Usage limits are handled by a custom Koa Middleware function that follows these steps:
-
A request is made to the API
-
Usage Limiter checks to see if there is any usage remaining
-
a) If usage remaining - the request is executed
b) If no usage remaining -
429 usage exceeded
response is returned -
After the request is finished, new usage is saved
If you’re creating a new endpoint that you want to be usage limited then just include the middleware function:
The string passed to the limiter chat
defines which usage property is decremented.
Usage limits are stored on the LicenseKey
model in mongoose, and both daily and monthly usage is saved.
You can define usage limits when a user signs up from the configs/plans.yml
file. More info about how that config is handled can be found in the plans section.
Usage response
Every request that calls an OpenAI API endpoint results in a cost. These costs are calculated (or estimated) and returned from all the StartKit.AI services with the result as a usage
property.
For example, this is the response of a call to the moderation endpoint to get the sentiment of some text:
For the image endpoints the response is slightly different:
The total cost of a request is also available on the x-usage-cost
header of the response.
Editing a users’ limits
You can change the limits for a specific user from the Admin Dashboard, on the Users page.
Click the License
button next to the user you want to modify.