• Resolved Anonymous User 18191698

    (@anonymized-18191698)


    Hi there. As you may know, there are limits on the number of concurrent requests and with the success of chatgpt, there are probably more strains on their servers. If you could add a feature which would make it possible to add more api keys, and have the system randomly choose an api key on each request, this would benefit many users and also give u a competitive advantage. For example, john has 1 open ai account and has an app which has 500 users making calls to the api. He sets up another open ai account and gets another key. He then adds a small bit of code to randomly choose which open ai key to use per req .

    • This topic was modified 3 years, 3 months ago by Anonymous User 18191698.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jordy Meow

    (@tigroumeow)

    Hi,

    As you may know, there are limits on the number of concurrent requests and with the success of chatgpt, there are probably more strains on their servers. 

    Actually, I don’t know 🙂 Are you sure they have limits on the OpenAI API? Of course, they do have on ChatGPT, but that’s different.

    If you could add a feature which would make it possible to add more api keys, and have the system randomly choose an api key on each request, this would benefit many users and also give u a competitive advantage

    You actually do this already 🙂

    $api_keys = array(
        '1234567890',
        '0987654321',
        'qwertyuiop',
        'asdfghjkl',
        'zxcvbnm',
    );
    
    function assign_random_api_key( $query ) {
        global $api_keys;
        $index = array_rand( $api_keys );
        $query->setApiKey( $api_keys[$index] );
        return $query;
    }
    
    add_filter( 'mwai_ai_query', 'assign_random_api_key' );
    
    Thread Starter Anonymous User 18191698

    (@anonymized-18191698)

    Thanks for this reply. Just shows that the French are smarter than the Irish haha. Regarding the code above, do I add that to functions.php and what about the existing api key in the backend, is that included in the array?

    Here is the rate guide:

    https://platform.openai.com/docs/guides/rate-limits

    Plugin Author Jordy Meow

    (@tigroumeow)

    Oh, are you Irish? :p Based on your name, I thought you were a bit closer to where I live 😉

    No, the default API is not included; but we could modify the code in a way it is; or you could simply add your own API Key in the array to make it straightforward.

    About the rates, I wonder if it’s linked to an account, or an API key however! Of course, you could also create different accounts, but I am not sure they would like that 😜

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Add multiple open AI keys’ is closed to new replies.