This document describes how to build Lingua and generate language bindings.
- Rust 1.70+ with Cargo
- Node.js 20+ with pnpm (for TypeScript bindings)
- Python 3.11+ with uv (for Python bindings)
- Protocol Buffers compiler (for Google provider)
# Install git hooks (recommended for development)
make install-hooks
# Build all bindings
make all
# Run tests
make testAfter cloning the repository, install git hooks to ensure code quality:
make install-hooksThis installs a pre-commit hook that:
- Automatically runs
cargo fmtto format Rust code - Runs TypeScript linting/formatting checks (if applicable)
- Aborts the commit if any files are changed by formatting
If the commit is aborted, review the formatting changes and re-commit:
git add -A
git commitTo temporarily bypass the hook (not recommended):
git commit --no-verifyBuild in development mode:
cargo buildBuild optimized release version:
cargo build --releaseBuild with specific provider features:
cargo build --no-default-features --features="openai,anthropic"TypeScript types for the universal Message format are automatically generated from Rust types using ts-rs:
# Generate TypeScript types from Rust
make generate-typesThis creates TypeScript files in bindings/typescript/src/generated/:
- Individual type files (e.g.,
Message.ts,UserContentPart.ts) - Automatic exports for all types marked with
#[ts(export)]
Important: After modifying Rust types in src/universal/, always run make generate-types and commit the updated TypeScript files. CI will verify that generated types are up to date.
To build the full TypeScript bindings (WASM):
make typescriptGenerate provider-specific types from OpenAPI specs:
cargo run --bin generate-types openai
cargo run --bin generate-types anthropicRun all tests (Rust, TypeScript, and Python):
make testRun tests for specific languages:
make test-rust # Rust tests only
make test-typescript # TypeScript tests only
make test-python # Python tests onlyRun tests for specific features:
cargo test --features="openai"Format code:
make fmt # Format all code (Rust + TypeScript)
cargo fmt # Format Rust code onlyRun linter:
cargo clippy --all-targets --all-features -- -D warningsCheck all code compiles:
make check # Check Rust and TypeScriptopenai- OpenAI API types and translatorsanthropic- Anthropic API types and translatorsgoogle- Google Gemini API types and translatorsbedrock- AWS Bedrock API types and translators
Default features: ["openai", "anthropic", "google", "bedrock"]