diff --git a/src/api/providers/fetchers/__tests__/litellm.spec.ts b/src/api/providers/fetchers/__tests__/litellm.spec.ts index f4db3bc12e..07bbe9871a 100644 --- a/src/api/providers/fetchers/__tests__/litellm.spec.ts +++ b/src/api/providers/fetchers/__tests__/litellm.spec.ts @@ -4,6 +4,7 @@ vi.mock("axios") import type { Mock } from "vitest" import axios from "axios" import { getLiteLLMModels } from "../litellm" +import { DEFAULT_HEADERS } from "../../constants" const mockedAxios = axios as typeof axios & { get: Mock @@ -32,6 +33,7 @@ describe("getLiteLLMModels", () => { headers: { Authorization: "Bearer test-api-key", "Content-Type": "application/json", + ...DEFAULT_HEADERS, }, timeout: 5000, }) @@ -83,6 +85,7 @@ describe("getLiteLLMModels", () => { headers: { Authorization: "Bearer test-api-key", "Content-Type": "application/json", + ...DEFAULT_HEADERS, }, timeout: 5000, }) @@ -125,6 +128,7 @@ describe("getLiteLLMModels", () => { expect(mockedAxios.get).toHaveBeenCalledWith("http://localhost:4000/v1/model/info", { headers: { "Content-Type": "application/json", + ...DEFAULT_HEADERS, }, timeout: 5000, }) diff --git a/src/api/providers/fetchers/litellm.ts b/src/api/providers/fetchers/litellm.ts index 47617cd390..0891527406 100644 --- a/src/api/providers/fetchers/litellm.ts +++ b/src/api/providers/fetchers/litellm.ts @@ -4,6 +4,7 @@ import { LITELLM_COMPUTER_USE_MODELS } from "@roo-code/types" import type { ModelRecord } from "../../../shared/api" +import { DEFAULT_HEADERS } from "../constants" /** * Fetches available models from a LiteLLM server * @@ -16,6 +17,7 @@ export async function getLiteLLMModels(apiKey: string, baseUrl: string): Promise try { const headers: Record = { "Content-Type": "application/json", + ...DEFAULT_HEADERS, } if (apiKey) { diff --git a/src/api/providers/router-provider.ts b/src/api/providers/router-provider.ts index c64b29571a..25e9a11e1b 100644 --- a/src/api/providers/router-provider.ts +++ b/src/api/providers/router-provider.ts @@ -7,6 +7,8 @@ import { ApiHandlerOptions, RouterName, ModelRecord } from "../../shared/api" import { BaseProvider } from "./base-provider" import { getModels } from "./fetchers/modelCache" +import { DEFAULT_HEADERS } from "./constants" + type RouterProviderOptions = { name: RouterName baseURL: string @@ -43,7 +45,14 @@ export abstract class RouterProvider extends BaseProvider { this.defaultModelId = defaultModelId this.defaultModelInfo = defaultModelInfo - this.client = new OpenAI({ baseURL, apiKey }) + this.client = new OpenAI({ + baseURL, + apiKey, + defaultHeaders: { + ...DEFAULT_HEADERS, + ...(options.openAiHeaders || {}), + }, + }) } public async fetchModel() {