diff --git a/app/api/302ai.ts b/app/api/302ai.ts
index b4636bcd7be..defd7c719b7 100644
--- a/app/api/302ai.ts
+++ b/app/api/302ai.ts
@@ -22,7 +22,7 @@ export async function handle(
return NextResponse.json({ body: "OK" }, { status: 200 });
}
- const authResult = auth(req, ModelProvider["302.AI"]);
+ const authResult = auth(req, ModelProvider.AI302);
if (authResult.error) {
return NextResponse.json(authResult, {
status: 401,
@@ -42,7 +42,7 @@ async function request(req: NextRequest) {
const controller = new AbortController();
// alibaba use base url or just remove the path
- let path = `${req.nextUrl.pathname}`.replaceAll(ApiPath["302.AI"], "");
+ let path = `${req.nextUrl.pathname}`.replaceAll(ApiPath.AI302, "");
let baseUrl = serverConfig.ai302Url || AI302_BASE_URL;
@@ -91,7 +91,7 @@ async function request(req: NextRequest) {
isModelNotavailableInServer(
serverConfig.customModels,
jsonBody?.model as string,
- ServiceProvider["302.AI"] as string,
+ ServiceProvider.AI302 as string,
)
) {
return NextResponse.json(
diff --git a/app/api/[provider]/[...path]/route.ts b/app/api/[provider]/[...path]/route.ts
index e8af34f29f8..563bb4d2296 100644
--- a/app/api/[provider]/[...path]/route.ts
+++ b/app/api/[provider]/[...path]/route.ts
@@ -53,7 +53,7 @@ async function handle(
return siliconflowHandler(req, { params });
case ApiPath.OpenAI:
return openaiHandler(req, { params });
- case ApiPath["302.AI"]:
+ case ApiPath.AI302:
return ai302Handler(req, { params });
default:
return proxyHandler(req, { params });
diff --git a/app/api/auth.ts b/app/api/auth.ts
index 8c78c70c865..18cb5f53627 100644
--- a/app/api/auth.ts
+++ b/app/api/auth.ts
@@ -104,6 +104,9 @@ export function auth(req: NextRequest, modelProvider: ModelProvider) {
case ModelProvider.SiliconFlow:
systemApiKey = serverConfig.siliconFlowApiKey;
break;
+ case ModelProvider.AI302:
+ systemApiKey = serverConfig.ai302ApiKey;
+ break;
case ModelProvider.GPT:
default:
if (req.nextUrl.pathname.includes("azure/deployments")) {
diff --git a/app/client/api.ts b/app/client/api.ts
index f60b0e2ad71..1a251fdb9dd 100644
--- a/app/client/api.ts
+++ b/app/client/api.ts
@@ -174,7 +174,7 @@ export class ClientApi {
case ModelProvider.SiliconFlow:
this.llm = new SiliconflowApi();
break;
- case ModelProvider["302.AI"]:
+ case ModelProvider.AI302:
this.llm = new Ai302Api();
break;
default:
@@ -269,7 +269,7 @@ export function getHeaders(ignoreHeaders: boolean = false) {
const isChatGLM = modelConfig.providerName === ServiceProvider.ChatGLM;
const isSiliconFlow =
modelConfig.providerName === ServiceProvider.SiliconFlow;
- const isAI302 = modelConfig.providerName === ServiceProvider["302.AI"];
+ const isAI302 = modelConfig.providerName === ServiceProvider.AI302;
const isEnabledAccessControl = accessStore.enabledAccessControl();
const apiKey = isGoogle
? accessStore.googleApiKey
@@ -391,8 +391,8 @@ export function getClientApi(provider: ServiceProvider): ClientApi {
return new ClientApi(ModelProvider.ChatGLM);
case ServiceProvider.SiliconFlow:
return new ClientApi(ModelProvider.SiliconFlow);
- case ServiceProvider["302.AI"]:
- return new ClientApi(ModelProvider["302.AI"]);
+ case ServiceProvider.AI302:
+ return new ClientApi(ModelProvider.AI302);
default:
return new ClientApi(ModelProvider.GPT);
}
diff --git a/app/client/platforms/ai302.ts b/app/client/platforms/ai302.ts
index 7bd18f96d4c..24be64c2ff9 100644
--- a/app/client/platforms/ai302.ts
+++ b/app/client/platforms/ai302.ts
@@ -1,11 +1,6 @@
"use client";
-import {
- ApiPath,
- AI302_BASE_URL,
- DEFAULT_MODELS,
- AI302,
-} from "@/app/constant";
+import { ApiPath, AI302_BASE_URL, DEFAULT_MODELS, AI302 } from "@/app/constant";
import {
useAccessStore,
useAppConfig,
@@ -54,17 +49,14 @@ export class Ai302Api implements LLMApi {
if (baseUrl.length === 0) {
const isApp = !!getClientConfig()?.isApp;
- const apiPath = ApiPath["302.AI"];
+ const apiPath = ApiPath.AI302;
baseUrl = isApp ? AI302_BASE_URL : apiPath;
}
if (baseUrl.endsWith("/")) {
baseUrl = baseUrl.slice(0, baseUrl.length - 1);
}
- if (
- !baseUrl.startsWith("http") &&
- !baseUrl.startsWith(ApiPath["302.AI"])
- ) {
+ if (!baseUrl.startsWith("http") && !baseUrl.startsWith(ApiPath.AI302)) {
baseUrl = "https://" + baseUrl;
}
diff --git a/app/components/settings.tsx b/app/components/settings.tsx
index 881c12caeb3..980f85e924b 100644
--- a/app/components/settings.tsx
+++ b/app/components/settings.tsx
@@ -1459,44 +1459,44 @@ export function Settings() {
>
);
- const ai302ConfigComponent = accessStore.provider === ServiceProvider["302.AI"] && (
+ const ai302ConfigComponent = accessStore.provider ===
+ ServiceProvider.AI302 && (
<>
+
+ accessStore.update(
+ (access) => (access.ai302Url = e.currentTarget.value),
+ )
}
- >
-
- accessStore.update(
- (access) => (access.ai302Url = e.currentTarget.value),
- )
- }
- >
-
-
- {
- accessStore.update(
- (access) => (access.ai302ApiKey = e.currentTarget.value),
- );
- }}
- />
-
- >
+ >
+
+
+ {
+ accessStore.update(
+ (access) => (access.ai302ApiKey = e.currentTarget.value),
+ );
+ }}
+ />
+
+ >
);
return (
diff --git a/app/constant.ts b/app/constant.ts
index db9842d6027..e8485864384 100644
--- a/app/constant.ts
+++ b/app/constant.ts
@@ -74,7 +74,7 @@ export enum ApiPath {
ChatGLM = "/api/chatglm",
DeepSeek = "/api/deepseek",
SiliconFlow = "/api/siliconflow",
- "302.AI" = "/api/302ai",
+ AI302 = "/api/302ai",
}
export enum SlotID {
@@ -133,7 +133,7 @@ export enum ServiceProvider {
ChatGLM = "ChatGLM",
DeepSeek = "DeepSeek",
SiliconFlow = "SiliconFlow",
- "302.AI" = "302.AI",
+ AI302 = "302.AI",
}
// Google API safety settings, see https://ai.google.dev/gemini-api/docs/safety-settings
@@ -160,7 +160,7 @@ export enum ModelProvider {
ChatGLM = "ChatGLM",
DeepSeek = "DeepSeek",
SiliconFlow = "SiliconFlow",
- "302.AI" = "302.AI",
+ AI302 = "302.AI",
}
export const Stability = {
@@ -493,7 +493,7 @@ export const VISION_MODEL_REGEXES = [
/o3/,
/o4-mini/,
/grok-4/i,
- /gpt-5/
+ /gpt-5/,
];
export const EXCLUDE_VISION_MODEL_REGEXES = [/claude-3-5-haiku-20241022/];
@@ -561,7 +561,7 @@ const googleModels = [
"gemini-2.0-pro-exp",
"gemini-2.0-pro-exp-02-05",
"gemini-2.5-pro-preview-06-05",
- "gemini-2.5-pro"
+ "gemini-2.5-pro",
];
const anthropicModels = [
diff --git a/app/store/access.ts b/app/store/access.ts
index fd55fbdd3d1..dac877e56cf 100644
--- a/app/store/access.ts
+++ b/app/store/access.ts
@@ -60,7 +60,7 @@ const DEFAULT_SILICONFLOW_URL = isApp
? SILICONFLOW_BASE_URL
: ApiPath.SiliconFlow;
-const DEFAULT_AI302_URL = isApp ? AI302_BASE_URL : ApiPath["302.AI"];
+const DEFAULT_AI302_URL = isApp ? AI302_BASE_URL : ApiPath.AI302;
const DEFAULT_ACCESS_STATE = {
accessCode: "",