Text Generation
Generates website copy using gpt-4o-mini with a system prompt tailored for conversion-focused copywriting.
Honeycomb uses the OpenAI API for AI-powered content features in the site builder and AI docs apps. All calls are server-side only — the API key never reaches the browser.
The OpenAI client is a lazy singleton in src/lib/modules/sitebuilder/services/ai.service.ts:
import OpenAI from "openai";import { OPENAI_API_KEY } from "$env/static/private";
let _openai: OpenAI | null = null;function openai(): OpenAI { if (!_openai) { _openai = new OpenAI({ apiKey: OPENAI_API_KEY }); } return _openai;}A separate Supabase service-role client writes usage records to the ext_builder.ai_generations table.
Text Generation
Generates website copy using gpt-4o-mini with a system prompt tailored for conversion-focused copywriting.
Text Modification
Simplify, shorten, lengthen, fix spelling, change tone, or translate existing text.
Image Generation
Creates images via DALL-E 3 with configurable size and style (vivid or natural).
Usage Tracking
Every generation is logged with token count, model, prompt, and response for billing and audit.
export async function generateText( userId: string, prompt: string, context?: string,): Promise<{ text: string; tokensUsed: number }>gpt-4o-minicontext parameter injects background about the website before the user’s prompt.export async function modifyText( userId: string, text: string, action: AiModifyAction, params?: { tone?: AiTone; language?: string },): Promise<{ text: string; tokensUsed: number }>Supported actions:
| Action | Description |
|---|---|
simplify | Make text easier to understand |
shorten | Condense while keeping the key message |
lengthen | Expand with more detail |
fix_spelling | Correct spelling, grammar, and punctuation |
change_tone | Rewrite in a specified tone (requires params.tone) |
translate | Translate to a target language (requires params.language) |
gpt-4o-miniexport async function generateImage( userId: string, prompt: string, size?: "1024x1024" | "1792x1024" | "1024x1792", style?: "vivid" | "natural",): Promise<{ url: string }>The returned URL is a temporary Stripe-hosted image. The caller is responsible for downloading and storing it in Supabase Storage if persistence is needed.
Every call writes a row to ext_builder.ai_generations:
| Column | Description |
|---|---|
user_id | The authenticated user |
type | generate_text, modify_text, generate_image, or modify_image |
prompt | The input prompt or action description |
response | Generated text or image URL |
tokens_used | Total tokens consumed (1 for image generations) |
model | Model identifier (gpt-4o-mini, dall-e-3) |
// Get paginated generation historyawait listAiGenerations(userId, { limit: 25, offset: 0 });
// Get current month statsawait getUsageStats(userId);// Returns: { text_tokens_used, image_count, period_start }The AI Docs app (src/lib/apps/aidocs) supports multiple model providers. The model constants are defined in src/lib/apps/aidocs/constants.ts:
export const AI_MODELS = [ "gpt-4o", "gpt-4o-mini", "gpt-4-turbo", "gpt-3.5-turbo", "claude-sonnet-4-20250514", "claude-haiku-4-5-20251001", "gemini-2.5-pro", "gemini-2.5-flash",] as const;
export const DEFAULT_MODEL = "gpt-4o" as const;| File | Purpose |
|---|---|
src/lib/modules/sitebuilder/services/ai.service.ts | OpenAI client, text/image generation, usage tracking |
src/lib/apps/aidocs/constants.ts | Multi-provider model list and defaults |