Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/api/providers/fetchers/__tests__/litellm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -32,6 +33,7 @@ describe("getLiteLLMModels", () => {
headers: {
Authorization: "Bearer test-api-key",
"Content-Type": "application/json",
...DEFAULT_HEADERS,
},
timeout: 5000,
})
Expand Down Expand Up @@ -83,6 +85,7 @@ describe("getLiteLLMModels", () => {
headers: {
Authorization: "Bearer test-api-key",
"Content-Type": "application/json",
...DEFAULT_HEADERS,
},
timeout: 5000,
})
Expand Down Expand Up @@ -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,
})
Expand Down
2 changes: 2 additions & 0 deletions src/api/providers/fetchers/litellm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -16,6 +17,7 @@ export async function getLiteLLMModels(apiKey: string, baseUrl: string): Promise
try {
const headers: Record<string, string> = {
"Content-Type": "application/json",
...DEFAULT_HEADERS,
}

if (apiKey) {
Expand Down
11 changes: 10 additions & 1 deletion src/api/providers/router-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down
Loading