35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
|
|
import { createAnthropic } from '@ai-sdk/anthropic';
|
|
import { generateText } from 'ai';
|
|
import 'dotenv/config';
|
|
|
|
// 使用 custom-kevisual provider (聚合了多个模型)
|
|
const kevisual = createOpenAICompatible({
|
|
baseURL: 'https://newapi.kevisual.cn/v1',
|
|
name: 'custom-kevisual',
|
|
apiKey: process.env.KEVISUAL_NEW_API_KEY!,
|
|
});
|
|
|
|
const kevisualAnthropic = createAnthropic({
|
|
baseURL: "https://newapi.kevisual.cn/v1",
|
|
apiKey: process.env.KEVISUAL_NEW_API_KEY!,
|
|
})
|
|
|
|
// 测试所有可用模型
|
|
// const models = ['qwen3-coder-plus', 'ark-code-latest', 'GLM-4.7', 'MiniMax-M2.1'];
|
|
const models = ['MiniMax-M2.5'];
|
|
|
|
for (const model of models) {
|
|
console.log(`\n=== Testing model: ${model} ===`);
|
|
try {
|
|
const { text } = await generateText({
|
|
// model: kevisualAnthropic(model),
|
|
model: kevisual(model),
|
|
prompt: 'Say hello in one sentence.',
|
|
});
|
|
console.log(`Response: ${text}`);
|
|
} catch (error) {
|
|
console.error(`Error: ${error}`);
|
|
}
|
|
}
|