Skip to content

Replace Cloudflare Worker with local Claude Agent SDK (zero API costs)#29

Open
ingokpp wants to merge 1 commit intofarzaa:mainfrom
ingokpp:feature/local-claude-no-api-costs
Open

Replace Cloudflare Worker with local Claude Agent SDK (zero API costs)#29
ingokpp wants to merge 1 commit intofarzaa:mainfrom
ingokpp:feature/local-claude-no-api-costs

Conversation

@ingokpp
Copy link
Copy Markdown

@ingokpp ingokpp commented Apr 8, 2026

Not intended for merging — this PR is shared as a reference for anyone who wants to run Clicky with zero API costs using their local Claude Code session. Feel free to cherry-pick ideas or use it as a starting point.

What this does

Replaces the Cloudflare Worker proxy with free, local alternatives — eliminating all external API costs:

  • Claude API → local Node.js server using @anthropic-ai/claude-agent-sdk, which spawns the Claude Code CLI and inherits local session auth (no API key needed)
  • ElevenLabs TTS → macOS NSSpeechSynthesizer with AVSpeechSynthesizer fallback
  • AssemblyAI STT → Apple Speech framework (already existed as fallback, now the default)

The Cloudflare Worker (worker/) is removed entirely.

Why NSSpeechSynthesizer (deprecated) instead of AVSpeechSynthesizer?

Apple deprecated NSSpeechSynthesizer in macOS 14 in favor of AVSpeechSynthesizer. However, AVSpeechSynthesizer cannot access Siri voices — only its own set of compact/enhanced/premium voices, which sound noticeably robotic. NSSpeechSynthesizer uses the system voice configured in Accessibility settings, which includes Siri voices and sounds dramatically better. It still works fine on macOS 14+ despite the deprecation. An AVSpeechSynthesizer fallback is included in case NSSpeechSynthesizer ever stops working.

How to run it

  1. Have Claude Code installed and authenticated (claude auth login)
  2. cd local-server && npm install && npm start
  3. Build and run in Xcode as normal
  4. Enable speech recognition: System Settings → Keyboard → Dictation

Disclaimer

This was built almost entirely using Claude Code (Claude Opus 4.6). The implementation uses the Claude Agent SDK with local session auth, which works for personal use but is not intended for distributed applications per Anthropic's terms.

🤖 Generated with Claude Code

Eliminate all external API costs by replacing the Cloudflare Worker proxy
with local alternatives:

- Claude API → local Node.js server using @anthropic-ai/claude-agent-sdk,
  which spawns the Claude Code CLI and inherits local session auth
- ElevenLabs TTS → macOS NSSpeechSynthesizer (uses system voice including
  Siri voices, with AVSpeechSynthesizer fallback)
- AssemblyAI STT → Apple Speech framework (already existed as fallback,
  now the default)

The Cloudflare Worker is no longer needed — all three API routes are
replaced with free, local alternatives that require no API keys.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant