core-genai#
A Python library that wraps multiple AI provider SDKs under a single, consistent interface, async-first, with optional synchronous support.
Documentation Contents#
Index:
Features#
Unified agent interface: all providers share the same
IAgentAPI:analyze,get_text,get_texts,get_cost, andget_metadata.Multi-provider support: plug-and-play agents for Google Gemini, Anthropic Claude, OpenAI ChatGPT, and xAI Grok.
GrokAgentextendsChatGPTAgentsince the xAI API is OpenAI-compatible.Async-first, sync-friendly: agents are natively
async; wrap any agent withSyncWrapperfromcore-mixinsfor transparent synchronous access.Normalized usage metadata:
get_metadata()always returns aUsageMetadataTypedDict with consistent keys (input_tokens,output_tokens,total_tokens,cost_usd) plus provider-specific optional fields (cached_tokens,cache_creation_tokens,reasoning_tokens).Built-in cost estimation:
get_cost()computes the USD cost for any response using per-model pricing tables bundled with each agent.Factory registration: agents are auto-registered by class name; instantiate any agent with
IAgent.create_agent("GeminiAgent", api_key=...).Lazy client initialization: the underlying SDK client is created only on first use, so importing an agent has no side effects.
Batch job support via
IScheduler: Gemini, Claude, ChatGPT, and Grok implementschedule_job,check_job_status, andextract_job_resultsfor large-scale asynchronous inference at reduced cost. Users pass simpleBatchRequestobjects; serialization is handled internally per provider.Normalized batch contracts:
ScheduledJobMetadataandScheduledJobResponseare defined once inbase.pyand shared across all providers, with a commonjob_idfield.
Installation#
pip install core-genai
uv pip install core-genai # Or using UV...
pip install -e ".[dev]" # For development...
Contributing#
Contributions are welcome! Please:
Fork the repository
Create a feature branch
Write tests for new functionality
Ensure all tests pass:
python manager.py run-testsRun linting:
pylint core_genaiRun security checks:
bandit -r core_genaiSubmit a pull request
License#
This project is licensed under the MIT License. See the LICENSE file for details.
Links#
Documentation: https://core-genai.readthedocs.io/en/latest/
Repository: bytecode-solutions/core/core-genai
Changelog: bytecode-solutions/core/core-genai/-/blob/master/CHANGELOG.md
Support#
For questions or support, please open an issue on GitLab or contact the maintainers.