Spaces:
Sleeping
Sleeping
Claude Code Claude Opus 4.6 commited on
Commit ·
740ba92
1
Parent(s): d9c8cec
Claude Code: Fix worker env injection - add ANTHROPIC_API_KEY and CLAUDE_API_KEY to env config
Browse files- Added CLAUDE_API_KEY to .env.example (was completely missing)
- Uncommented ANTHROPIC_API_KEY in .env.example (was commented out)
- Added both keys to utils/env_init.py _CRITICAL_DEFAULTS
- Added both keys to optional critical variables verification
This fixes worker initialization failures where API keys were not properly
propagated to the worker subprocess environment.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- .env.example +12 -1
- utils/env_init.py +3 -1
.env.example
CHANGED
|
@@ -133,9 +133,20 @@ OPENAI_API_KEY=
|
|
| 133 |
# Leave empty here - value comes from HF Space secrets
|
| 134 |
OPENROUTER_API_KEY=
|
| 135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
# Other providers (OpenClaw reads these from the environment)
|
| 137 |
#
|
| 138 |
-
# ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
| 139 |
# GOOGLE_API_KEY=AIza...
|
| 140 |
# MISTRAL_API_KEY=mis-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
| 141 |
# COHERE_API_KEY=co-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
|
|
| 133 |
# Leave empty here - value comes from HF Space secrets
|
| 134 |
OPENROUTER_API_KEY=
|
| 135 |
|
| 136 |
+
# Anthropic Claude API (used by error_handlers.py for agent responses)
|
| 137 |
+
#
|
| 138 |
+
# [RECOMMENDED] - Must be set as Space Repository Secret
|
| 139 |
+
# Leave empty here - value comes from HF Space secrets
|
| 140 |
+
ANTHROPIC_API_KEY=
|
| 141 |
+
|
| 142 |
+
# Claude API alias (alternative to ANTHROPIC_API_KEY)
|
| 143 |
+
#
|
| 144 |
+
# [RECOMMENDED] - Must be set as Space Repository Secret
|
| 145 |
+
# Leave empty here - value comes from HF Space secrets
|
| 146 |
+
CLAUDE_API_KEY=
|
| 147 |
+
|
| 148 |
# Other providers (OpenClaw reads these from the environment)
|
| 149 |
#
|
|
|
|
| 150 |
# GOOGLE_API_KEY=AIza...
|
| 151 |
# MISTRAL_API_KEY=mis-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
| 152 |
# COHERE_API_KEY=co-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
utils/env_init.py
CHANGED
|
@@ -42,6 +42,8 @@ _CRITICAL_DEFAULTS = {
|
|
| 42 |
# LLM defaults (empty - must be set for AI to work)
|
| 43 |
"OPENAI_API_KEY": "",
|
| 44 |
"OPENROUTER_API_KEY": "",
|
|
|
|
|
|
|
| 45 |
"OPENCLAW_DEFAULT_MODEL": "",
|
| 46 |
|
| 47 |
# HuggingFace defaults (empty - must be set for data sync to work)
|
|
@@ -192,7 +194,7 @@ def init_env() -> bool:
|
|
| 192 |
|
| 193 |
# Step 3: Verify critical variables have values (log warnings if missing)
|
| 194 |
_missing_critical = []
|
| 195 |
-
_optional_critical = ["HF_TOKEN", "OPENCLAW_DATASET_REPO", "OPENAI_API_KEY", "OPENROUTER_API_KEY"]
|
| 196 |
for key in _optional_critical:
|
| 197 |
if not os.environ.get(key):
|
| 198 |
_missing_critical.append(key)
|
|
|
|
| 42 |
# LLM defaults (empty - must be set for AI to work)
|
| 43 |
"OPENAI_API_KEY": "",
|
| 44 |
"OPENROUTER_API_KEY": "",
|
| 45 |
+
"ANTHROPIC_API_KEY": "",
|
| 46 |
+
"CLAUDE_API_KEY": "",
|
| 47 |
"OPENCLAW_DEFAULT_MODEL": "",
|
| 48 |
|
| 49 |
# HuggingFace defaults (empty - must be set for data sync to work)
|
|
|
|
| 194 |
|
| 195 |
# Step 3: Verify critical variables have values (log warnings if missing)
|
| 196 |
_missing_critical = []
|
| 197 |
+
_optional_critical = ["HF_TOKEN", "OPENCLAW_DATASET_REPO", "OPENAI_API_KEY", "OPENROUTER_API_KEY", "ANTHROPIC_API_KEY", "CLAUDE_API_KEY"]
|
| 198 |
for key in _optional_critical:
|
| 199 |
if not os.environ.get(key):
|
| 200 |
_missing_critical.append(key)
|