Skip to content

Replace litellm with direct OpenAI and Anthropic SDKs - #11

Merged
strickvl merged 2 commits into
mainfrom
feature/remove-litellm
Apr 3, 2026
Merged

Replace litellm with direct OpenAI and Anthropic SDKs#11
strickvl merged 2 commits into
mainfrom
feature/remove-litellm

Conversation

@strickvl

@strickvl strickvl commented Apr 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • Remove litellm entirely as a dependency (security concern from recent vulnerability)
  • Add direct SDK integrations: OpenAITranslator (handles OpenAI, Ollama, Gemini via OpenAI-compatible APIs) and AnthropicTranslator (with thinking config mapping for reasoning effort)
  • Make provider SDKs optional extras: tinbox[openai], tinbox[anthropic], or tinbox[all] for everything
  • Preserve all existing behavior: same CLI UX, same provider:model syntax, same algorithms, same glossary/checkpoint/cost tracking
  • Fix CI: migrate str, EnumStrEnum (Python 3.12+), use uv in GitHub Actions

Provider matrix

CLI syntax Provider Translator Extra
openai:gpt-5-... OpenAI OpenAITranslator tinbox[openai]
ollama:llama3.1:8b Ollama OpenAITranslator tinbox[openai]
gemini:gemini-2.5-pro Gemini OpenAITranslator tinbox[openai]
anthropic:claude-... Anthropic AnthropicTranslator tinbox[anthropic]

Key design decisions

  • Shared _shared.py module: prompt construction, JSON parsing, retry decorator, and content validation are shared across both translators — no behavioral drift
  • Lazy imports: create_translator() uses local imports so base install works without any provider SDK
  • Gemini kept via Google's official OpenAI-compatible endpoint (generativelanguage.googleapis.com)
  • OpenRouter supported by setting OPENAI_BASE_URL env var (documented in README)

Test plan

  • All 284 tests pass
  • 84% code coverage
  • Ruff linting fully clean (including UP042 StrEnum migration)
  • Formatting clean
  • uv pip install -e ".[dev]" installs cleanly
  • litellm fully removed — no imports, no dependency, no references

strickvl added 2 commits April 3, 2026 17:52
Remove litellm dependency due to security concerns and replace with
direct openai and anthropic SDK integrations as optional extras.

- Add OpenAITranslator for OpenAI, Ollama, and Gemini (via OpenAI-compatible APIs)
- Add AnthropicTranslator with thinking config mapping for reasoning effort
- Extract shared helpers (_shared.py): prompt builders, retry decorator,
  JSON parsing, model name extraction, content validation
- Add calculate_usage_cost() to cost.py (replaces litellm's completion_cost)
- Add SDK presence checks to doctor.py diagnostics
- Make openai/anthropic installable as extras: tinbox[openai], tinbox[anthropic]
- Update factory to lazy-import translators based on ModelType
- All 284 tests pass at 84% coverage
- Convert all str+Enum classes to StrEnum (Python 3.12+)
- Use astral-sh/setup-uv in CI for faster installs
- All ruff checks now pass (UP042 resolved)
@strickvl
strickvl merged commit 73c2c26 into main Apr 3, 2026
3 checks passed
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