.env · generator · OpenAI

OpenAI .env Generator

Most AI apps use OpenAI + at least one vector DB. This generator produces a .env covering OpenAI, Anthropic, and Pinecone — the default AI stack for 2026.

.env for OpenAI · 5 keys
Customize →
OPENAI_API_KEY=sk-
ANTHROPIC_API_KEY=sk-ant-
OPENAI_MODEL=gpt-4o-mini
PINECONE_API_KEY=
PINECONE_INDEX=

Secrets regenerate on every page load. Want to combine stacks (e.g., Next.js + Stripe + Supabase)? Use the full generator.

How to use this .env in OpenAI

  1. 1.Generate OpenAI keys at platform.openai.com/api-keys — use a scoped key per project.
  2. 2.Generate Anthropic keys at console.anthropic.com → API Keys.
  3. 3.Paste everything into .env.local. OPENAI_MODEL is a runtime knob, not a key — you'll swap this often.
  4. 4.For Next.js, keep these server-only — prefixing with NEXT_PUBLIC_ would expose them in every bundle.

Gotchas

  • OpenAI keys are billed per-request — set per-project spend limits in the dashboard.
  • Never use OPENAI_API_KEY directly in client code. Proxy via an API route.
  • Rate-limit your endpoint so a leaked key doesn't drain your budget in minutes.

Common keys explained

OPENAI_API_KEY

sk-... — used by the OpenAI SDK. Server-only.

OPENAI_MODEL

gpt-4o-mini, gpt-4o, etc. Optional but handy for A/B tests.

ANTHROPIC_API_KEY

sk-ant-... — Anthropic SDK.

PINECONE_API_KEY

Pinecone vector DB key.

PINECONE_INDEX

Pinecone index name for your embeddings.

Related tools

Other stacks