LiteLLM provider for Treasure Data LLM Proxy
Project description
LiteLLM TD LLM Proxy Provider
Custom LiteLLM provider for Treasure Data's LLM Proxy API.
Installation
Using uv (recommended)
cd litellm-td-llm-provider
uv sync
source .venv/bin/activate # On Windows: .venv\Scripts\activate
Using pip
cd litellm-td-llm-provider
pip install -e .
Usage
import litellm
from litellm_td_llm_provider import register_td_provider
# Register the TD provider
register_td_provider()
# Use with LiteLLM
response = litellm.completion(
model="td/claude-sonnet-4-5",
messages=[{"role": "user", "content": "Hello!"}],
api_key="your-td-api-key",
api_base="https://llm-proxy.us01.treasuredata.com"
)
Configuration
Available Models
The following Claude 4.5 models are available through TD LLM Proxy:
| Model | Model ID | Alias |
|---|---|---|
| Claude Sonnet 4.5 | claude-sonnet-4-5-20250929 |
claude-sonnet-4-5 |
| Claude Haiku 4.5 | claude-haiku-4-5-20251001 |
claude-haiku-4-5 |
| Claude Opus 4.5 | claude-opus-4-5-20251101 |
claude-opus-4-5 |
Note:
- Aliases (e.g.,
claude-sonnet-4-5) automatically point to the latest version - Use specific versions (e.g.,
claude-sonnet-4-5-20250929) if you need to pin to a particular model snapshot
This provider uses claude-sonnet-4-5 as the default model.
Site Endpoints
us01: https://llm-proxy.us01.treasuredata.comjp01: https://llm-proxy.treasuredata.co.jpeu01: https://llm-proxy.eu01.treasuredata.comap02: https://llm-proxy.ap02.treasuredata.comap03: https://llm-proxy.ap03.treasuredata.comdev-us01: https://llm-proxy-development.us01.treasuredata.comdev-eu01: https://llm-proxy-development.eu01.treasuredata.comstg-us01: https://llm-proxy-staging.us01.treasuredata.comstg-jp01: https://llm-proxy-staging.treasuredata.co.jpstg-ap03: https://llm-proxy-staging.ap03.treasuredata.com
Environment Variables
export TD_LLM_API_KEY="your-api-key"
export TD_LLM_SITE="us01" # Optional, defaults to us01
Features
- ✅ Streaming support
- ✅ Non-streaming completion
- ✅ Multi-site support
- ✅ Anthropic-compatible API
Development
Setup
# Install dependencies (creates venv automatically)
uv sync
# Activate virtual environment
source .venv/bin/activate
# Run tests
uv run pytest
Using Makefile
make install-dev # Install dev dependencies
make format # Format code with ruff
make lint # Run linting
make check # Run type checking with pyright
make test # Run tests
make test-cov # Run tests with coverage
make check-all # Run all checks (format, lint, check, test)
make clean # Clean cache and build artifacts
Release Process
- Update version in
pyproject.toml - Create and push a git tag:
git tag v0.1.0 git push origin v0.1.0
- GitHub Actions will automatically build and publish to PyPI
Required GitHub Secret:
PYPI_TOKEN: PyPI API token for publishing
Running Examples
# Set credentials
export TD_LLM_API_KEY="your-api-key"
export TD_LLM_SITE="us01"
# Run basic example
python examples/basic_usage.py
# Run site selection example
python examples/site_selection.py
Implementation Details
This provider is based on the TypeScript implementation in tdx-studio/electron/services/llm-proxy-client.ts and provides:
- Endpoint Management: Multi-region support with automatic site resolution
- Streaming: Server-Sent Events (SSE) parsing for real-time responses
- Error Handling: Proper error propagation and API error messages
- LiteLLM Integration: Custom provider registration with standard LiteLLM interface
API Compatibility
The TD LLM Proxy API is Anthropic-compatible and supports:
/v1/messagesendpointx-api-keyauthenticationanthropic-version: 2023-06-01header- Streaming via SSE with
stream: true
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file litellm_td_llm_provider-0.1.0.tar.gz.
File metadata
- Download URL: litellm_td_llm_provider-0.1.0.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9d6fc48482f5875c9dfeb92cabfa8b2300c0392c851297efa820c2f95d2a45b
|
|
| MD5 |
0dd649919d6e80b9fb76a362c5c98270
|
|
| BLAKE2b-256 |
0692caf3d2fd28a7dbf54c90f46cc694c2a0b313ba86dea8bc596eeb1de1c137
|
File details
Details for the file litellm_td_llm_provider-0.1.0-py3-none-any.whl.
File metadata
- Download URL: litellm_td_llm_provider-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec323bf4c29778b542c1e4cacc0f5a399596a5137b8560ad982e39975bd2039d
|
|
| MD5 |
2bd34ae3612fbb62cbd9a43afda7b154
|
|
| BLAKE2b-256 |
1e90a6c343c9bfeb80fcc321041a44d5bcd00498cb18206842b02d1530f9ff20
|