@japro/luma-sdk
v0.2.8
Published
Luma API SDK
Readme
Luma SDK
TypeScript SDK for the Luma platform used by Mentingo.
It provides two separate clients:
- HTTP client for public API operations (drafts, ingestion, chat, assets, configuration)
- Socket client for realtime audio/voice mentor flows
Installation
pnpm add @japro/luma-sdk
# or
npm install @japro/luma-sdk
# or
yarn add @japro/luma-sdkQuick Start (HTTP)
import { createLumaClient } from "@japro/luma-sdk";
const client = createLumaClient({
baseURL: "https://your-luma-api.example.com",
apiKey: process.env.LUMA_API_KEY,
});
const draft = await client.createDraft({
integrationId: "course-123",
draftName: "Cybersecurity Fundamentals",
courseLanguage: "en",
});Quick Start (Socket)
import {
createLumaSocket,
LUMA_AUDIO_ACTIONS,
LUMA_AUDIO_FORMATS,
LUMA_SOCKET_MESSAGE_TYPES,
} from "@japro/luma-sdk";
const socket = createLumaSocket({
baseURL: "https://your-luma-api.example.com",
apiKey: process.env.LUMA_API_KEY,
socketData: {
sessionId: "session-123",
userId: "user-123",
lessonId: "lesson-123",
},
});
socket
.onServerConnected((payload) => console.log("connected", payload))
.onMentorTranscription((payload) => console.log("transcription", payload))
.onAudioOutputChunk((payload) => console.log("audio chunk", payload));
socket.connect();
socket.startAudio({
type: LUMA_SOCKET_MESSAGE_TYPES.AUDIO_START,
audioAction: LUMA_AUDIO_ACTIONS.VOICE_MENTOR,
meta: { sr: 16000, channels: 1, format: LUMA_AUDIO_FORMATS.PCM_S16LE },
});
socket.sendAudioChunk(
{
type: LUMA_SOCKET_MESSAGE_TYPES.AUDIO_CHUNK,
meta: { seq: 1, sr: 16000, samples: 320, tsMs: Date.now() },
},
new Uint8Array([0, 1, 2]),
);
socket.stopAudio();HTTP Client API
createLumaClient(opts)
Options:
baseURL?: string- Luma API base URL.apiKey?: string- API key sent asX-API-Key.httpsAgent?: Agent- custom Node.js HTTPS agent.allowInsecureTls?: boolean- iftrue, usesrejectUnauthorized: false(dev only).
Methods:
chat(opts)createDraft(opts)ingestDraftFile(opts)deleteIngestedDocument(opts)getDraftFiles(opts)getDraft(opts)getDraftMessages(opts)getGeneratedCourse(opts)deleteDraft(opts)getAssets(opts)getConfiguration()
Socket Client API
createLumaSocket(opts)
Options:
baseURL?: stringapiKey?: stringallowInsecureTls?: booleansocketData?: { sessionId?: string; userId?: string; lessonId?: string }
Emit helpers:
startAudio(payload)-> emitsstart_audiosendAudioChunk(payload, chunk)-> emitsaudio_chunkstopAudio(payload?)-> emitsaudio_stopsendMentorTextDelta(payload)-> emitsmentor_text_deltasendMentorTextEnd(payload)-> emitsmentor_text_endsendMentorTextError(payload)-> emitsmentor_text_errorsendPing(payload?)-> emitsping
Listener helpers:
onServerConnected(handler)-> listensserver:connectedonAudioStarted(handler)-> listensaudio:startedonAudioChunked(handler)-> listensaudio:chunkedonAudioStopped(handler)-> listensaudio:stoppedonMentorTranscription(handler)-> listensmentor:transcriptiononAudioOutputChunk(handler)-> listensaudio:output:chunkonAudioOutputInterrupted(handler)-> listensaudio:output:interruptedonAudioOutputError(handler)-> listensaudio:output:erroronAudioOutputComplete(handler)-> listensaudio:output:complete
Public Exports
- HTTP:
createLumaClient,LumaClient,LumaClientOptions - Socket:
createLumaSocket,LumaSocket, socket payload/event types fromsrc/socket/types.ts - Shared API/domain types from
src/types.ts
Development
pnpm install
pnpm build
pnpm lintRegenerate API client from OpenAPI schema
pnpm generate:clientUses src/api/api-schema-public.json to regenerate src/api/generated-api.ts.
Notes
- Built with
tsupand ships ESM + CJS. - HTTP auth uses the
X-API-Keyheader. - Keep API keys out of source control.
