A lightweight TypeScript/JavaScript SDK for accessing AI models, media downloads, image generation, games, and utilities through the ER-API platform.
npm install er-api-sdk # npm
yarn add er-api-sdk # yarn
pnpm add er-api-sdk # pnpm
- AI Models: Easy access to various AI models (Gemini 2.0, Claude, Mistral, etc.)
- Media Downloads: Download videos/audio from TikTok, Spotify, YouTube, etc.
- Image Generation: Create images from text prompts
- Games & Entertainment: Access word games and other interactive content
- Utilities: Various helper functions and tools
Many endpoints work without an API key:
// CommonJS
const { ttdl, text2img, tebakkata } = require('er-api-sdk');
// ESM
// import { ttdl, text2img, tebakkata } from 'er-api-sdk';
// Download TikTok video
const tiktokData = await ttdl('https://www.tiktok.com/@user/video/12345');
// Generate an image from text
const imageBuffer = await text2img('beautiful mountain landscape');
// Play a word game
const game = await tebakkata();
Basic AI requests work without an API key, but custom parameters require one:
// CommonJS
const { deepseek, llama3, deepcoder } = require('er-api-sdk');
// ESM
// import { deepseek, llama3, deepcoder } from 'er-api-sdk';
// Basic AI requests (no API key needed)
const response = await deepseek('Explain quantum computing');
const code = await deepcoder('Write a function to sort an array in JavaScript');
// For custom parameters, you need an API key:
const { ErApiSdk } = require('er-api-sdk');
ErApiSdk.openRouter.setApiKey('YOUR_API_KEY');
const customResponse = await llama3('Tell me about space exploration', {
temperature: 0.7,
max_tokens: 500
});
The recommended way to use API keys is through environment variables:
// Set in .env file:
// OPENROUTER_API_KEY=your_api_key_here
// In your code:
const { ErApiSdk } = require('er-api-sdk');
const sdk = ErApiSdk.fromEnv();
// Now you can use advanced features
const response = await sdk.llama3('Explain quantum computing', {
temperature: 0.8,
max_tokens: 1000
});
const { ermp3, ermp4, spotify } = require('er-api-sdk');
// Download YouTube audio
const audioData = await ermp3('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
// Download YouTube video
const videoData = await ermp4('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
// Download from Spotify
const spotifyData = await spotify('https://open.spotify.com/track/...');
const { brat, text2img } = require('er-api-sdk');
// Generate an image with Brat AI
const bratImage = await brat('hello world');
// Create a text-to-image
const textImage = await text2img('mountain landscape');
const { family100, truth, dare, tebakkata } = require('er-api-sdk');
// Family 100 game
const familyGame = await family100();
// Truth or Dare
const truthQuestion = await truth();
const dareChallenge = await dare();
// Word guessing game
const wordGame = await tebakkata();
To use AI models with custom parameters, you need an API key from ER-API Platform.
Setting your API key:
-
Environment variable (recommended):
OPENROUTER_API_KEY=your_api_key_here
-
Direct in code:
const { ErApiSdk } = require('er-api-sdk'); ErApiSdk.openRouter.setApiKey('YOUR_API_KEY');
For detailed API documentation, visit our Documentation.