mirror of
https://github.com/openai/codex.git
synced 2026-05-01 09:56:37 +00:00
fix: inconsistent usage of base URL and API key (#507)
A recent commit introduced the ability to use third-party model providers. (Really appreciate it!) However, the usage is inconsistent: some pieces of code use the custom providers, whereas others still have the old behavior. Additionally, `OPENAI_BASE_URL` is now being disregarded when it shouldn't be. This PR normalizes the usage to `getApiKey` and `getBaseUrl`, and enables the use of `OPENAI_BASE_URL` if present. --------- Co-authored-by: Gabriel Bianconi <GabrielBianconi@users.noreply.github.com>
This commit is contained in:
@@ -20,9 +20,11 @@ async function fetchModels(provider: string): Promise<Array<string>> {
|
||||
throw new Error("No API key configured for provider: " + provider);
|
||||
}
|
||||
|
||||
const baseURL = getBaseUrl(provider);
|
||||
try {
|
||||
const openai = new OpenAI({ apiKey: getApiKey(provider), baseURL });
|
||||
const openai = new OpenAI({
|
||||
apiKey: getApiKey(provider),
|
||||
baseURL: getBaseUrl(provider),
|
||||
});
|
||||
const list = await openai.models.list();
|
||||
const models: Array<string> = [];
|
||||
for await (const model of list as AsyncIterable<{ id?: string }>) {
|
||||
|
||||
Reference in New Issue
Block a user