/**
 * Anthropic Provider Definition
 */

import { createAnthropic } from '@ai-sdk/anthropic';
import type { ProviderInfo, ProviderFactory } from '../types.js';

export const anthropicProvider: ProviderInfo = {
  id: 'anthropic',
  name: 'Anthropic',
  description: 'Claude AI models by Anthropic',
  builtin: true,
  apiKeyEnvVar: 'ANTHROPIC_API_KEY',
  models: [
    {
      id: 'claude-sonnet-4-20250514',
      name: 'Claude Sonnet 4',
      capabilities: { vision: true, functionCalling: true, streaming: true },
      contextWindow: 200000,
      maxOutput: 8192,
    },
    {
      id: 'claude-3-5-sonnet-20241022',
      name: 'Claude 3.5 Sonnet',
      capabilities: { vision: true, functionCalling: true, streaming: true },
      contextWindow: 200000,
      maxOutput: 8192,
    },
    {
      id: 'claude-3-opus-20240229',
      name: 'Claude 3 Opus',
      capabilities: { vision: true, functionCalling: true, streaming: true },
      contextWindow: 200000,
      maxOutput: 4096,
    },
    {
      id: 'claude-3-haiku-20240307',
      name: 'Claude 3 Haiku',
      capabilities: { vision: true, functionCalling: true, streaming: true },
      contextWindow: 200000,
      maxOutput: 4096,
    },
  ],
  allowCustomModels: true,
};

export const anthropicFactory: ProviderFactory = ({ apiKey, baseUrl }) => {
  const client = createAnthropic({ apiKey, baseURL: baseUrl });
  return (model) => client(model);
};
