Api key and account rotation on the userapi.ai

·

1 min read

This article will very briefly shed some light on how api keys and account rotation work.

When you register on userapi.ai, an api-key is immediately created for you, which you must specify in every request to the api in the request headers, like this:

curl -X POST https://api.userapi.ai/midjourney/v2/imagine \
-H "Content-Type: application/json" \
-H "api-key: 3fb0b6d9-6e1b-4bd7-993f-f79e9f1717e8" \
-d '{ "prompt": "a kitty lying on a cozy couch" }'

What it looks like in the dashboard:

However, in order for the api-key to work and you can generate images through the API, you need to link your Discord account to this api-key. When adding your first and subsequent Discord accounts (you may need several accounts if you have a large number of simultaneous generation requests), you must specify the api-key to which you are linking the account:

This way you can group multiple accounts via api-key. API works in such a way that if you specify api-key in the header, but do not specify account_hash parameter in the request body (i.e. do not specify which Discord account linked to this api-key you want to use during this particular generation) - then for each new generation task a new Discord account will be taken, so the load between accounts linked to the same api-key will be distributed evenly.