Skip to content

Problem with OpenAI keys and base url #22

@roleiland

Description

@roleiland

I was following the steps described in the README.md and I couldn't make the connection with OpenAI. According to the README.md we need to do the following exports:

export OPENAI_BASE_URL=your_openai_base_url
export OPENAI_API_KEY=your_openai_api_key

After debugging your code, I didn't find any mechanism for the program to read it. Instead I found the following in the file openai-asure.py:

key_4 = [
	{"api_base": "<api_base>", "api_key": "<api_key>", "api_version": '<api_version>'},
]

key_35 = [
  {"api_base": "<api_base>", "api_key": "<api_key>", "api_version": '<api_version>'},
]
...
        self.key_pool = key_4 if model.startswith('gpt-4') else key_35
...

        choose_api = random.choice(self.key_pool) # -> {'api_base': '<api_base>', 'api_key': '<api_key>', 'api_version': '<api_version>'}
        api_base = choose_api["api_base"]
        api_key = choose_api['api_key']
        api_version = choose_api['api_version']
                client = AzureOpenAI(
            azure_endpoint=api_base,
            api_key=api_key,
            api_version=api_version
        )

Why is choose_api picked randomly?

The values are {'api_base': '<api_base>', 'api_key': '<api_key>', 'api_version': '<api_version>'}, therefore in order to make the code work, I had to input the api_base, api_key, and api_version directly into the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions