An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
feat: add xAI (Grok) provider and models
Yoshiki Miura934b3af91123
diff --git a/.env.local.example b/.env.local.exampleindex fe96ae10..2efd5794 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.mdindex 49a3446e..2da1208d 100644--- a/README.md+++ b/README.md@@ -208,6 +208,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 Implementationdiff --git a/bun.lockb b/bun.lockbindex c09aac26..a501ffb5 100755Binary files a/bun.lockb and b/bun.lockb differdiff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.mdindex 188403f2..1e21f4a6 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 Featurediff --git a/lib/types/models.ts b/lib/types/models.tsindex 92abbd58..06c1a7fc 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.tsindex ab2f1b33..64484bdc 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_KEYcase 'fireworks':return !!process.env.FIREWORKS_API_KEY+ case 'xai':+ return !!process.env.XAI_API_KEYcase 'openai-compatible':return (!!process.env.OPENAI_COMPATIBLE_API_KEY &&diff --git a/package.json b/package.jsonindex 65cc2a2b..780e2ec9 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.svgnew file mode 100644index 00000000..74af63dd--- /dev/null+++ b/public/providers/logos/xai.svg@@ -0,0 +1,7 @@+<?xml version="1.0" encoding="UTF-8"?>+<svg width="727.27" height="778.68" version="1.1" viewBox="0 0 727.27 778.68" xmlns="http://www.w3.org/2000/svg">+ <polygon transform="translate(-134,-113.32)" points="508.67 574.07 761.27 213.32 639.19 213.32 447.64 486.9"/>+ <polygon transform="translate(-134,-113.32)" points="356.08 792 417.12 704.83 356.08 617.66 234 792"/>+ <polygon transform="translate(-134,-113.32)" points="508.67 792 630.75 792 356.08 399.72 234 399.72"/>+ <polygon transform="translate(-134,-113.32)" points="761.27 256.91 661.27 399.72 671.27 792 751.27 792"/>+</svg>