@kymamediagroup/mila-sdk
v1.0.7
Published
Official Node.js/TypeScript SDK for the Mila Enterprise API (Quantum-Aion Architecture)
Maintainers
Readme
@kymamediagroup/mila-sdk
The official Node.js / TypeScript SDK for the Mila Enterprise API (Quantum-Aion Architecture).
Installation
npm install @kymamediagroup/mila-sdk
Quick Start💡 Dedicated Endpoint Resolution: Every enterprise client is provisioned with an isolated Cloud Run endpoint URL. Supply your full dedicated endpoint URL and Enterprise Security Key (ESK) in the SDK constructor.TypeScriptimport { MilaClient } from '@kymamediagroup/mila-sdk';
const mila = new MilaClient({
endpoint: 'https://mila-enterprise-milahub-[CLIENT_ID].us-west2.run.app/generateText',
esk: process.env.MILA_API_KEY
});
async function main() {
// 1. Standard Text Generation
const textRes = await mila.generate({
prompt: "Outline a disaster recovery plan.",
persona: "mila_admin"
});
console.log(textRes.results[0].data.text);
// 2. Structured Data (JSON Mode)
const jsonRes = await mila.generate({
prompt: "Extract the names from this text: Alice and Bob.",
persona: "data_analyst",
response_schema: {
type: "object",
properties: {
names: { type: "array", items: { type: "string" } }
}
}
});
console.log(jsonRes.results[0].data.json_output); // Fully parsed object
// 3. Image Generation
const imageUrl = await mila.generateImage("A sleek, futuristic workstation");
console.log("Rendered Image:", imageUrl);
}
main();
Handling Batch Responses & Partial SuccessMila guarantees an HTTP 200 on batch requests via Partial Success Architecture. Always check result.status:TypeScriptconst response = await mila.generate({ prompts: ["Prompt 1", "Prompt 2"] });
for (const result of response.results) {
if (result.status === 'error') {
console.error(`Item ${result.prompt_index} failed:`, result.error);
} else {
console.log(`Success:`, result.data.text);
}
}
Authentication & Security Protocol 🔑Your Enterprise Security Key (ESK) is a production secret handling Authentication, Access Control, and Quotas.CRITICAL SECURITY MANDATENO CLIENT-SIDE USE: Never expose your ESK in a browser, frontend, or mobile application.SERVER-SIDE ONLY: All API calls must be executed from a secure backend or proxy server.ENVIRONMENT VARIABLES: Store your key in environment variables (e.g., process.env.MILA_API_KEY), never hardcoded in git.Master Payload SchemaFieldTypeRequiredDefaultDescriptionpromptstringYES*N/ACore instruction. Prefix with /image [prompt] for image synthesis.promptsstring[]NoN/AArray of prompts for server-side batch processing.personastringNo"mila_admin"System personality kernel (See Persona Matrix).response_schemastring/objectNonullSchema object forcing strict parsed json_output.image_datastringNonullRaw Base64 image payload.mime_typestringNo"image/jpeg"Image MIME type.use_web_searchbooleanNofalseSet true to enable external web search grounding.* Either prompt or prompts must be provided.The Persona Matrix 👥IDArchetypeBehavior ProfileBest Use Casemila_adminThe DiplomatBalanced, professional, concise.General Chat, Support Bots.code_architectThe EngineerTechnical, terse. Markdown outputs.Coding Assistants, SQL.marketing_guruThe CopywriterPersuasive, emotional, marketing copy.Ad Copy, Social Media.data_analystThe QuantLogical, structured tabular outputs.Financial Reports, Data.web_navigatorThe ResearcherInquisitive. Triggers Web Search.News, Competitor Analysis.study_buddyThe TutorSocratic, step-by-step logic.EdTech, Learning Platforms.creative_writerThe NovelistNarrative-focused and descriptive.Storytelling, Ghostwriting.Troubleshooting & Gateway Errors 🚨HTTP StatusMeaningSolution400 Bad RequestMalformed body or missing promptVerify payload syntax and required parameters.401 UnauthorizedInvalid or missing ESKCheck Authorization: Bearer header configuration.429 Too Many RequestsConcurrency/Rate limit hitNative SDK exponential backoff will automatically retry.500 Internal ErrorTemporary upstream gateway issueRetry after backoff interval.