Skip to content

Commit b3c7be7

Browse files
committed
feat(openai): Add Config Option to Overwrite OpenAI's API Base
1 parent d990f0e commit b3c7be7

File tree

6 files changed

+15
-1
lines changed

6 files changed

+15
-1
lines changed

evals/packages/types/src/roo-code.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ export const providerSettingsSchema = z.object({
358358
googleGeminiBaseUrl: z.string().optional(),
359359
// OpenAI Native
360360
openAiNativeApiKey: z.string().optional(),
361+
openAiNativeBaseUrl: z.string().optional(),
361362
// XAI
362363
xaiApiKey: z.string().optional(),
363364
// Mistral
@@ -445,6 +446,7 @@ const providerSettingsRecord: ProviderSettingsRecord = {
445446
googleGeminiBaseUrl: undefined,
446447
// OpenAI Native
447448
openAiNativeApiKey: undefined,
449+
openAiNativeBaseUrl: undefined,
448450
// Mistral
449451
mistralApiKey: undefined,
450452
mistralCodestralUrl: undefined,

src/api/providers/openai-native.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
2929
super()
3030
this.options = options
3131
const apiKey = this.options.openAiNativeApiKey ?? "not-provided"
32-
this.client = new OpenAI({ apiKey })
32+
this.client = new OpenAI({ baseURL: this.options.openAiNativeBaseUrl, apiKey })
3333
}
3434

3535
override async *createMessage(systemPrompt: string, messages: Anthropic.Messages.MessageParam[]): ApiStream {

src/exports/roo-code.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ type ProviderSettings = {
105105
geminiApiKey?: string | undefined
106106
googleGeminiBaseUrl?: string | undefined
107107
openAiNativeApiKey?: string | undefined
108+
openAiNativeBaseUrl?: string | undefined
108109
mistralApiKey?: string | undefined
109110
mistralCodestralUrl?: string | undefined
110111
deepSeekBaseUrl?: string | undefined

src/exports/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ type ProviderSettings = {
106106
geminiApiKey?: string | undefined
107107
googleGeminiBaseUrl?: string | undefined
108108
openAiNativeApiKey?: string | undefined
109+
openAiNativeBaseUrl?: string | undefined
109110
mistralApiKey?: string | undefined
110111
mistralCodestralUrl?: string | undefined
111112
deepSeekBaseUrl?: string | undefined

src/schemas/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ export const providerSettingsSchema = z.object({
401401
googleGeminiBaseUrl: z.string().optional(),
402402
// OpenAI Native
403403
openAiNativeApiKey: z.string().optional(),
404+
openAiNativeBaseUrl: z.string().optional(),
404405
// Mistral
405406
mistralApiKey: z.string().optional(),
406407
mistralCodestralUrl: z.string().optional(),
@@ -492,6 +493,7 @@ const providerSettingsRecord: ProviderSettingsRecord = {
492493
googleGeminiBaseUrl: undefined,
493494
// OpenAI Native
494495
openAiNativeApiKey: undefined,
496+
openAiNativeBaseUrl: undefined,
495497
// Mistral
496498
mistralApiKey: undefined,
497499
mistralCodestralUrl: undefined,

webview-ui/src/components/settings/ApiOptions.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,14 @@ const ApiOptions = ({
490490

491491
{selectedProvider === "openai-native" && (
492492
<>
493+
<VSCodeTextField
494+
value={apiConfiguration?.openAiNativeBaseUrl || ""}
495+
type="url"
496+
onInput={handleInputChange("openAiNativeBaseUrl")}
497+
placeholder={t("settings:placeholders.baseUrl")}
498+
className="w-full">
499+
<label className="block font-medium mb-1">{t("settings:providers.openAiBaseUrl")}</label>
500+
</VSCodeTextField>
493501
<VSCodeTextField
494502
value={apiConfiguration?.openAiNativeApiKey || ""}
495503
type="password"

0 commit comments

Comments
 (0)