File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { createOpenAI } from "@ai-sdk/openai" ;
22import { createGoogleGenerativeAI } from "@ai-sdk/google" ;
3+ import { createOpenAICompatible } from "@ai-sdk/openai-compatible" ;
34import { streamText , UIMessage , convertToModelMessages } from "ai" ;
45
56// Allow streaming responses up to 30 seconds
@@ -22,12 +23,12 @@ export async function POST(req: Request) {
2223 content ?: string ;
2324 slug ?: string ;
2425 } ;
25- provider ?: "openai" | "gemini" ;
26+ provider ?: "openai" | "gemini" | "intern" ;
2627 apiKey ?: string ;
2728 } = await req . json ( ) ;
2829
29- // Check if API key is provided
30- if ( ! apiKey || apiKey . trim ( ) === "" ) {
30+ // Check if API key is provided (not required for intern provider)
31+ if ( provider !== "intern" && ( ! apiKey || apiKey . trim ( ) === "" ) ) {
3132 return Response . json (
3233 {
3334 error :
@@ -68,6 +69,13 @@ export async function POST(req: Request) {
6869 apiKey : apiKey ,
6970 } ) ;
7071 model = customGoogle ( "models/gemini-2.0-flash" ) ;
72+ } else if ( provider === "intern" ) {
73+ const intern = createOpenAICompatible ( {
74+ name : "intern" ,
75+ baseURL : "https://chat.intern-ai.org.cn/api/v1/" ,
76+ apiKey : process . env . INTERN_KEY ,
77+ } ) ;
78+ model = intern ( "intern-s1" ) ;
7179 } else {
7280 // Default to OpenAI
7381 const customOpenAI = createOpenAI ( {
You can’t perform that action at this time.
0 commit comments