Skip to content

Conversation

@KJ7LNW
Copy link

@KJ7LNW KJ7LNW commented Dec 27, 2025

Enable Claude Code SDK authentication via Claude Code CLI without requiring API keys. The Claude SDK provider complements existing API-based providers by supporting local authentication through the installed Claude Code tool.

This integration allows users with Claude Code subscriptions to leverage their existing Claude Code CLI installation for translation tasks without managing API keys or paying per token. The provider implements the same interface as other providers while using the claude-agent-sdk for communication with the locally authenticated Claude service.

  • add claude-agent-sdk dependency
  • add CLAUDE_SDK enum variant for provider type identification
  • register CLAUDE_SDK as local provider requiring no API key
  • implement ClaudeSdkProvider with multiple model support and fallbacks
  • register new provider in initialization pipeline
  • document Claude SDK usage in CLI help with example

@KJ7LNW KJ7LNW force-pushed the add-claude-code-support branch from 2262bdd to d0acd6a Compare December 27, 2025 23:09
@KJ7LNW
Copy link
Author

KJ7LNW commented Dec 27, 2025

Force pushed to clear out an unintentionally deleted comment about Ollama.

@KJ7LNW KJ7LNW marked this pull request as draft December 27, 2025 23:22
@KJ7LNW KJ7LNW marked this pull request as ready for review December 28, 2025 00:10
@KJ7LNW
Copy link
Author

KJ7LNW commented Dec 28, 2025

Okay, I'm pulling this out of draft. It is working.

I've done hundreds of translations so far without issue.

@pescheck-bram
Copy link
Contributor

There are some issues with flake8 and pylint:

python_gpt_po/services/providers/claude_sdk_provider.py:5:1: F401 'logging' imported but unused
python_gpt_po/services/providers/claude_sdk_provider.py:6:1: F401 'sys' imported but unused
python_gpt_po/services/providers/provider_init.py:4:1: F401 'logging' imported but unused

@KJ7LNW
Copy link
Author

KJ7LNW commented Dec 30, 2025

fixed.

@pescheck-bram
Copy link
Contributor

pescheck-bram commented Dec 30, 2025

fixed.

Imports are incorrectly sorted and/or formatted.

Run isort --check-only --diff .
ERROR: /home/runner/work/python-gpt-po/python-gpt-po/python_gpt_po/services/providers/claude_sdk_provider.py Imports are incorrectly sorted and/or formatted.
--- /home/runner/work/python-gpt-po/python-gpt-po/python_gpt_po/services/providers/claude_sdk_provider.py:before	2025-12-30 09:37:03.074886
+++ /home/runner/work/python-gpt-po/python-gpt-po/python_gpt_po/services/providers/claude_sdk_provider.py:after	2025-12-30 09:37:26.814133
@@ -58,14 +58,8 @@
             raise ValueError("Claude SDK client not initialized")
 
         import anyio
-        from claude_agent_sdk import (
-            AssistantMessage,
-            CLINotFoundError,
-            ClaudeAgentOptions,
-            ProcessError,
-            TextBlock,
-            query,
-        )
+        from claude_agent_sdk import (AssistantMessage, ClaudeAgentOptions, CLINotFoundError, ProcessError, TextBlock,
+                                      query)
 
         async def get_translation():
             """Async function to get translation from Claude SDK."""
Skipped 1 files

Eric Wheeler added 3 commits December 30, 2025 13:07
Enable Claude SDK authentication via Claude Code CLI without requiring API keys.
The Claude SDK provider complements existing API-based providers by supporting
local authentication through the installed Claude Code tool.

- add claude-agent-sdk dependency
- add CLAUDE_SDK enum variant for provider type identification
- register CLAUDE_SDK as local provider requiring no API key
- implement ClaudeSdkProvider with multiple model support and fallbacks
- register new provider in initialization pipeline
- document Claude SDK usage in CLI help with example

Signed-off-by: Eric Wheeler <[email protected]>
Unused imports increase cognitive load and may trigger linting warnings.
Cleaning removes technical debt and improves code clarity.

- remove unused logging and sys imports from claude_sdk_provider.py
- remove unused logging import from provider_init.py
- remove trailing blank line from provider_init.py

Signed-off-by: Eric Wheeler <[email protected]>
Condense the multi-line import statement in the Claude SDK provider to fit on fewer lines, aligning imports horizontally rather than vertically.

- reformat import statement to condensed format

Signed-off-by: Eric Wheeler <[email protected]>
@KJ7LNW KJ7LNW force-pushed the add-claude-code-support branch from 62a0fd9 to a1e132c Compare December 30, 2025 21:08
@KJ7LNW
Copy link
Author

KJ7LNW commented Dec 30, 2025

fixed and rebased

@KJ7LNW
Copy link
Author

KJ7LNW commented Dec 30, 2025

It looks like Python 3.9 failed, but the dependency does require 3.10. Would you like this to be conditionally available if someone pip installs the claude sdk package, or do you want to drop support for 3.9?

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.

2 participants