@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio
147 lines (146 loc) • 3.91 kB
TypeScript
/**
* Image Generation Service
*
* Handles AI image generation using NeuroLink SDK with configurable providers
* and models. Supports reference images and PDFs for contextual generation.
*
* @packageDocumentation
* @module @juspay/neurolink/image-gen
* @category ImageGeneration
*
* @example
* ```typescript
* import { ImageGenService } from '@juspay/neurolink';
*
* const service = new ImageGenService();
*
* const result = await service.generate({
* prompt: 'A serene mountain landscape at sunset',
* style: 'photorealistic',
* aspectRatio: '16:9'
* });
*
* if (result.success && result.imageBuffer) {
* fs.writeFileSync('output.png', result.imageBuffer);
* }
* ```
*/
import type { ImageGenConfig, ImageGenOptions, ImageGenResult } from "../types/index.js";
/**
* NeuroLink instance type (avoiding circular dependencies)
*/
/**
* Image generation service for AI-powered image creation
*
* Uses NeuroLink SDK to generate images with support for:
* - Multiple providers (Vertex AI, OpenAI, etc.)
* - Reference images for style guidance
* - PDF documents for contextual generation
* - Configurable aspect ratios and styles
*
* @example Basic usage
* ```typescript
* const service = new ImageGenService();
* const result = await service.generate({
* prompt: 'A cute robot playing chess'
* });
* ```
*
* @example With custom configuration
* ```typescript
* const service = new ImageGenService({
* defaultProvider: 'openai',
* defaultModel: 'dall-e-3',
* timeout: 60000
* });
* ```
*/
export declare class ImageGenService {
private config;
private neurolinkInstance;
private instanceId;
/**
* Create a new ImageGenService instance
*
* @param config - Optional configuration overrides
*/
constructor(config?: Partial<ImageGenConfig>);
/**
* Get or create the NeuroLink instance
* Uses dynamic import to avoid circular dependencies
*
* @returns NeuroLink instance for image generation
*/
private getNeuroLink;
/**
* Generate an image from a text prompt
*
* @param options - Generation options including prompt, style, etc.
* @returns Promise resolving to generation result
*
* @example Simple generation
* ```typescript
* const result = await service.generate({
* prompt: 'A futuristic cityscape'
* });
* ```
*
* @example With reference images
* ```typescript
* const referenceImage = fs.readFileSync('style-reference.jpg');
* const result = await service.generate({
* prompt: 'A portrait in this style',
* images: [referenceImage],
* aspectRatio: '1:1'
* });
* ```
*/
generate(options: ImageGenOptions): Promise<ImageGenResult>;
/**
* Extract image data from various result formats
*
* Handles multiple output formats:
* - result.imageOutput?.base64
* - result.images?.[0]
* - data:image URI in content
* - Buffer directly
*
* @param result - Raw result from NeuroLink generate
* @returns Extracted image data or null
*/
private extractImageFromResult;
/**
* Check if image generation is enabled
*/
isEnabled(): boolean;
/**
* Get the default model
*/
getModel(): string;
/**
* Get the default provider
*/
getProvider(): string;
/**
* Get the service configuration
*/
getConfig(): Readonly<ImageGenConfig>;
/**
* Get the service instance ID (for debugging)
*/
getInstanceId(): string;
/**
* Update service configuration
*
* @param config - Partial configuration to merge
*/
updateConfig(config: Partial<ImageGenConfig>): void;
/**
* Enable image generation
*/
enable(): void;
/**
* Disable image generation
*/
disable(): void;
}