claude-lite-llm
A lightweight Python wrapper around Anthropic's Claude Code CLI and OpenAI's Codex CLI that allows developers to run Claude and ChatGPT LLMs programmatically using their active subscriptions (CLAUDE_CODE_TOKEN and ChatGPT account / CODEX_ACCESS_TOKEN) — bypassing pay-per-token API keys.
Also includes built-in custom providers for LiteLLM (ClaudeSubscriptionProvider, CodexSubscriptionProvider, and register_with_litellm).
Features
- Subscription-Powered: Authenticate using Claude Code (
CLAUDE_CODE_TOKEN) and OpenAI Codex CLI subscriptions. - Claude & Codex CLI Support: Unified programmatic access to Anthropic Claude (Sonnet, Opus, Haiku) and OpenAI Codex (o3-mini, o3, gpt-4o).
- LiteLLM Native Integration: Exported
ClaudeSubscriptionProviderandCodexSubscriptionProviderclasses plus 1-lineregister_with_litellm()forlitellm.completion(model="claude_sub/sonnet"). - Flexible Message Formats: Pass raw prompt strings or conversational message dicts (
[{"role": "user", "content": "..."}]). - Structured Responses: Access generated text, token usage metrics, latency, and session IDs.
- Safe Execution: Disables tool execution and runs sandboxed (
read-only) by default for pure text completions. - Granular Error Handling: Dedicated exceptions for rate limits (session quota / 429), authentication failures, and CLI execution errors.
Installation
pip install claude-lite-llm
# With LiteLLM support:
pip install "claude-lite-llm[litellm]"
Prerequisites
-
Claude CLI (if using Claude models):
npm install -g @anthropic-ai/claude-code claude setup-token
Add
CLAUDE_CODE_TOKENto your app's.env:CLAUDE_CODE_TOKEN=sk-ant-oat01-...
-
Codex CLI (if using Codex / ChatGPT models):
npm install -g @openai/codex codex login
Or provide
CODEX_ACCESS_TOKENin.env.
Usage
1. Claude Completion
from claude_lite_llm import completion
response = completion("Explain quantum computing in 2 sentences.", model="sonnet")
print(response.content)
print(f"Tokens: {response.usage.input_tokens} in / {response.usage.output_tokens} out")
2. Codex Completion (OpenAI / ChatGPT)
from claude_lite_llm import codex_completion
response = codex_completion("Write a Python function to reverse a linked list.", model="o3-mini")
print(response.content)
print(f"Tokens: {response.usage.input_tokens} in / {response.usage.output_tokens} out")
3. Native Integration with LiteLLM
Use register_with_litellm() to route any LiteLLM call through your Claude or Codex subscription:
import litellm
from claude_lite_llm import register_with_litellm
# Register 'claude_sub' and 'codex_sub' custom providers in LiteLLM
register_with_litellm()
# Call Claude via subscription in LiteLLM
claude_res = litellm.completion(
model="claude_sub/sonnet",
messages=[{"role": "user", "content": "Explain async/await in Python."}],
)
print(claude_res.choices[0].message.content)
# Call Codex via subscription in LiteLLM
codex_res = litellm.completion(
model="codex_sub/o3-mini",
messages=[{"role": "user", "content": "Write a binary search in Python."}],
)
print(codex_res.choices[0].message.content)
You can also instantiate the providers directly:
from claude_lite_llm import ClaudeSubscriptionProvider, CodexSubscriptionProvider
import litellm
litellm.custom_provider_map = [
{"provider": "my_claude", "custom_handler": ClaudeSubscriptionProvider()},
{"provider": "my_codex", "custom_handler": CodexSubscriptionProvider()},
]
4. Asynchronous Completions
import asyncio
from claude_lite_llm import acompletion, codex_acompletion
async def main():
claude_res = await acompletion("Hello from Claude async!")
print("Claude:", claude_res.content)
codex_res = await codex_acompletion("Hello from Codex async!", model="o3-mini")
print("Codex:", codex_res.content)
asyncio.run(main())
5. Handling Rate Limits & Errors
from claude_lite_llm import completion
from claude_lite_llm.exceptions import ClaudeAuthError, ClaudeRateLimitError
try:
response = completion("Hello Claude!")
print(response.content)
except ClaudeRateLimitError as e:
# Captures 429 session limits and subscription reset times
print(f"Rate limit reached: {e}")
except ClaudeAuthError as e:
print(f"Authentication failure: {e}")
Development
uv sync --all-extras --dev
uv run pytest
uv run ruff check .
uv run mypy
Install the git hooks once after cloning:
uv run pre-commit install
Make targets
| Target | Description |
|---|---|
make install |
Sync the dev environment |
make lint |
Ruff lint and format check |
make format |
Apply Ruff formatting and fixes |
make typecheck |
Run mypy in strict mode |
make test |
Run the test suite with coverage |
make build |
Build the sdist and wheel |
make clean |
Remove build and cache artifacts |
License
MIT
Metadata
Release files for claude-lite-llm 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| claude_lite_llm-0.2.0.tar.gz | 17.1 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| claude_lite_llm-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.8 kB
Release files / claude_lite_llm-0.2.0.tar.gz
| Download URL | claude_lite_llm-0.2.0.tar.gz |
|---|---|
| Size | 17.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
50fdd65af4fdd11a772fa1c0c2fd67d9644f20b090853fe47d225c42500adc64
|
|
BLAKE2b-256 checksum How to use checksums |
e9666ddb69479fb8f3f8d4734e91cff36fe96c49b607cc88a7d3f7180c4c63fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.
Transparency logRelease files / claude_lite_llm-0.2.0-py3-none-any.whl
| Download URL | claude_lite_llm-0.2.0-py3-none-any.whl |
|---|---|
| Size | 15.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
19b137778c94fef45d0abaa62573afb581b47200a3b01db0b33ac8dd446c36a7
|
|
BLAKE2b-256 checksum How to use checksums |
ef542c3bc56fbd95dcb076aa27f59e25867ec2f560d9b2677b8f239c936fbeb6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.
Transparency logSecurity for claude-lite-llm 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for claude_lite_llm-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.