Skip to main content
caution
The feature described on this page is in preparation. Details may change without notice.

AICU TypeScript SDK

@aicu/api-client - the official TypeScript/JavaScript SDK (Coming Soon)

Installation​

npm install @aicu/api-client
# or
pnpm add @aicu/api-client
# or
bun add @aicu/api-client

Quick start​

import { AicuClient } from '@aicu/api-client';

const aicu = new AicuClient('aicu_live_xxx');

// Generate speech from text
const audio = await aicu.tts.generate({
text: 'こんにちは、世界!',
voice: 'ono_anna',
});

// Save it to a file
await Bun.write('output.mp3', audio);

// Or play it with the Web Audio API
const audioUrl = URL.createObjectURL(new Blob([audio], { type: 'audio/mpeg' }));
const audioElement = new Audio(audioUrl);
await audioElement.play();

API reference​

AicuClient​

const client = new AicuClient(apiKey: string, options?: {
baseUrl?: string; // default: 'https://api.aicu.ai/v1'
timeout?: number; // default: 30000 (ms)
});

tts.generate()​

const audio = await client.tts.generate({
text: string; // Required: the text to speak
voice: string; // Required: voice ID
language?: string; // Optional: 'Japanese' | 'English' | 'Chinese'
format?: 'mp3' | 'wav'; // Optional: output format
seed?: number; // Optional: seed for reproducibility
instruct?: string; // Optional: style direction
});

// Returns: ArrayBuffer (audio data)

tts.voices()​

const voices = await client.tts.voices();
// Returns: Voice[]

interface Voice {
id: string;
name: string;
description: string;
languages: string[];
}

credits.balance()​

const balance = await client.credits.balance();
// Returns: { tap: number; ap: number; total: number }

Examples​

Next.js Server Action​

// app/actions/tts.ts
'use server';

import { AicuClient } from '@aicu/api-client';

const aicu = new AicuClient(process.env.AICU_API_KEY!);

export async function generateTTS(text: string) {
const audio = await aicu.tts.generate({
text,
voice: 'ono_anna',
});

return Buffer.from(audio).toString('base64');
}

Streaming (Coming Soon)​

// For long text, stream the audio in chunks
const stream = await aicu.tts.stream({
text: longText,
voice: 'ono_anna',
});

for await (const chunk of stream) {
// Process audio chunks
}

Error handling​

import { AicuClient, AicuError } from '@aicu/api-client';

try {
const audio = await aicu.tts.generate({ text, voice: 'ono_anna' });
} catch (error) {
if (error instanceof AicuError) {
switch (error.code) {
case 'UNAUTHORIZED':
console.error('Invalid API key');
break;
case 'INSUFFICIENT_CREDITS':
console.error('Not enough credits');
break;
case 'RATE_LIMITED':
console.error('Rate limit exceeded');
break;
default:
console.error('API error:', error.message);
}
}
}

Current status​

The SDK is still in development. We will announce the release on News and in our newsletter, Weekly AICU.

In the meantime, call the REST API directly.


Support​

© 2026 AICU Inc.