Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About multiple secret keys rate limit #16

Open
lzonel opened this issue Apr 26, 2023 · 1 comment
Open

About multiple secret keys rate limit #16

lzonel opened this issue Apr 26, 2023 · 1 comment
Labels
documentation Improvements or additions to documentation question Further information is requested

Comments

@lzonel
Copy link

lzonel commented Apr 26, 2023

If I want to use multiple sks and dynamically change sks, how should I write them because a single sk affects the rate?

@coin-au-carre
Copy link
Member

coin-au-carre commented Apr 27, 2023

@lzonel I suppose you are referring to secret keys as sks ?

Approach 1: If you want to have only one instance and manage dynamically keys

If you are conformtable with C++, you can use the undocumented method setToken on the session see

void setToken(const std::string& token, const std::string& organization) {

I am willing to add more helpers and documentation if this something you might really need and you don't know how to proceed.

Approach 2: If you want to have several instances with different secret keys

Check out https://github.com/olrea/openai-cpp#pass-by-reference

Pass by reference

An other approach is to pass the OpenAI instance by reference, store it, and call the appropriate methods when needed.

void bar(openai::OpenAI& openai) {
    openai.completion.create({
        {"model", "text-davinci-003"},
        {"prompt", "Say bar() function called"}
    });
}

int main() {
    openai::OpenAI openai_instance{"your_api_key"};
    bar(openai_instance);
}

You can use a std::reference_wrapper as shown in examples/09-instances.cpp. This strategy is useful if you have to manage several OpenAI-CPP instances.

@coin-au-carre coin-au-carre added the question Further information is requested label Apr 27, 2023
@coin-au-carre coin-au-carre changed the title About SK rate limit About secret keys rate limit Apr 27, 2023
@coin-au-carre coin-au-carre changed the title About secret keys rate limit About multiple secret keys rate limit Apr 27, 2023
@coin-au-carre coin-au-carre added the documentation Improvements or additions to documentation label Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants