v1.0.2
What's Changed
- Add dynamic API key setting and improve file/HTTP handling by @hosseinhezami in #3
Overview
This PR introduces dynamic API key configuration via a new setApiKey() method and refactors file handling (CRUD operations) for better consistency. It also enhances the HttpClient class to support runtime API key and base URI settings, improving flexibility without breaking existing functionality.
Changes
-
Feat: Dynamic API Key Setting
- Added
Gemini::setApiKey('custom-key')method to allow runtime override of API key (falls back to .env/config if not set). - Updated
Gemini,ProviderFactory,BaseProvider, andHttpClientto propagate the custom key. - Ensures priority for manual set over .env.
- Added
-
Refactor: File CRUD Improvements
- Optimized methods for upload, list, get, and delete files in
GeminiProviderandBaseProvider. - Switched to consistent use of injected
HttpClientfor all file operations, removing raw HTTP calls. - Fixed inconsistencies in HTTP usage for file-related endpoints.
- Optimized methods for upload, list, get, and delete files in
-
Refactor: HttpClient Enhancements
- Modified
HttpClientto accept optionalapiKeyandbaseUrlin constructor for dynamic configuration. - Added chainable methods like
withHeaders()andwithBody()to support resumable uploads and other requests.
- Modified
Rationale
These changes make the package more flexible for multi-tenant apps or dynamic environments, while cleaning up code for maintainability. No breaking changes; backward compatibility preserved.
Contributors
- @hosseinhezami made their first contribution in #3
Full Changelog: v1.0.1...v1.0.2