File size: 4,221 Bytes
233cefb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/// LLM Provider configuration for Hugging Face supported providers
class LLMProvider {
  final String id;
  final String name;
  final String? apiBaseUrl;
  final String routerBaseUrl;
  final bool supportsHuggingFaceKey;
  final bool isAvailable;

  const LLMProvider({
    required this.id,
    required this.name,
    this.apiBaseUrl,
    required this.routerBaseUrl,
    this.supportsHuggingFaceKey = true,
    this.isAvailable = true,
  });

  /// Create a copy with updated availability
  LLMProvider copyWith({bool? isAvailable}) {
    return LLMProvider(
      id: id,
      name: name,
      apiBaseUrl: apiBaseUrl,
      routerBaseUrl: routerBaseUrl,
      supportsHuggingFaceKey: supportsHuggingFaceKey,
      isAvailable: isAvailable ?? this.isAvailable,
    );
  }

  /// Get the API key label for this provider
  String get apiKeyLabel {
    if (!supportsHuggingFaceKey) {
      return '$name API Key';
    }
    return 'Hugging Face API Key';
  }

  /// List of all supported providers based on HF documentation
  static const List<LLMProvider> supportedProviders = [
    LLMProvider(
      id: 'built-in',
      name: 'Built-in (free, slow)',
      routerBaseUrl: '',
      supportsHuggingFaceKey: false,
    ),
    LLMProvider(
      id: 'cerebras',
      name: 'Cerebras',
      apiBaseUrl: 'https://api.cerebras.ai/v1',
      routerBaseUrl: 'https://router.huggingface.co/cerebras/v1',
    ),
    LLMProvider(
      id: 'cohere',
      name: 'Cohere',
      apiBaseUrl: 'https://api.cohere.com/compatibility/v1',
      routerBaseUrl: 'https://router.huggingface.co/cohere/v1',
    ),
    LLMProvider(
      id: 'fal-ai',
      name: 'Fal AI',
      apiBaseUrl: 'https://api.fal.ai/v1',
      routerBaseUrl: 'https://router.huggingface.co/fal-ai/v1',
    ),
    LLMProvider(
      id: 'featherless',
      name: 'Featherless AI',
      apiBaseUrl: 'https://api.featherless.ai/v1',
      routerBaseUrl: 'https://router.huggingface.co/featherless/v1',
    ),
    LLMProvider(
      id: 'fireworks',
      name: 'Fireworks',
      apiBaseUrl: 'https://api.fireworks.ai/inference/v1',
      routerBaseUrl: 'https://router.huggingface.co/fireworks/v1',
    ),
    LLMProvider(
      id: 'groq',
      name: 'Groq',
      apiBaseUrl: 'https://api.groq.com/openai/v1',
      routerBaseUrl: 'https://router.huggingface.co/groq/v1',
    ),
    LLMProvider(
      id: 'hf-inference',
      name: 'HF Inference',
      apiBaseUrl: 'https://api-inference.huggingface.co/v1',
      routerBaseUrl: 'https://router.huggingface.co/hf-inference/v1',
    ),
    LLMProvider(
      id: 'hyperbolic',
      name: 'Hyperbolic',
      apiBaseUrl: 'https://api.hyperbolic.xyz/v1',
      routerBaseUrl: 'https://router.huggingface.co/hyperbolic/v1',
    ),
    LLMProvider(
      id: 'nebius',
      name: 'Nebius',
      apiBaseUrl: 'https://api.studio.nebius.ai/v1',
      routerBaseUrl: 'https://router.huggingface.co/nebius/v1',
    ),
    LLMProvider(
      id: 'novita',
      name: 'Novita',
      apiBaseUrl: 'https://api.novita.ai/v3/openai',
      routerBaseUrl: 'https://router.huggingface.co/novita/v1',
    ),
    LLMProvider(
      id: 'nscale',
      name: 'Nscale',
      apiBaseUrl: 'https://inference.api.nscale.com/v1',
      routerBaseUrl: 'https://router.huggingface.co/nscale/v1',
    ),
    LLMProvider(
      id: 'replicate',
      name: 'Replicate',
      apiBaseUrl: 'https://api.replicate.com/v1',
      routerBaseUrl: 'https://router.huggingface.co/replicate/v1',
    ),
    LLMProvider(
      id: 'sambanova',
      name: 'SambaNova',
      apiBaseUrl: 'https://api.sambanova.ai/v1',
      routerBaseUrl: 'https://router.huggingface.co/sambanova/v1',
    ),
    LLMProvider(
      id: 'together',
      name: 'Together',
      apiBaseUrl: 'https://api.together.xyz/v1',
      routerBaseUrl: 'https://router.huggingface.co/together/v1',
    ),
  ];

  /// Get provider by ID
  static LLMProvider? getById(String id) {
    try {
      return supportedProviders.firstWhere((provider) => provider.id == id);
    } catch (e) {
      return null;
    }
  }

  /// Get default provider
  static LLMProvider get defaultProvider {
    return supportedProviders.first; // Built-in is first in the list
  }
}