Adding requesty base url (#6992)

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Co-authored-by: John Costa <john@requesty.ai>
Co-authored-by: Roo Code <roomote@roocode.com>
This commit is contained in:
Matt Rubens 2025-08-12 10:04:35 -04:00 committed by GitHub
parent 2730ef96b8
commit 3acb3ba21e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 87 additions and 3 deletions

View file

@ -225,6 +225,7 @@ const unboundSchema = baseProviderSettingsSchema.extend({
})
const requestySchema = baseProviderSettingsSchema.extend({
requestyBaseUrl: z.string().optional(),
requestyApiKey: z.string().optional(),
requestyModelId: z.string().optional(),
})

View file

@ -65,6 +65,21 @@ describe("RequestyHandler", () => {
})
})
it("can use a base URL instead of the default", () => {
const handler = new RequestyHandler({ ...mockOptions, requestyBaseUrl: "some-base-url" })
expect(handler).toBeInstanceOf(RequestyHandler)
expect(OpenAI).toHaveBeenCalledWith({
baseURL: "some-base-url",
apiKey: mockOptions.requestyApiKey,
defaultHeaders: {
"HTTP-Referer": "https://github.com/RooVetGit/Roo-Cline",
"X-Title": "Roo Code",
"User-Agent": `RooCode/${Package.version}`,
},
})
})
describe("fetchModel", () => {
it("returns correct model info when options are provided", async () => {
const handler = new RequestyHandler(mockOptions)

View file

@ -47,7 +47,7 @@ export class RequestyHandler extends BaseProvider implements SingleCompletionHan
this.options = options
this.client = new OpenAI({
baseURL: "https://router.requesty.ai/v1",
baseURL: options.requestyBaseUrl || "https://router.requesty.ai/v1",
apiKey: this.options.requestyApiKey ?? "not-provided",
defaultHeaders: DEFAULT_HEADERS,
})

View file

@ -1,5 +1,5 @@
import { useCallback, useState } from "react"
import { VSCodeTextField } from "@vscode/webview-ui-toolkit/react"
import { useCallback, useEffect, useState } from "react"
import { VSCodeCheckbox, VSCodeTextField } from "@vscode/webview-ui-toolkit/react"
import { type ProviderSettings, type OrganizationAllowList, requestyDefaultModelId } from "@roo-code/types"
@ -35,6 +35,13 @@ export const Requesty = ({
const [didRefetch, setDidRefetch] = useState<boolean>()
const [requestyEndpointSelected, setRequestyEndpointSelected] = useState(!!apiConfiguration.requestyBaseUrl)
// This ensures that the "Use custom URL" checkbox is hidden when the user deletes the URL.
useEffect(() => {
setRequestyEndpointSelected(!!apiConfiguration?.requestyBaseUrl)
}, [apiConfiguration?.requestyBaseUrl])
const handleInputChange = useCallback(
<K extends keyof ProviderSettings, E>(
field: K,
@ -72,6 +79,31 @@ export const Requesty = ({
{t("settings:providers.getRequestyApiKey")}
</VSCodeButtonLink>
)}
<VSCodeCheckbox
checked={requestyEndpointSelected}
onChange={(e: any) => {
const isChecked = e.target.checked === true
if (!isChecked) {
setApiConfigurationField("requestyBaseUrl", undefined)
}
setRequestyEndpointSelected(isChecked)
}}>
{t("settings:providers.requestyUseCustomBaseUrl")}
</VSCodeCheckbox>
{requestyEndpointSelected && (
<VSCodeTextField
value={apiConfiguration?.requestyBaseUrl || ""}
type="text"
onInput={handleInputChange("requestyBaseUrl")}
placeholder={t("settings:providers.getRequestyBaseUrl")}
className="w-full">
<div className="flex justify-between items-center mb-1">
<label className="block font-medium">{t("settings:providers.getRequestyBaseUrl")}</label>
</div>
</VSCodeTextField>
)}
<Button
variant="outline"
onClick={() => {

View file

@ -253,6 +253,8 @@
"error": "No s'ha pogut actualitzar la llista de models. Si us plau, torneu-ho a provar."
},
"getRequestyApiKey": "Obtenir clau API de Requesty",
"getRequestyBaseUrl": "URL base",
"requestyUseCustomBaseUrl": "Utilitza l'URL base personalitzada",
"openRouterTransformsText": "Comprimir prompts i cadenes de missatges a la mida del context (<a>Transformacions d'OpenRouter</a>)",
"anthropicApiKey": "Clau API d'Anthropic",
"getAnthropicApiKey": "Obtenir clau API d'Anthropic",

View file

@ -255,6 +255,8 @@
"error": "Fehler beim Aktualisieren der Modellliste. Bitte versuche es erneut."
},
"getRequestyApiKey": "Requesty API-Schlüssel erhalten",
"getRequestyBaseUrl": "Basis-URL",
"requestyUseCustomBaseUrl": "Benutzerdefinierte Basis-URL verwenden",
"openRouterTransformsText": "Prompts und Nachrichtenketten auf Kontextgröße komprimieren (<a>OpenRouter Transformationen</a>)",
"anthropicApiKey": "Anthropic API-Schlüssel",
"getAnthropicApiKey": "Anthropic API-Schlüssel erhalten",

View file

@ -252,6 +252,8 @@
"error": "Failed to refresh models list. Please try again."
},
"getRequestyApiKey": "Get Requesty API Key",
"getRequestyBaseUrl": "Base URL",
"requestyUseCustomBaseUrl": "Use custom base URL",
"openRouterTransformsText": "Compress prompts and message chains to the context size (<a>OpenRouter Transforms</a>)",
"anthropicApiKey": "Anthropic API Key",
"getAnthropicApiKey": "Get Anthropic API Key",

View file

@ -253,6 +253,8 @@
"error": "Error al actualizar la lista de modelos. Por favor, inténtalo de nuevo."
},
"getRequestyApiKey": "Obtener clave API de Requesty",
"getRequestyBaseUrl": "URL base",
"requestyUseCustomBaseUrl": "Utilice una URL base personalizada",
"openRouterTransformsText": "Comprimir prompts y cadenas de mensajes al tamaño del contexto (<a>Transformaciones de OpenRouter</a>)",
"anthropicApiKey": "Clave API de Anthropic",
"getAnthropicApiKey": "Obtener clave API de Anthropic",

View file

@ -253,6 +253,8 @@
"error": "Échec de l'actualisation de la liste des modèles. Veuillez réessayer."
},
"getRequestyApiKey": "Obtenir la clé API Requesty",
"getRequestyBaseUrl": "URL de base",
"requestyUseCustomBaseUrl": "Utiliser une URL de base personnalisée",
"openRouterTransformsText": "Compresser les prompts et chaînes de messages à la taille du contexte (<a>Transformations OpenRouter</a>)",
"anthropicApiKey": "Clé API Anthropic",
"getAnthropicApiKey": "Obtenir la clé API Anthropic",

View file

@ -253,6 +253,8 @@
"error": "मॉडल सूची अपडेट करने में विफल। कृपया पुनः प्रयास करें।"
},
"getRequestyApiKey": "Requesty API कुंजी प्राप्त करें",
"getRequestyBaseUrl": "बेस URL",
"requestyUseCustomBaseUrl": "कस्टम बेस URL का उपयोग करें",
"openRouterTransformsText": "संदर्भ आकार के लिए प्रॉम्प्ट और संदेश श्रृंखलाओं को संपीड़ित करें (<a>OpenRouter ट्रांसफॉर्म</a>)",
"anthropicApiKey": "Anthropic API कुंजी",
"getAnthropicApiKey": "Anthropic API कुंजी प्राप्त करें",

View file

@ -257,6 +257,8 @@
"error": "Gagal merefresh daftar model. Silakan coba lagi."
},
"getRequestyApiKey": "Dapatkan Requesty API Key",
"getRequestyBaseUrl": "Base URL",
"requestyUseCustomBaseUrl": "Gunakan URL dasar khusus",
"openRouterTransformsText": "Kompres prompt dan rantai pesan ke ukuran konteks (<a>OpenRouter Transforms</a>)",
"anthropicApiKey": "Anthropic API Key",
"getAnthropicApiKey": "Dapatkan Anthropic API Key",

View file

@ -253,6 +253,8 @@
"error": "Impossibile aggiornare l'elenco dei modelli. Riprova."
},
"getRequestyApiKey": "Ottieni chiave API Requesty",
"getRequestyBaseUrl": "URL base",
"requestyUseCustomBaseUrl": "Utilizza URL di base personalizzato",
"openRouterTransformsText": "Comprimi prompt e catene di messaggi alla dimensione del contesto (<a>Trasformazioni OpenRouter</a>)",
"anthropicApiKey": "Chiave API Anthropic",
"getAnthropicApiKey": "Ottieni chiave API Anthropic",

View file

@ -253,6 +253,8 @@
"error": "モデルリストの更新に失敗しました。もう一度お試しください。"
},
"getRequestyApiKey": "Requesty APIキーを取得",
"getRequestyBaseUrl": "ベースURL",
"requestyUseCustomBaseUrl": "カスタムベースURLを使用する",
"openRouterTransformsText": "プロンプトとメッセージチェーンをコンテキストサイズに圧縮 (<a>OpenRouter Transforms</a>)",
"anthropicApiKey": "Anthropic APIキー",
"getAnthropicApiKey": "Anthropic APIキーを取得",

View file

@ -253,6 +253,8 @@
"error": "모델 목록 새로고침에 실패했습니다. 다시 시도해 주세요."
},
"getRequestyApiKey": "Requesty API 키 받기",
"getRequestyBaseUrl": "기본 URL",
"requestyUseCustomBaseUrl": "사용자 정의 기본 URL 사용",
"openRouterTransformsText": "프롬프트와 메시지 체인을 컨텍스트 크기로 압축 (<a>OpenRouter Transforms</a>)",
"anthropicApiKey": "Anthropic API 키",
"getAnthropicApiKey": "Anthropic API 키 받기",

View file

@ -253,6 +253,8 @@
"error": "Kan modellenlijst niet vernieuwen. Probeer het opnieuw."
},
"getRequestyApiKey": "Requesty API-sleutel ophalen",
"getRequestyBaseUrl": "Basis-URL",
"requestyUseCustomBaseUrl": "Gebruik aangepaste basis-URL",
"openRouterTransformsText": "Comprimeer prompts en berichtreeksen tot de contextgrootte (<a>OpenRouter Transforms</a>)",
"anthropicApiKey": "Anthropic API-sleutel",
"getAnthropicApiKey": "Anthropic API-sleutel ophalen",

View file

@ -253,6 +253,8 @@
"error": "Nie udało się odświeżyć listy modeli. Spróbuj ponownie."
},
"getRequestyApiKey": "Uzyskaj klucz API Requesty",
"getRequestyBaseUrl": "Bazowy URL",
"requestyUseCustomBaseUrl": "Użyj niestandardowego bazowego URL",
"openRouterTransformsText": "Kompresuj podpowiedzi i łańcuchy wiadomości do rozmiaru kontekstu (<a>Transformacje OpenRouter</a>)",
"anthropicApiKey": "Klucz API Anthropic",
"getAnthropicApiKey": "Uzyskaj klucz API Anthropic",

View file

@ -253,6 +253,8 @@
"error": "Falha ao atualizar a lista de modelos. Por favor, tente novamente."
},
"getRequestyApiKey": "Obter chave de API Requesty",
"getRequestyBaseUrl": "URL Base",
"requestyUseCustomBaseUrl": "Usar URL base personalizada",
"openRouterTransformsText": "Comprimir prompts e cadeias de mensagens para o tamanho do contexto (<a>Transformações OpenRouter</a>)",
"anthropicApiKey": "Chave de API Anthropic",
"getAnthropicApiKey": "Obter chave de API Anthropic",

View file

@ -253,6 +253,8 @@
"error": "Не удалось обновить список моделей. Пожалуйста, попробуйте снова."
},
"getRequestyApiKey": "Получить Requesty API-ключ",
"getRequestyBaseUrl": "Базовый URL",
"requestyUseCustomBaseUrl": "Использовать пользовательский базовый URL",
"openRouterTransformsText": "Сжимать подсказки и цепочки сообщений до размера контекста (<a>OpenRouter Transforms</a>)",
"anthropicApiKey": "Anthropic API-ключ",
"getAnthropicApiKey": "Получить Anthropic API-ключ",

View file

@ -253,6 +253,8 @@
"error": "Model listesi yenilenemedi. Lütfen tekrar deneyin."
},
"getRequestyApiKey": "Requesty API Anahtarı Al",
"getRequestyBaseUrl": "Temel URL",
"requestyUseCustomBaseUrl": "Özel temel URL kullan",
"openRouterTransformsText": "İstem ve mesaj zincirlerini bağlam boyutuna sıkıştır (<a>OpenRouter Dönüşümleri</a>)",
"anthropicApiKey": "Anthropic API Anahtarı",
"getAnthropicApiKey": "Anthropic API Anahtarı Al",

View file

@ -253,6 +253,8 @@
"error": "Không thể làm mới danh sách mô hình. Vui lòng thử lại."
},
"getRequestyApiKey": "Lấy khóa API Requesty",
"getRequestyBaseUrl": "URL cơ sở",
"requestyUseCustomBaseUrl": "Sử dụng URL cơ sở tùy chỉnh",
"openRouterTransformsText": "Nén lời nhắc và chuỗi tin nhắn theo kích thước ngữ cảnh (<a>OpenRouter Transforms</a>)",
"anthropicApiKey": "Khóa API Anthropic",
"getAnthropicApiKey": "Lấy khóa API Anthropic",

View file

@ -253,6 +253,8 @@
"error": "刷新模型列表失败。请重试。"
},
"getRequestyApiKey": "获取 Requesty API 密钥",
"getRequestyBaseUrl": "基础 URL",
"requestyUseCustomBaseUrl": "使用自定义基础 URL",
"openRouterTransformsText": "自动压缩提示词和消息链到上下文长度限制内 (<a>OpenRouter转换</a>)",
"anthropicApiKey": "Anthropic API 密钥",
"getAnthropicApiKey": "获取 Anthropic API 密钥",

View file

@ -253,6 +253,8 @@
"error": "重新整理模型列表失敗。請再試一次。"
},
"getRequestyApiKey": "取得 Requesty API 金鑰",
"getRequestyBaseUrl": "基礎 URL",
"requestyUseCustomBaseUrl": "使用自訂基礎 URL",
"openRouterTransformsText": "將提示和訊息鏈壓縮到上下文大小 (<a>OpenRouter 轉換</a>)",
"anthropicApiKey": "Anthropic API 金鑰",
"getAnthropicApiKey": "取得 Anthropic API 金鑰",