- Add README.md with installation and usage instructions. - Create bun.lock and pnpm-lock.yaml for dependency management. - Implement main functionality in index.ts to test AI providers. - Add opencode.json configuration for various AI providers. - Create package.json to define project dependencies and scripts. - Add TypeScript configuration in tsconfig.json for project setup. - Implement test scripts for different AI providers in src directory.
24 lines
728 B
TypeScript
24 lines
728 B
TypeScript
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
|
|
import { createAnthropic } from '@ai-sdk/anthropic';
|
|
import { generateText } from 'ai';
|
|
import 'dotenv/config';
|
|
|
|
// 尝试不同的端点配置
|
|
const bailian = createOpenAICompatible({
|
|
baseURL: 'https://coding.dashscope.aliyuncs.com/v1',
|
|
name: 'custom-bailian',
|
|
apiKey: process.env.BAILIAN_CODE_API_KEY!,
|
|
});
|
|
// const bailian = createAnthropic({
|
|
// baseURL: 'https://coding.dashscope.aliyuncs.com/apps/anthropic/messages',
|
|
// name: 'custom-bailian',
|
|
// apiKey: process.env.BAILIAN_CODE_API_KEY!,
|
|
// });
|
|
|
|
const { text } = await generateText({
|
|
model: bailian('qwen3-coder-plus'),
|
|
prompt: 'What is an agent?',
|
|
});
|
|
|
|
console.log('Response:', text);
|