Shannon Environment Variables for Anthropic Claude and OpenAI Models

Shannon requires ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN for native Claude operation, while router mode requires ROUTER=true, ROUTER_DEFAULT, and either OPENAI_API_KEY or OPENROUTER_API_KEY to proxy requests through OpenAI or OpenRouter providers.

Shannon is an open-source AI coding assistant that integrates directly with Large Language Models to automate software development tasks. Whether you are running the default Anthropic Claude integration or routing requests to OpenAI models via the claude-code-router, configuring the correct Shannon environment variables is essential for authentication and runtime behavior.

Native Anthropic Claude Configuration

When running Shannon without the router, the application connects directly to Anthropic's Claude API. The startup script located at shannon (lines 37-46) validates that a Claude credential exists before launching the service.

Required Variables

You must provide exactly one of the following authentication methods:

  • ANTHROPIC_API_KEY – Your Anthropic API key for direct API access.
  • CLAUDE_CODE_OAUTH_TOKEN – An OAuth token obtained through Anthropic's authentication flow.

The src/ai/claude-executor.ts file (lines 224-230) injects these credentials into the SDK environment at runtime. If neither variable is present, the CLI exits with an authentication error.

Optional Variables

  • CLAUDE_CODE_MAX_OUTPUT_TOKENS – Configures the maximum token limit for Claude responses. The default value is 64000, which accommodates large tool outputs and extensive code generation.

Router Mode for OpenAI and OpenRouter

Shannon supports routing LLM requests to alternative providers through the claude-code-router container. When ROUTER=true, the system proxies Claude SDK calls to OpenAI, OpenRouter, or other compatible endpoints.

Required Variables

To enable router mode, you must set:

  • ROUTER=true – Activates the router profile in the Docker Compose configuration.
  • ROUTER_DEFAULT – Specifies the target provider and model in the format provider,model. For example: openai,gpt-5.2 or openrouter,google/gemini-3-flash-preview.
  • Provider API key – Either OPENAI_API_KEY or OPENROUTER_API_KEY depending on your selected provider.

The startup script (shannon lines 76-84) validates that a provider key exists when router mode is active. The src/ai/router-utils.ts file (lines 13-15) reads ROUTER_DEFAULT to resolve the actual model name for request routing.

Router Authentication Flow

When operating in router mode, Shannon automatically configures the Claude SDK to point at the local router container:

  • Sets ANTHROPIC_BASE_URL=http://router:3456 to redirect SDK requests to the router endpoint.
  • Injects a placeholder ANTHROPIC_API_KEY="router-mode" to satisfy SDK initialization requirements while the router handles actual provider authentication using your OPENAI_API_KEY or OPENROUTER_API_KEY.

Configuration Examples

Claude-Only Setup

Create a .env file in your project root:

ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxx
CLAUDE_CODE_MAX_OUTPUT_TOKENS=64000

Launch Shannon:

./shannon start URL=https://my-app.local REPO=my-repo

OpenAI Router Setup

ROUTER=true
OPENAI_API_KEY=sk-your-openai-key
ROUTER_DEFAULT=openai,gpt-5.2
CLAUDE_CODE_MAX_OUTPUT_TOKENS=64000

Start with routing enabled:

./shannon start URL=https://my-app.local REPO=my-repo ROUTER=true

OpenRouter Setup for Gemini

ROUTER=true
OPENROUTER_API_KEY=sk-your-openrouter-key
ROUTER_DEFAULT=openrouter,google/gemini-3-flash-preview
./shannon start URL=https://my-app.local REPO=my-repo ROUTER=true

OAuth Token Authentication

CLAUDE_CODE_OAUTH_TOKEN=your-oauth-token

No ANTHROPIC_API_KEY is needed when using the OAuth token; the executor picks up the token automatically from the environment.

Summary

  • Native Claude mode requires either ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN for direct API authentication.
  • Router mode requires ROUTER=true, ROUTER_DEFAULT to specify the provider/model, and either OPENAI_API_KEY or OPENROUTER_API_KEY for the target provider.
  • The CLAUDE_CODE_MAX_OUTPUT_TOKENS variable is optional but recommended for controlling response limits in both modes.
  • In router mode, Shannon automatically sets ANTHROPIC_BASE_URL and a placeholder ANTHROPIC_API_KEY to proxy requests through the claude-code-router container.

Frequently Asked Questions

What happens if I don't set any API keys?

Shannon validates credentials at startup in the shannon CLI script (lines 37-46). If neither ANTHROPIC_API_KEY nor CLAUDE_CODE_OAUTH_TOKEN is present in native mode, or if no provider key exists in router mode, the application exits immediately with an authentication error.

Can I use both Anthropic and OpenAI keys at the same time?

While you can define both ANTHROPIC_API_KEY and OPENAI_API_KEY in your environment, Shannon operates in mutually exclusive modes. When ROUTER=true, the system uses the OpenAI or OpenRouter key for actual LLM calls while using a placeholder Anthropic key for SDK initialization. In native mode, only the Anthropic credentials are utilized.

How do I switch between Claude and OpenAI models?

To switch providers, modify the ROUTER_DEFAULT environment variable to specify your desired provider and model (e.g., openai,gpt-5.2 or anthropic,claude-sonnet-4). When using native Anthropic mode, simply ensure ROUTER is not set to true and provide your ANTHROPIC_API_KEY. The src/ai/router-utils.ts file (lines 13-15) processes the ROUTER_DEFAULT value to determine the actual model endpoint.

Is the OAuth token more secure than the API key?

Both ANTHROPIC_API_KEY and CLAUDE_CODE_OAUTH_TOKEN provide secure authentication, but OAuth tokens are typically short-lived and revocable through the provider's consent management, making them preferable for temporary or shared environments. API keys are long-lived credentials that should be stored securely in environment variables or secret managers, never committed to version control.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →