diff --git a/.env.local.example b/.env.local.example index fe96ae10b..2efd57945 100644 --- a/.env.local.example +++ b/.env.local.example @@ -60,6 +60,9 @@ TAVILY_API_KEY=[YOUR_TAVILY_API_KEY] # Get your API key at: https://app.tavily. # Fireworks # FIREWORKS_API_KEY=[YOUR_FIREWORKS_API_KEY] +# xAI (Grok) +# XAI_API_KEY=[YOUR_XAI_API_KEY] + # OpenAI Compatible Model # NEXT_PUBLIC_OPENAI_COMPATIBLE_MODEL= # OPENAI_COMPATIBLE_API_KEY= diff --git a/README.md b/README.md index 688be7335..3b17c4a03 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,9 @@ This will allow you to use Morphic as your default search engine in the browser. - DeepSeek - DeepSeek V3 - DeepSeek R1 +- xAI + - grok-2 + - grok-2-vision ## ⚡ AI SDK Implementation diff --git a/bun.lockb b/bun.lockb index c09aac26b..a501ffb5e 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index 188403f28..1e21f4a6a 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -165,6 +165,12 @@ NEXT_PUBLIC_AZURE_DEPLOYMENT_NAME=[YOUR_DEPLOYMENT_NAME] # FIREWORKS_API_KEY=[YOUR_API_KEY] ``` +### xAI + +```bash +XAI_API_KEY=[YOUR_XAI_API_KEY] +``` + ## Other Features ### Share Feature diff --git a/lib/types/models.ts b/lib/types/models.ts index 92abbd589..06c1a7fc2 100644 --- a/lib/types/models.ts +++ b/lib/types/models.ts @@ -95,5 +95,17 @@ export const models: Model[] = [ name: process.env.NEXT_PUBLIC_OPENAI_COMPATIBLE_MODEL || 'Undefined', provider: 'OpenAI Compatible', providerId: 'openai-compatible' + }, + { + id: 'grok-2-1212', + name: 'Grok 2', + provider: 'xAI', + providerId: 'xai' + }, + { + id: 'grok-2-vision-1212', + name: 'Grok 2 Vision', + provider: 'xAI', + providerId: 'xai' } ] diff --git a/lib/utils/registry.ts b/lib/utils/registry.ts index ab2f1b335..64484bdc8 100644 --- a/lib/utils/registry.ts +++ b/lib/utils/registry.ts @@ -5,6 +5,7 @@ import { createFireworks, fireworks } from '@ai-sdk/fireworks' import { google } from '@ai-sdk/google' import { groq } from '@ai-sdk/groq' import { createOpenAI, openai } from '@ai-sdk/openai' +import { xai } from '@ai-sdk/xai' import { experimental_createProviderRegistry as createProviderRegistry, extractReasoningMiddleware, @@ -34,7 +35,8 @@ export const registry = createProviderRegistry({ 'openai-compatible': createOpenAI({ apiKey: process.env.OPENAI_COMPATIBLE_API_KEY, baseURL: process.env.OPENAI_COMPATIBLE_API_BASE_URL - }) + }), + xai }) export function getModel(model: string) { @@ -102,6 +104,8 @@ export function isProviderEnabled(providerId: string): boolean { return !!process.env.DEEPSEEK_API_KEY case 'fireworks': return !!process.env.FIREWORKS_API_KEY + case 'xai': + return !!process.env.XAI_API_KEY case 'openai-compatible': return ( !!process.env.OPENAI_COMPATIBLE_API_KEY && diff --git a/package.json b/package.json index 65cc2a2be..780e2ec9f 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "@ai-sdk/google": "^1.1.5", "@ai-sdk/groq": "^1.1.6", "@ai-sdk/openai": "^1.1.5", + "@ai-sdk/xai": "^1.1.10", "@radix-ui/react-alert-dialog": "^1.0.5", "@radix-ui/react-avatar": "^1.0.4", "@radix-ui/react-checkbox": "^1.0.4", diff --git a/public/providers/logos/xai.svg b/public/providers/logos/xai.svg new file mode 100644 index 000000000..74af63dd0 --- /dev/null +++ b/public/providers/logos/xai.svg @@ -0,0 +1,7 @@ + + + + + + +