UNPKG

magically-sdk

Version:

Official SDK for Magically - Build mobile apps with AI

40 lines (39 loc) 1.74 kB
import { MagicallyAuth } from './MagicallyAuth'; import { SDKConfig, LLMMessage, InvokeOptions, ChatOptions, ImageOptions, InvokeTextResponse, ChatResponse, SingleImageResponse, MultipleImageResponse, ModelsResponse } from './types'; export declare class MagicallyLLM { private config; private auth; private logger; constructor(config: SDKConfig, auth: MagicallyAuth); /** * Generate text or structured output using AI * @param prompt - The text prompt for generation * @param options - Optional parameters (model, temperature, response_json_schema, images) * @returns Generated text or structured object based on schema */ invoke<T = InvokeTextResponse>(prompt: string, options?: InvokeOptions): Promise<T>; /** * Chat with AI using conversation messages * @param messages - Array of conversation messages (supports images in content) * @param options - Optional parameters (model, temperature, stream) * @returns AI response message with usage info */ chat(messages: LLMMessage[], options?: ChatOptions): Promise<ChatResponse>; /** * Generate images using AI * @param prompt - Description of the image to generate * @param options - Optional parameters (model, size, quality, n) * @returns Image URL(s) and metadata */ image(prompt: string, options?: ImageOptions): Promise<SingleImageResponse | MultipleImageResponse>; /** * Get available AI models * @returns List of available text and image models with defaults */ models(): Promise<ModelsResponse>; /** * Handle API errors with structured error information for AI debugging */ private handleAPIError; private getApiUrl; }