fix: using baseURL to fetch models and get API key (#5732)

* fix: using baseURL to fetch models and get API key

* change set

* fix: keeping /v1 in URL

This is because `URL` constructor, strips the path when giving two
arguments.
This commit is contained in:
John Costa authored and GitHub committed 2025-09-11 19:52:42 -07:00
1 parent c3591290d2
commit 6b9dbccfd2
6 files changed
+128 -77

No files matched your search

+2 -2
View File
@@ -2,6 +2,7 @@ import { Anthropic } from "@anthropic-ai/sdk"
import { ModelInfo, requestyDefaultModelId, requestyDefaultModelInfo } from "@shared/api"
import { calculateApiCostOpenAI } from "@utils/cost"
import OpenAI from "openai"
import { toRequestyServiceStringUrl } from "@/shared/providers/requesty"
import { ApiHandler, CommonApiHandlerOptions } from "../index"
import { withRetry } from "../retry"
import { convertToOpenAiMessages } from "../transform/openai-format"
@@ -41,7 +42,7 @@ export class RequestyHandler implements ApiHandler {
}
try {
this.client = new OpenAI({
baseURL: this.options.requestyBaseUrl || "https://router.requesty.ai/v1",
baseURL: toRequestyServiceStringUrl(this.options.requestyBaseUrl),
apiKey: this.options.requestyApiKey,
defaultHeaders: {
"HTTP-Referer": "https://cline.bot",
@@ -82,7 +83,6 @@ export class RequestyHandler implements ApiHandler {
? thinking
: {}
// @ts-ignore-next-line
const stream = await client.chat.completions.create({
model: model.id,
max_tokens: model.info.maxTokens || undefined,