Installation
Get aimatey up and running in 2 minutes.
Prerequisites
Section titled “Prerequisites”- Node.js 18.0.0 or higher
- npm 9.0.0 or higher (or yarn/pnpm)
- TypeScript 5.0+ (optional but recommended)
Quick Install
Section titled “Quick Install”Install the main package to get started quickly:
npm install @johnhenry/aimateyThis installs the umbrella package which includes commonly-used adapters and utilities.
Package-Specific Installation
Section titled “Package-Specific Installation”For more control over bundle size, install only the packages you need:
Core Packages
Section titled “Core Packages”# Essential packagesnpm install @johnhenry/aimatey-core # Bridge, Router, Middlewarenpm install @johnhenry/aimatey-types # TypeScript type definitionsnpm install @johnhenry/aimatey-errors # Error classes and utilitiesnpm install @johnhenry/aimatey-utils # Shared utility functionsFrontend Adapters
Section titled “Frontend Adapters”Choose the input format you want to use:
npm install @johnhenry/aimatey-frontend # All frontend adaptersEach format lives at its own import subpath, so bundlers only include what you import:
import { OpenAIFrontendAdapter } from '@johnhenry/aimatey-frontend/openai'; // OpenAI formatimport { AnthropicFrontendAdapter } from '@johnhenry/aimatey-frontend/anthropic'; // Anthropic formatimport { GeminiFrontendAdapter } from '@johnhenry/aimatey-frontend/gemini'; // Google Gemini formatimport { MistralFrontendAdapter } from '@johnhenry/aimatey-frontend/mistral'; // Mistral formatBackend Adapters
Section titled “Backend Adapters”Choose which AI providers you want to support:
npm install @johnhenry/aimatey-backend # All backend adapters, one packageEach provider lives at its own import subpath, so unused providers stay out of your bundle:
import { OpenAIBackendAdapter } from '@johnhenry/aimatey-backend/openai'; // OpenAIimport { AnthropicBackendAdapter } from '@johnhenry/aimatey-backend/anthropic'; // Anthropic (Claude)import { GeminiBackendAdapter } from '@johnhenry/aimatey-backend/gemini'; // Google Geminiimport { OllamaBackendAdapter } from '@johnhenry/aimatey-backend/ollama'; // Ollama (local)import { GroqBackendAdapter } from '@johnhenry/aimatey-backend/groq'; // Groq (fast inference)All backend provider subpaths
# Cloud providers@johnhenry/aimatey-backend/openai@johnhenry/aimatey-backend/anthropic@johnhenry/aimatey-backend/gemini@johnhenry/aimatey-backend/mistral@johnhenry/aimatey-backend/cohere@johnhenry/aimatey-backend/groq@johnhenry/aimatey-backend/ai21@johnhenry/aimatey-backend/anyscale@johnhenry/aimatey-backend/aws-bedrock@johnhenry/aimatey-backend/azure-openai@johnhenry/aimatey-backend/cerebras@johnhenry/aimatey-backend/cloudflare@johnhenry/aimatey-backend/dashscope@johnhenry/aimatey-backend/deepinfra@johnhenry/aimatey-backend/deepseek@johnhenry/aimatey-backend/fireworks@johnhenry/aimatey-backend/github-models@johnhenry/aimatey-backend/huggingface@johnhenry/aimatey-backend/inception@johnhenry/aimatey-backend/moonshot@johnhenry/aimatey-backend/nvidia@johnhenry/aimatey-backend/omniroute@johnhenry/aimatey-backend/openrouter@johnhenry/aimatey-backend/perplexity@johnhenry/aimatey-backend/replicate@johnhenry/aimatey-backend/sambanova@johnhenry/aimatey-backend/together-ai@johnhenry/aimatey-backend/xai
# Local/Self-Hosted@johnhenry/aimatey-backend/ollama@johnhenry/aimatey-backend/lmstudioOptional Packages
Section titled “Optional Packages”# Middleware (logging, caching, retry, etc.)npm install @johnhenry/aimatey-middleware
# HTTP server integrationnpm install @johnhenry/aimatey-http # Express, Fastify, Hono, Node.js http
# React hooksnpm install @johnhenry/aimatey-react-corenpm install @johnhenry/aimatey-react-hooks
# SDK wrappers (drop-in replacements)npm install @johnhenry/aimatey-wrapper
# CLI toolsnpm install @johnhenry/aimatey-cli
# Testing utilitiesnpm install @johnhenry/aimatey-testingVerify Installation
Section titled “Verify Installation”Create a simple test file to verify installation:
import { Bridge } from '@johnhenry/aimatey-core';import { OpenAIFrontendAdapter } from '@johnhenry/aimatey-frontend/openai';import { OpenAIBackendAdapter } from '@johnhenry/aimatey-backend/openai';
console.log('aimatey installed successfully!');
const bridge = new Bridge( new OpenAIFrontendAdapter(), new OpenAIBackendAdapter({ apiKey: 'test-key' }));
console.log('Bridge created:', bridge ? '✓' : '✗');Run it:
npx tsx test.ts# Should output: aimatey installed successfully!# Bridge created: ✓Environment Setup
Section titled “Environment Setup”1. Create Environment File
Section titled “1. Create Environment File”Create a .env file in your project root:
# OpenAIOPENAI_API_KEY=sk-...
# Anthropic (Claude)ANTHROPIC_API_KEY=sk-ant-...
# Google GeminiGOOGLE_API_KEY=...
# Other providers (as needed)DEEPSEEK_API_KEY=...GROQ_API_KEY=...MISTRAL_API_KEY=...HUGGINGFACE_API_KEY=...
# Local models (optional)OLLAMA_BASE_URL=http://localhost:11434LMSTUDIO_BASE_URL=http://localhost:12342. Load Environment Variables
Section titled “2. Load Environment Variables”Node.js
Section titled “Node.js”npm install dotenvimport 'dotenv/config';
const apiKey = process.env.ANTHROPIC_API_KEY;TypeScript with Vite/Vitest
Section titled “TypeScript with Vite/Vitest”Environment variables are loaded automatically from .env files.
const apiKey = import.meta.env.VITE_ANTHROPIC_API_KEY;TypeScript Configuration
Section titled “TypeScript Configuration”For optimal TypeScript support, configure your tsconfig.json:
{ "compilerOptions": { "target": "ES2020", "module": "ESNext", "moduleResolution": "bundler", "lib": ["ES2020"], "strict": true, "esModuleInterop": true, "skipLibCheck": true, "resolveJsonModule": true, "allowSyntheticDefaultImports": true }}Installation by Use Case
Section titled “Installation by Use Case”For Chat Applications
Section titled “For Chat Applications”npm install @johnhenry/aimatey-core \ @johnhenry/aimatey-frontend \ @johnhenry/aimatey-backend \ @johnhenry/aimatey-middlewareimport { OpenAIFrontendAdapter } from '@johnhenry/aimatey-frontend/openai';import { AnthropicBackendAdapter } from '@johnhenry/aimatey-backend/anthropic';For HTTP APIs
Section titled “For HTTP APIs”npm install @johnhenry/aimatey-core \ @johnhenry/aimatey-frontend \ @johnhenry/aimatey-backend \ @johnhenry/aimatey-httpimport { OpenAIFrontendAdapter } from '@johnhenry/aimatey-frontend/openai';For React Apps
Section titled “For React Apps”npm install @johnhenry/aimatey-core \ @johnhenry/aimatey-frontend \ @johnhenry/aimatey-backend \ @johnhenry/aimatey-react-core \ @johnhenry/aimatey-react-hooksimport { OpenAIFrontendAdapter } from '@johnhenry/aimatey-frontend/openai';import { OpenAIBackendAdapter } from '@johnhenry/aimatey-backend/openai';For Local Development
Section titled “For Local Development”npm install @johnhenry/aimatey-core \ @johnhenry/aimatey-frontend \ @johnhenry/aimatey-backendimport { OpenAIFrontendAdapter } from '@johnhenry/aimatey-frontend/openai';import { OllamaBackendAdapter } from '@johnhenry/aimatey-backend/ollama';Then install and run Ollama:
# Install Ollamacurl -fsSL https://ollama.ai/install.sh | sh
# Pull a modelollama pull llama3.2
# Ollama server runs on http://localhost:11434Troubleshooting
Section titled “Troubleshooting”Module Not Found Error
Section titled “Module Not Found Error”Error: Cannot find module '@johnhenry/aimatey-core'Solution: Ensure you’ve installed the package:
npm install @johnhenry/aimatey-coreType Errors in TypeScript
Section titled “Type Errors in TypeScript”Could not find a declaration file for module '@johnhenry/aimatey-core'Solution: Install type definitions:
npm install @johnhenry/aimatey-typesESM vs CommonJS Issues
Section titled “ESM vs CommonJS Issues”aimatey is an ES Module (ESM) package. If you’re using CommonJS:
package.json:
{ "type": "module"}Or use .mjs file extensions.
Import Path Issues
Section titled “Import Path Issues”Use full import paths including the adapter name:
✅ Correct:
import { OpenAIFrontendAdapter } from '@johnhenry/aimatey-frontend/openai';import { AnthropicBackendAdapter } from '@johnhenry/aimatey-backend/anthropic';❌ Incorrect:
import { OpenAIFrontendAdapter } from '@johnhenry/aimatey-frontend';Next Steps
Section titled “Next Steps”- Quick Start - Build your first bridge
- Core Concepts - Understand the architecture
- Your First Bridge - Step-by-step tutorial
- Examples - Explore working code
Package Versions
Section titled “Package Versions”All aimatey packages use synchronized versioning. Install matching versions:
# Good (matching versions)@johnhenry/[email protected]@johnhenry/[email protected]@johnhenry/[email protected]
# Avoid (mismatched versions)@johnhenry/[email protected]@johnhenry/[email protected]Check the latest version on npm.