Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# AI provider — set one of the following depending on studio.ai.provider:
# - GROQ_API_KEY for Groq (free tier via GroqCloud, works in all regions)
# - NUXT_STUDIO_AI_API_KEY for Vercel AI Gateway
# - GEMINI_API_KEY for Google Gemini (region-limited free tier)
GROQ_API_KEY=
NUXT_STUDIO_AI_API_KEY=
GEMINI_API_KEY=
NUXT_STUDIO_AI_GEMINI_API_KEY=

# If using GitHub provider
STUDIO_GITHUB_CLIENT_ID=
STUDIO_GITHUB_CLIENT_SECRET=
Expand All @@ -11,7 +20,6 @@ STUDIO_GITLAB_MODERATORS=
STUDIO_GOOGLE_CLIENT_ID=
STUDIO_GOOGLE_CLIENT_SECRET=
STUDIO_GOOGLE_MODERATORS=user@domain.com,user2@domain.com

# If using GitHub provider with Google Oauth
STUDIO_GITHUB_TOKEN=

Expand Down
55 changes: 48 additions & 7 deletions docs/content/7.ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ navigation:
icon: i-lucide-sparkles
seo:
title: AI Content Assistance - Nuxt Studio
description: Enable Claude-powered AI features in Nuxt Studio for smart content completion, grammar fixes, improvements, and translation using Vercel AI Gateway.
description: Enable AI-powered features in Nuxt Studio for smart content completion, grammar fixes, improvements, and translation using Groq, Google Gemini, or Vercel AI Gateway.
---

Nuxt Studio integrates AI-powered content assistance using models via Vercel AI Gateway. These features help you write, improve, and transform content faster with intelligent suggestions and transformations.
Nuxt Studio integrates AI-powered content assistance supporting GroqCloud, Google Gemini, and Vercel AI Gateway. These features help you write, improve, and transform content faster with intelligent suggestions and transformations.

::video
---
Expand All @@ -21,7 +21,7 @@ src: https://res.cloudinary.com/nuxt/video/upload/v1770661582/studio/studio-ai_b
::

::note{type="info"}
AI features are optional and require a Vercel AI Gateway API key. Vercel provides $5 in free credits, which is typically sufficient for most editing scenarios over several days.
AI features are optional. They require either a Vercel AI Gateway API key, a Groq API key, or a Google Gemini API key. Vercel provides $5 in free credits, which is typically sufficient for most editing scenarios over several days.
::

## Configuration
Expand All @@ -46,13 +46,54 @@ Generate a new API key from the AI Gateway dashboard.

### Set Environment Variable

To enable AI-powered editing in Studio, simply set the `NUXT_STUDIO_AI_API_KEY` environment variable.
To enable AI-powered editing in Studio, set one of the following environment variables:

```bash [.env]
NUXT_STUDIO_AI_API_KEY=your_vercel_ai_gateway_api_key
```

### Contextualization
### Groq (free, works in all regions)

[GroqCloud](https://console.groq.com) offers a generous **free tier** for Llama, Gemma, and Qwen models, works in all regions, and does not require a credit card.

```bash [.env]
GROQ_API_KEY=your_groq_api_key
```

### Google Gemini

Nuxt Studio also supports Google Gemini as the AI provider without Vercel.

```bash [.env]
GEMINI_API_KEY=your_google_ai_studio_api_key
```

`NUXT_STUDIO_AI_GEMINI_API_KEY` is also accepted. You can create a key at [Google AI Studio](https://aistudio.google.com/apikey). Note that the Gemini free tier is not available in all regions.

#### Choosing a Provider

The provider is selected with the `provider` option on `studio.ai`:

- `auto` (default): uses Groq when `GROQ_API_KEY` is set, then Gemini, then Vercel AI Gateway.
- `gateway`: always uses Vercel AI Gateway.
- `gemini`: always uses Google Gemini.
- `groq`: always uses Groq.

```ts [nuxt.config.ts]
export default defineNuxtConfig({
studio: {
ai: {
provider: 'groq', // or 'gateway' / 'gemini' / 'auto'
groqModel: 'llama-3.3-70b-versatile',
groqFastModel: 'llama-3.1-8b-instant',
geminiModel: 'gemini-2.0-flash',
geminiFastModel: 'gemini-2.0-flash-lite',
},
},
})
```

#### Contextualization

You can then configure AI behavior in your `nuxt.config.ts` file to provide contextual guidance and ensure the AI output aligns with your preferred writing style.

Expand Down Expand Up @@ -83,7 +124,7 @@ AI Completion provides intelligent text suggestions as you type in the TipTap vi
- **Manual trigger**: Press `Cmd/Ctrl+J` to request a suggestion anytime
- **Accept**: Press `Tab` to insert the suggestion
- **Dismiss**: Press `Escape` or continue typing to ignore
- Powered by **Claude Haiku 4.5** for fast responses (~300-500ms)
- Powered by a fast model (Claude Haiku 4.5 via Vercel AI Gateway, or `geminiFastModel` via Gemini / `groqFastModel` via Groq) for quick responses
- **Toggle On/Off:** Click the sparkles ✨ button in the footer toolbar to enable/disable AI completion

### AI Transform
Expand All @@ -103,7 +144,7 @@ Transform selected text with AI-powered improvements, fixes, translations, and s
- **Select** a mode from the dropdown menu
- **Review** the proposed changes in the preview pane before applying them.
- **Accept or decline** the AI proposition
- Powered by **Claude Sonnet 4.5** for high-quality results
- Powered by a quality model (Claude Sonnet 4.5 via Vercel AI Gateway, or `geminiModel` via Gemini / `groqModel` via Groq) for high-quality results

### Contextualization

Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
],
"main": "./dist/module/module.mjs",
"scripts": {
"prepack": "nuxt-module-build build src/module; vite build src/app",
"dev": "pnpm run dev:prepare && STUDIO_DEV_SERVER=http://localhost:5151 nuxi dev playground/docus",
"dev:minimal": "pnpm run dev:prepare && STUDIO_DEV_SERVER=http://localhost:5151 nuxt dev playground/minimal",
"prepack": "nuxt-module-build build src/module && vite build src/app",
"dev": "pnpm run dev:prepare && pnpm run dev:docus",
"dev:docus": "STUDIO_DEV_SERVER=http://localhost:5151 nuxi dev playground/docus",
"dev:minimal": "pnpm run dev:prepare && pnpm run dev:minimal:serve",
"dev:minimal:serve": "STUDIO_DEV_SERVER=http://localhost:5151 nuxt dev playground/minimal",
"dev:app": "vite src/app --port 5151",
"dev:docs": "nuxt dev docs",
"dev:prepare": "nuxt-module-build build --stub src/module && nuxt-module-build prepare src/module && nuxi prepare playground/docus && nuxi prepare docs",
Expand All @@ -51,6 +53,8 @@
"ipx": "^3.1.1"
},
"dependencies": {
"@ai-sdk/groq": "^3.0.0",
"@ai-sdk/google": "^3.0.0",
"@ai-sdk/gateway": "^3.0.126",
"@ai-sdk/vue": "^3.0.198",
"@iconify-json/lucide": "^1.2.111",
Expand Down
66 changes: 66 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 57 additions & 5 deletions src/module/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ interface EditorOptions {
interface MediaUploadOptions {
/**
* Enable external storage for media uploads.
* When enabled, media files are uploaded to cloud storage (S3, Vercel Blob, Cloudflare R2, etc.)
* instead of being committed to Git. NuxtHub auto-detects the driver from environment variables.
* When enabled, media files are uploaded to cloud storage (S3, Vercel Blob, Cloudflare R2, Cloudinary, etc.)
* instead of being committed to Git.
*
* @default false
*/
Expand Down Expand Up @@ -157,13 +157,58 @@ export interface ModuleOptions {
* AI-powered content generation settings.
*/
ai?: {
/**
* The AI provider used for content generation.
*
* - `auto` (default): uses Groq when a Groq API key is set, then Gemini,
* then the Vercel AI Gateway.
* - `gateway`: always uses the Vercel AI Gateway (`apiKey`).
* - `gemini`: always uses the Google Gemini API (`geminiApiKey`).
* - `groq`: always uses the Groq API (`groqApiKey`) with Llama/Gemma/Qwen models.
*
* @default 'auto'
*/
provider?: 'auto' | 'gateway' | 'gemini' | 'groq'
/**
* The Groq API key for AI features (free tier via GroqCloud).
* Set via `GROQ_API_KEY` environment variable at runtime.
*/
groqApiKey?: string
/**
* The Groq model to use for quality transforms.
* @default 'llama-3.3-70b-versatile'
*/
groqModel?: string
/**
* The Groq model to use for quick/continue completions.
* @default 'llama-3.1-8b-instant'
*/
groqFastModel?: string
/**
* The Vercel AI Gateway key for AI features.
* When set, AI-powered content generation will be enabled.
*
* Set via `NUXT_STUDIO_AI_API_KEY` environment variable at runtime.
*/
apiKey?: string
/**
* The Google Gemini API key for AI features.
* When set (and provider is not explicitly `gateway`), AI-powered content
* generation uses the Gemini API directly.
*
* Set via `GEMINI_API_KEY` or `NUXT_STUDIO_AI_GEMINI_API_KEY` environment variable at runtime.
*/
geminiApiKey?: string
/**
* The Google Gemini model to use.
* @default 'gemini-2.0-flash'
*/
geminiModel?: string
/**
* The Google Gemini model to use for quick/continue completions.
* @default 'gemini-2.0-flash-lite'
*/
geminiFastModel?: string
/**
* Contextual information to guide AI content generation.
*/
Expand Down Expand Up @@ -518,7 +563,6 @@ export default defineNuxtModule<ModuleOptions>({
options.media!.publicUrl = resolve(nuxt.options.rootDir, 'public')
}

// Public runtime config
nuxt.options.runtimeConfig.public.studio = {
route: options.route!,
dev: Boolean(options.dev),
Expand All @@ -527,8 +571,9 @@ export default defineNuxtModule<ModuleOptions>({
},
ai: {
// Honest build-time baseline; the studio-env middleware recomputes this at runtime
// once NUXT_STUDIO_AI_API_KEY is resolved.
enabled: Boolean(options.ai?.apiKey),
// once the API keys are resolved.
enabled: Boolean(options.ai?.apiKey || options.ai?.geminiApiKey || options.ai?.groqApiKey),
provider: options.ai?.provider || 'auto',
context: {
collectionName: options.ai?.context?.collection?.name as string,
contentFolder: options.ai?.context?.collection?.folder as string,
Expand All @@ -552,6 +597,13 @@ export default defineNuxtModule<ModuleOptions>({
nuxt.options.runtimeConfig.studio = {
ai: {
apiKey: options.ai?.apiKey || '',
geminiApiKey: options.ai?.geminiApiKey || '',
geminiModel: options.ai?.geminiModel || 'gemini-2.0-flash',
geminiFastModel: options.ai?.geminiFastModel || 'gemini-2.0-flash-lite',
groqApiKey: options.ai?.groqApiKey || '',
groqModel: options.ai?.groqModel || 'llama-3.3-70b-versatile',
groqFastModel: options.ai?.groqFastModel || 'llama-3.1-8b-instant',
provider: options.ai?.provider || 'auto',
context: options.ai?.context as never,
experimental: options.ai?.experimental,
},
Expand Down
Loading
Loading