tpmjs/apps/playground/src/env.ts
Ajax Davis cc14476a36 fix: make OPENAI_API_KEY optional for playground to allow client-provided keys
- Make OPENAI_API_KEY optional in env validation
- Move OpenAI client initialization from module level to runtime
- Accept API key from client UI (Settings sidebar) or server env
- Return clear error message if no API key is provided
- Fixes Vercel build failure due to missing env var at build time

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 13:22:23 +10:00

7 lines
223 B
TypeScript

import { createEnv } from '@tpmjs/env';
import { z } from 'zod';
export const env = createEnv({
// Server-only (optional for playground - can be provided by client UI)
OPENAI_API_KEY: z.string().min(1).optional(),
});