bolt.new/app/lib/.server/llm/model.ts
2025-04-30 15:07:21 +05:30

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');
}