Skip to content

Proper encapsulation of the API keys #233

@perone

Description

@perone

Describe the feature or improvement you're requesting

In the Node.js API we have the API accepting keys upon creation of the OpenAIApi object:

import { Configuration, OpenAIApi } from "openai";
const configuration = new Configuration({
    organization: "org-1qRDHAPS0UN4vVhAii7VYY7y",
    apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);

In Python, however, the key is set globally, which poses a problem when dealing with multiple keys/organizations in requests. It would be nice to have proper encapsulation of the key into a Python class that is responsible for the API like it is usually done for many Python APIs, instead of using global objects for keys.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixed in v1Issues addressed by the v1 beta

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions