Thank you for your interest in contributing to gemini-client-rs. This project provides a high-performance, idiomatic, and infrastructure-first Rust client for the Google Gemini API.
We focus on being a precision thin layer—prioritizing raw API fidelity, reliability, and architectural clarity.
- Rust: Latest stable version (Edition 2021).
- Google AI Studio API Key: Required for running integration tests and examples.
-
Clone the repository:
git clone https://github.com/Adriftdev/gemini-client.git cd gemini-client -
Configure Environment: Create a
.envfile in the root directory:GEMINI_API_KEY=your_api_key_here
-
Run Examples: Verify your setup by running the basic example:
cargo run --example basic
This library is part of the rain ecosystem. To maintain consistency across clients (e.g., ollama-client-rs), we adhere to a shared set of interface patterns:
- Macro-First DX: Prioritize declarative request building via procedural macros (
gemini_chat!,gemini_parts!). - Standardized Schema Generation: All structured outputs should use the
GeminiSchemaderive macro. - Builder Pattern: Clients should always implement
new,with_client, andwith_api_url. - Pinned Streams: All streaming methods must return
Pin<Box<dyn Stream>>to simplify caller integration. - Standardized Telemetry: Use the internal
telemetry_*!macros. - Error Mapping: Maintain a flat, descriptive
GeminiErrorenum usingthiserror.
When contributing to the core client, adhere to these principles:
- Thin Layer Foundation: The core client is a transport and mapping layer. Avoid adding complex state machines or orchestration logic.
- Ergonomic Macro Overlay: Provide a best-in-class developer experience via macros that simplify common tasks (e.g., chat construction, tool declaration).
- Transparent Proxy: Preserving byte-for-byte fidelity and API structure in the core types is a priority.
- Rust Type Safety: Leverage Rust's type system to make API constraints explicit and compile-time safe.
- Zero-Overhead Abstractions: Ensure the mapping from macros to request structs is efficient.
- Follow Rust API Guidelines.
- Use
thiserrorfor all library-level error definitions. - Avoid
anyhowin the core library; it is reserved for examples and tests.
We maintain strict quality gates. PRs will not be merged if they contain Clippy warnings.
cargo fmt --all
cargo clippy --all-targets --all-features -- -D warningsAlways use the standardized macros to ensure consistent mapping of error kinds and span data for cloud-native observability.
Every PR must be verified across multiple feature configurations:
-
Core Tests:
cargo test -
Feature-Specific Tests: Verify the
tracingfeature and other optional dependencies:cargo test --features tracing -
Example Verification: Ensure basic examples remain functional:
cargo check --examples
- Open an Issue: Discuss major changes before implementation.
- Fork and Branch: Work on a feature branch (
feat/your-featureorfix/your-fix). - Conventional Commits: We use conventional commit messages (e.g.,
feat: add embedding support). - PR Review: All PRs require approval and passing CI checks.
- Never commit your
.envfile or API keys. - Report security vulnerabilities via GitHub Issues or contact the maintainers directly.