omnilink-web
v0.2.0
Published
OmniLink Web Client SDK — integrate OmniLink AI agents into any web application
Maintainers
Readme
omnilink-web
OmniLink Web Client SDK — integrate OmniLink AI agents into any web application.
This is the browser/TypeScript counterpart to the Python omnilink-lib package, providing a typed client for every OmniLink REST endpoint.
Install
# From npm (when published)
npm install omnilink-web
# Or install from source
git clone https://github.com/omnilink/omnilink
cd omnilink/omnilink-web
npm install && npm run build && npm linkGet Your Omni Key
Before using the SDK you need an Omni Key (omk_...). Generate one with a single click:
Sign in (or create a free account) and click Generate API key. Copy the key — you will need it for every API call.
Quick Start
import { OmniLinkClient } from 'omnilink-web';
const client = new OmniLinkClient({ omniKey: 'omk_...' });
// Chat
const reply = await client.chat({
agentName: 'assistant',
prompt: 'What is 2 + 2?',
});
console.log(reply.text);API Reference
new OmniLinkClient(config)
| Option | Type | Default |
|------------|----------|--------------------------------------|
| omniKey | string | required |
| baseUrl | string | https://www.omnilink-agents.com |
| timeout | number | 30000 (ms) |
| headers | object | {} |
Chat
// Simple chat
const reply = await client.chat({
agentName: 'my-agent',
prompt: 'Hello!',
engine: 'g4-engine', // g1 = Gemini, g2 = GPT-5, g3 = Grok, g4 = Claude
});
// Streaming chat (async iterable)
for await (const chunk of client.chatStream({ agentName: 'my-agent', prompt: 'Tell me a story' })) {
process.stdout.write(chunk.text);
if (chunk.done) break;
}
// Multi-turn with messages array
const reply = await client.chat({
agentName: 'tutor',
messages: [
{ role: 'user', content: 'What is gravity?' },
{ role: 'assistant', content: 'Gravity is a force...' },
{ role: 'user', content: 'How does it work on the Moon?' },
],
});Speech-to-Text
// From a Blob (e.g., from MicrophoneRecorder)
const result = await client.transcribe(audioBlob);
console.log(result.text);
// With options
const result = await client.transcribe(audioBuffer, {
mimeType: 'audio/mp4',
language: 'fr',
});Text-to-Speech
// Get raw response with base64 audio
const tts = await client.synthesize('Hello world');
// Get audio as a Blob
const blob = await client.synthesizeToBlob('Hello world');
// Synthesize and play immediately
await client.synthesizeAndPlay('Hello world', {
languageCode: 'en-US',
speakingRate: 1.2,
});Translation
const result = await client.translate('Bonjour le monde', {
targetLanguage: 'English',
});
console.log(result.translation);Memory Management
// List agents with memory status
const { agents, memoryAgents } = await client.listAgents();
// Get conversation history
const memory = await client.getMemory('my-agent');
// Set conversation history
await client.setMemory('my-agent', [
{ role: 'user', parts: [{ text: 'Hello' }] },
{ role: 'model', parts: [{ text: 'Hi there!' }] },
]);
// Clear memory
await client.clearMemory('my-agent');Agent Profiles
const profiles = await client.listProfiles();
const profile = await client.createProfile('door-controller', {
settings: { autoLock: true },
});
await client.updateProfile(profile.id, { name: 'smart-lock' });
await client.deleteProfile(profile.id);Other Endpoints
// Service config
const config = await client.getConfig();
// Usage stats
const usage = await client.getUsage({ limit: 50 });
// Feedback
await client.sendFeedback({ response: 'Great answer!', command: 'hello' });Audio Module (opt-in)
The audio module provides browser-specific helpers for microphone recording and audio playback. It is a separate entry point to keep the core SDK lean.
import { MicrophoneRecorder, AudioPlayer } from 'omnilink-web/audio';
// Record from microphone
const recorder = new MicrophoneRecorder();
await recorder.start();
// ... user speaks ...
const blob = await recorder.stop();
// Play audio
const player = new AudioPlayer();
await player.playBlob(blob);
await player.playBase64(base64Data);
player.stop();
player.destroy();React Hooks
See demos/react/ for a complete React app with custom hooks:
import { useOmniLink } from './hooks/useOmniLink';
import { useChat } from './hooks/useChat';
import { useAudioRecorder } from './hooks/useAudioRecorder';
function App() {
const client = useOmniLink('omk_...');
const { messages, isLoading, send } = useChat(client, {
agentName: 'assistant',
engine: 'g2-engine',
});
const { isRecording, start, stop } = useAudioRecorder();
// ... render chat UI ...
}Demos
| Demo | Path | Description |
|------|------|-------------|
| Vanilla Chat | demos/vanilla/index.html | Single-file chat demo with zero dependencies |
| Vanilla Audio | demos/vanilla/audio.html | STT/TTS demo with mic recording and playback |
| Robot Control | demos/vanilla/robot.html | 2D robot simulator with AI navigation + LIDAR |
| React App | demos/react/ | Full React app with hooks for chat, STT, and profiles |
Running Demos Locally
# Build the SDK first
cd omnilink-web
npm install
npm run build
# Vanilla demos — open in browser
open demos/vanilla/index.html
# React demo
cd demos/react
npm install
npm run devPython ↔ TypeScript Method Mapping
| Python (omnilink-lib) | TypeScript (omnilink-web) |
|---|---|
| chat(prompt, agent_name=...) | chat({ agentName, prompt }) |
| list_profiles() | listProfiles() |
| create_profile(name, settings=...) | createProfile(name, { settings }) |
| update_profile(profile_id, ...) | updateProfile(profileId, { ... }) |
| delete_profile(profile_id) | deleteProfile(profileId) |
| list_agents() | listAgents() |
| get_memory(agent_name) | getMemory(agentName) |
| set_memory(agent_name, conversation) | setMemory(agentName, conversation) |
| clear_memory(agent_name) | clearMemory(agentName) |
| transcribe(audio, mime_type=...) | transcribe(audio, { mimeType }) |
| synthesize(text, ...) | synthesize(text, { ... }) |
| synthesize_to_bytes(text) | synthesizeToBlob(text) |
| translate(text, target_language=...) | translate(text, { targetLanguage }) |
| (no equivalent) | chatStream(options) |
| (no equivalent) | synthesizeAndPlay(text) |
Build
npm run build # Build ESM + CJS + declarations
npm run dev # Watch mode
npm run typecheck # Type-check without emittingLicense
MIT
