@ducquang/zenith-core
v0.1.1
Published
Zenith AI Framework — Core engine. Zero infrastructure dependency.
Downloads
298
Maintainers
Readme
@ducquang/zenith-core
📖 Overview
@ducquang/zenith-core is the foundational engine of the Zenith AI Framework. It provides a robust, zero-infrastructure-dependency orchestrator for interacting with multiple AI providers (Anthropic, Google Gemini, OpenRouter).
It abstracts away provider-specific complexities, offering a unified interface for prompt execution, event-driven streaming, and fallback mechanisms.
✨ Features
- 🧠 Multi-Provider AI Orchestrator: Seamlessly route requests to Anthropic Claude, Google Gemini, or any model via OpenRouter.
- 🛡️ Automatic Fallbacks: Built-in resilience. If a primary model fails, the core engine automatically falls back to secondary models defined in your pipeline mapping.
- 🌊 Unified Streaming Protocol: Consumes proprietary streaming formats from different providers and emits a normalized, consistent Server-Sent Events (SSE) compatible stream.
- 🔑 BYoK (Bring Your Own Key) Support: First-class support for multi-tenant applications where users provide their own API keys.
- ⚡ Zero Infrastructure Dependency: The core package handles logic, routing, and HTTP requests without enforcing a specific database or Redis configuration.
- ⌨️ TypeScript Ready: Includes type definitions for a first-class developer experience.
📦 Installation
npm install @ducquang/zenith-core🚀 Basic Usage
import { AIOrchestrator } from '@ducquang/zenith-core';
// Initialize the orchestrator
const ai = new AIOrchestrator({
anthropicApiKey: process.env.ANTHROPIC_API_KEY,
geminiApiKey: process.env.GEMINI_API_KEY,
});
// Example: Generate text with an automatic fallback chain
const response = await ai.generate({
provider: 'anthropic',
model: 'claude-3-haiku-20240307',
messages: [{ role: 'user', content: 'Explain quantum computing in simple terms.' }],
fallbackChain: ['gemini'] // Will try Gemini if Anthropic fails
});
console.log(response.content);🔌 Adapters
To add persistence for quotas, rate-limiting, and complex state management, integrate @ducquang/zenith-core with official adapters:
@ducquang/zenith-adapter-sequelize- MySQL/PostgreSQL/SQLite persistence.
🤝 Contributing
Zenith is an open framework. If you have ideas for new providers or core improvements, we welcome PRs!
📜 License
AGPL-3.0 License
