Interface IAudioGenerator

Abstraction over an audio generation backend (Suno, Udio, Stable Audio, ElevenLabs, Replicate, etc.).

Capability negotiation

Not every provider supports every sub-modality. The supports method lets callers (and the FallbackAudioProxy) query whether a given capability is available before invoking it.

Lifecycle

  1. Construct the provider.
  2. Call initialize with provider-specific configuration (API keys, base URLs, etc.).
  3. Use generateMusic and/or generateSFX.
  4. Optionally call shutdown to release resources.

Example

const suno: IAudioGenerator = new SunoProvider();
await suno.initialize({ apiKey: process.env.SUNO_API_KEY! });

if (suno.supports('music')) {
const result = await suno.generateMusic({ prompt: 'Ambient piano loop' });
console.log(result.audio[0].url);
}

await suno.shutdown?.();
interface IAudioGenerator {
    providerId: string;
    isInitialized: boolean;
    defaultModelId?: string;
    initialize(config): Promise<void>;
    generateMusic(request): Promise<AudioResult>;
    generateSFX?(request): Promise<AudioResult>;
    supports(capability): boolean;
    shutdown?(): Promise<void>;
}

Implemented by

Methods

  • Initialise the provider with runtime configuration.

    Parameters

    • config: Record<string, unknown>

      Provider-specific key/value pairs (API keys, endpoints, model overrides, etc.).

    Returns Promise<void>

  • Generate a sound effect from a text prompt.

    This method is optional — providers that do not support SFX generation should either omit it or have supports return false for 'sfx'.

    Parameters

    Returns Promise<AudioResult>

    A result envelope containing one or more generated audio clips.

  • Query whether this provider supports a given capability.

    Parameters

    • capability: "music" | "sfx"

      The capability to check ('music' or 'sfx').

    Returns boolean

    true if the provider can handle the requested capability.

  • Release any resources held by the provider (HTTP connections, polling loops, temp files, etc.).

    Returns Promise<void>

Properties

providerId: string

Unique identifier for this provider (e.g. 'suno', 'elevenlabs-sfx').

isInitialized: boolean

Whether initialize has been called successfully.

defaultModelId?: string

Default model used when the request omits modelId.