mirror of
https://github.com/stackblitz/bolt.new
synced 2025-06-26 18:17:50 +00:00
13 lines
527 B
TypeScript
13 lines
527 B
TypeScript
import { createOpenAI } from '@ai-sdk/openai';
|
|
import { createAnthropic } from '@ai-sdk/anthropic';
|
|
|
|
export function getModel(provider: 'openai' | 'anthropic', apiKey: string) {
|
|
if (provider === 'openai') {
|
|
const openai = createOpenAI({ apiKey });
|
|
return openai('gpt-4o'); // e.g., 'gpt-4o'
|
|
} else if (provider === 'anthropic') {
|
|
const anthropic = createAnthropic({ apiKey });
|
|
return anthropic('claude-3-5-sonnet-20240620'); // e.g., 'claude-3-opus-20240229'
|
|
}
|
|
throw new Error('Unsupported provider');
|
|
} |