# CodeVinci — copy to .env and fill OPENAI_API_KEY
# ============================================================================
# App
# ============================================================================
# Local server port (default 3847)
PORT=3847
# Vite dev HMR WebSocket port (default 24678). Change if port is already in use.
HMR_PORT=24679
# Open browser on startup (default true)
OPEN_BROWSER=true
# ============================================================================
# Deepgram STT (Voice Mode)
# ============================================================================
# Required for voice mode speech-to-text
DEEPGRAM_API_KEY=
# Nova-3 supports Chinese (zh). Flux is English-only.
DEEPGRAM_MODEL=nova-3
DEEPGRAM_LANGUAGE=zh
# Silence before speech_final (ms). Increase if users pause mid-sentence.
DEEPGRAM_ENDPOINTING=300
# Word-gap before UtteranceEnd (ms). Minimum 1000 recommended by Deepgram.
DEEPGRAM_UTTERANCE_END_MS=1000
# Max wait for Deepgram WebSocket to open (ms)
DEEPGRAM_CONNECT_TIMEOUT_MS=15000
# Set STT_DEBUG=true for verbose STT logs (or LOG_LEVEL=debug)
# STT_DEBUG=true
# Dump LLM request/response to terminal (also auto-enabled in dev). Copy blocks labeled LLM DUMP when debugging.
# LLM_DEBUG=true
# ============================================================================
# LLM Configuration
# ============================================================================
# API transport format
# openai -> OpenAI-compatible chat.completions (default)
# anthropic -> Anthropic Messages API (/v1/messages)
API_FORMAT=openai
# Model id as returned by the provider
# CodeVinci sends design images — use a VISION model (e.g. glm-5v-turbo), not text-only models (glm-5.1, glm-5.1-highspeed).
MODEL_NAME=
# --------------------------------------------------------------------------
# OpenAI-compatible (API_FORMAT=openai)
# --------------------------------------------------------------------------
# API Key (required when API_FORMAT=openai)
OPENAI_API_KEY=
# Base URL (no /chat/completions suffix)
# OpenRouter: https://openrouter.ai/api/v1
OPENAI_BASE_URL=
# --------------------------------------------------------------------------
# Anthropic (API_FORMAT=anthropic)
# --------------------------------------------------------------------------
# API Key (required when API_FORMAT=anthropic)
ANTHROPIC_API_KEY=
# Official: https://api.anthropic.com
# Some proxies/gateways also expose Anthropic format at a custom base URL.
ANTHROPIC_BASE_URL=https://api.anthropic.com
# Messages API version header (anthropic-version)
ANTHROPIC_VERSION=2023-06-01
# Example anthropic setup (text models only — NOT for CodeVinci render):
# API_FORMAT=anthropic
# ANTHROPIC_API_KEY=your-zhipu-key
# ANTHROPIC_BASE_URL=https://open.bigmodel.cn/api/anthropic
# MODEL_NAME=glm-5.1
# Example Zhipu vision setup (recommended for CodeVinci):
# API_FORMAT=openai
# OPENAI_API_KEY=your-zhipu-key
# OPENAI_BASE_URL=https://open.bigmodel.cn/api/paas/v4
# MODEL_NAME=glm-5v-turbo
# USER_AGENT=KimiCLI/1.34.0
# THINKING_MODE — OpenAI-compatible providers only (ignored when API_FORMAT=anthropic)
# When not "false", reasoning/thinking text is wrapped in ... in saved output.
#
# openai -> extra_body: {"thinking": {"type": "enabled"}}
# Z.AI GLM (matches official curl thinking.type).
#
# kimi -> extra_body: {"enable_thinking": true}
# Moonshot / Kimi-style APIs.
#
# gemini -> extra_body: {"reasoning": {"enabled": true}}
# Plus REASONING_EFFORT as nested reasoning.effort when URL uses OpenRouter transport.
#
# openrouter -> extra_body: {"reasoning": {"effort": ""}} if REASONING_EFFORT set
# (THINKING_MODE=openrouter maps max -> xhigh; see OpenRouter reasoning-tokens docs),
# else {"reasoning": {"enabled": true}}.
#
# false -> no thinking / reasoning payload
THINKING_MODE=openai
# REASONING_EFFORT — optional. Empty with THINKING_MODE=openrouter enables reasoning via enabled only.
# OpenRouter: xhigh | high | medium | low | minimal | none
# With THINKING_MODE=openrouter: alias max -> xhigh; other tokens lowercased and sent as-is.
REASONING_EFFORT=max
# REASONING_EFFORT_MODE — how REASONING_EFFORT is sent when THINKING_MODE is not openrouter
# (default auto from OPENAI_BASE_URL):
# auto -> if base URL contains "deepseek", use top_level; else OpenRouter nested.
# top_level -> chat.completions.create(..., reasoning_effort=...) (DeepSeek official).
# openrouter -> extra_body["reasoning"]["effort"] only (e.g. with THINKING_MODE=gemini).
# THINKING_MODE=openrouter always uses extra_body["reasoning"] with normalized effort (see above).
# REASONING_EFFORT_MODE=auto
# ============================================================================
# Voice Task Queue (parallel patch scheduling)
# ============================================================================
# Max concurrent LLM generation tasks (default 2). Additional tasks queue until a slot opens.
MAX_CONCURRENT_TASKS=2
# Required: lightweight model for per-utterance impact planning (declare_impact tool).
# Example: glm-4-flash, glm-4-air
PLANNER_MODEL_NAME=
# ============================================================================
# Generation Settings
# ============================================================================
DEFAULT_TEMPERATURE=1.0
DEFAULT_TOP_P=0.95
DEFAULT_TOP_K=40
DEFAULT_MAX_TOKENS=64000
# Per-request timeout in seconds (include thinking / long generations)
DEFAULT_TIMEOUT=900
# ============================================================================
# Concurrency & per-task API retry (call_openrouter.py)
# ============================================================================
# Default worker count hint; used when you pass --parallel N (sequential mode ignores this).
DEFAULT_CONCURRENCY=5
# DEFAULT_RETRY_TIMES — maximum attempts for a single task's chat.completions.create
# (one prompt × one turn). Each task has its own retry counter, not shared globally.
# Count includes the first try (e.g. 3 => up to 3 HTTP calls for that task).
# Values below 1 are treated as 1.
DEFAULT_RETRY_TIMES=3
# DEFAULT_RETRY_DELAY — seconds to sleep before the next attempt after a retriable failure.
# Retriable in script: connection/timeout errors, rate limiting, and HTTP 408, 429, 500, 502, 503, 504.
# Other errors (e.g. 400/401/403) are not retried.
DEFAULT_RETRY_DELAY=120
# ============================================================================
# Optional: Advanced Settings
# ============================================================================
# TOKENIZER_ENCODING=cl100k_base
LOG_LEVEL=DEBUG