Unified AI Adapter Library. For Ollama, Gemini, Openai
Install package:
# ✨ Auto-detect
npx nypm install @shba007/unai
# npm
npm install @shba007/unai
# yarn
yarn add @shba007/unai
# pnpm
pnpm install @shba007/unai
# bun
bun install @shba007/unai
Code:
No Stream
import { initAI } from '@shba007/unai'
const ai = initAI()
const result = await ai.run('@Google/gemini-1.5-flash-8b', {
prompt: 'What is the sky color',
})
console.log({ result: result.content })
Stream
import { initAI, readStream } from '@shba007/unai'
const ai = initAI()
const result = await ai.run('@Google/gemini-1.5-flash-8b', {
prompt: 'write 1 to 100',
stream: true,
})
readStream(result.content, ({ delta, total }) => {
process.stdout.write(delta)
})
Feature | Ollama | Gemini | OpenAI | Perplexity | Anthropic | X | Groq |
---|---|---|---|---|---|---|---|
Text (Unstructured) Input | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ |
Text (Structured) Input | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ |
Text (Unstructured) Output | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ |
Text (Structured) Output | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
Streamed Response | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ |
Document Input | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
Document Output | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
Image Input | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ |
Image Output | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
Audio Input | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
Audio Output | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
JSON Mode | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
Function Calling/Tool Use | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
Memory (STM/LTM) | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
- @OpenAI/o1:2024-12-17
- @OpenAI/o1:latest
- @OpenAI/o3-mini:2025-01-31
- @OpenAI/o3-mini:latest
- @Perplexity/sonar
- gpt-4o-mini-2024-07-18 and later
- gpt-4o-2024-08-06 and later
- o1-2024-12-17 and later
- o3-mini-2025-1-31 and later
- gpt-4o-mini-2024-07-18 and later
- gpt-4o-2024-08-06 and later
- o1-2024-12-17 and later