API-LLM-Hub is a lightweight JavaScript library that simplifies the use of multiple AI language models directly in your web browser. It offers a straightforward interface for interacting with various AI providers through vanilla JavaScript, with no build steps or backend required.
- Simple Integration: Include a single script and start using AI in your web projects.
- Browser-Focused: Designed for easy use in static web pages and client-side applications.
- CORS-Friendly: Helps avoid common deployment issues, particularly with certain providers (anthropics/anthropic-sdk-typescript#410).
- API-LLM-Hub: Consistent interface across multiple AI providers for easier development.
- Quick Prototyping: Rapidly integrate AI capabilities into static web projects.
- OpenAI
- Anthropic
- TogetherAI
- Google's Gemini
Include the script and use API-LLM-Hub with just a few lines of code:
<script type="module">
import APILLMHub from 'https://amanpriyanshu.github.io/API-LLM-Hub/unified-llm-api.js';
async function runTest() {
const ai = new APILLMHub({
provider: 'openai',
apiKey: 'your-api-key',
model: 'gpt-3.5-turbo'
});
await ai.initialize();
const response = await ai.sendMessage("Hello, AI!");
console.log(response);
}
runTest();
</script>
- Works with Static Pages: Suitable for use with GitHub Pages, Netlify, or similar static hosting.
- No Dependencies: Self-contained in a single, small JavaScript file.
- Easy Provider Switching: Change between AI providers by modifying a single parameter.
- Browser-based AI prototypes
- Adding AI features to static websites
- AI-enhanced browser extensions
- Educational projects showcasing multiple AI providers
API-LLM-Hub addresses some common challenges in web-based AI integration:
- Browser-Native: Runs directly in the browser, unlike server-side libraries.
- No Build Process: Works out of the box, without complex setup or installation.
- Static Page Compatible: Ideal for projects without a backend server.
- CORS Issue Mitigation: Helpful for providers with known cross-origin challenges.
We welcome contributions to API-LLM-Hub. Whether it's bug fixes, new provider integrations, or documentation improvements, your input is valuable.
API-LLM-Hub is available under the MIT License. Please see the LICENSE file for full details.