From 10f3849549476c6df5e9665132af2b982c436a79 Mon Sep 17 00:00:00 2001 From: Chris Guidry Date: Mon, 29 Dec 2025 16:16:01 -0500 Subject: [PATCH] Use STORIED_ANTHROPIC_API_KEY to avoid collision with Claude Code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The SDK defaults to reading ANTHROPIC_API_KEY, which conflicts with Claude Code's own API key when running storied from within it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .envrc.private.example | 2 +- src/storied/engine.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.envrc.private.example b/.envrc.private.example index 2f91226..9d232ad 100644 --- a/.envrc.private.example +++ b/.envrc.private.example @@ -1,4 +1,4 @@ # Copy this file to .envrc.private and fill in your API keys # .envrc.private is gitignored and will not be committed -export ANTHROPIC_API_KEY="your-api-key-here" +export STORIED_ANTHROPIC_API_KEY="your-api-key-here" diff --git a/src/storied/engine.py b/src/storied/engine.py index b59d93d..8451bbe 100644 --- a/src/storied/engine.py +++ b/src/storied/engine.py @@ -1,6 +1,7 @@ """DM Engine - the agentic loop for running D&D sessions.""" import copy +import os from collections.abc import Iterator from pathlib import Path @@ -46,7 +47,9 @@ class DMEngine: model: Claude model to use prompt_name: System prompt to use (default: "dm-system", or "character-creation") """ - self.client = anthropic.Anthropic() + self.client = anthropic.Anthropic( + api_key=os.environ.get("STORIED_ANTHROPIC_API_KEY"), + ) self.model = model self.world_id = world_id self.player_id = player_id -- 2.51.2