import { type AIMLAPIClient } from '../client'; /** * OCR parameters for Google OCR */ export interface GoogleOCRParams { /** * The document file to be processed by the OCR model. */ document: string; /** * The MIME type of the document. */ mimeType?: 'application/pdf' | 'image/gif' | 'image/tiff' | 'image/jpeg' | 'image/png' | 'image/bmp' | 'image/webp' | 'text/html'; /** * Specific pages you want to process */ pages?: { type: 'start' | 'end' | 'range' | 'indices'; start?: number; end?: number; indices?: number[]; }; } /** * OCR parameters for Mistral OCR */ export interface MistralOCRParams { /** * Document to run OCR - can be image URL or document URL */ document: { type: 'image_url' | 'document_url'; image_url?: string; document_url?: string; }; /** * Specific pages you want to process */ pages?: string | number[] | null; /** * Include base64 images in response */ include_image_base64?: boolean; /** * Max images to extract */ image_limit?: number; /** * Minimum height and width of image to extract */ image_min_size?: number; } /** * Google OCR Response - matches the actual Google Document AI response structure */ export interface GoogleOCRResponse { pages: Array<{ blocks: Array<{ boundingBox: { normalizedVertices: Array<{ x: number; y: number; }>; }; blockType: string; confidence: number; layout: { boundingBox: { normalizedVertices: Array<{ x: number; y: number; }>; }; orientation: string; textAnchor: { textSegments: Array<{ endIndex: number; startIndex: number; }>; }; }; paragraphs: Array; text: string; }>; detectedLanguages: Array<{ languageCode: string; confidence: number; }>; dimension: { width: number; height: number; unit: string; }; provenance: any; imageQualityScores: any; }>; entities: Array; entityRelations: Array; revisions: Array; textChanges: Array; entitiesRevisions: Array; mimeType: string; text: string; shardInfo: any; error: any; docid: string; documentLayout: any; chunkedDocument: any; entityValidationOutput: any; entitiesRevisionId: string; uri: string; source: string; meta: { usage: { credits_used: number; }; }; } /** * Mistral OCR Response - matches the actual Mistral OCR response structure */ export interface MistralOCRResponse { pages: Array<{ index: number; markdown: string; images: Array<{ id: string; top_left_x: number | null; top_left_y: number | null; bottom_right_x: number | null; bottom_right_y: number | null; image_base64: string | null; }>; dimensions?: { dpi: number; height: number; width: number; }; }>; model: 'mistral-ocr-latest'; usage_info: { pages_processed: number; doc_size_bytes: number | null; }; } /** * OCR Response - union type for different OCR providers */ export type OCRResponse = GoogleOCRResponse | MistralOCRResponse; /** * Vision parameters (legacy) */ export interface VisionParams { /** * The image to analyze. */ image: string; /** * The prompt to send to the vision model. */ prompt: string; /** * The model to use. */ model?: string; /** * Maximum tokens in response. */ max_tokens?: number; /** * Temperature for sampling. */ temperature?: number; } /** * Vision Response (legacy) */ export interface VisionResponse { id: string; model: string; content: Array<{ type: 'text'; text: string; }>; usage?: { input_tokens: number; output_tokens: number; }; } /** * OCR resource for document processing */ export declare class OCR { private readonly _client; constructor(_client: AIMLAPIClient); /** * Perform OCR using Google Document AI. * @see https://docs.aimlapi.com/api-reference/ocr * * @example * ```typescript * const result = await client.ocr.google({ * document: "https://example.com/document.pdf", * mimeType: "application/pdf" * }); * console.log(result.text); * ``` */ google(params: GoogleOCRParams): Promise; /** * Perform OCR using Mistral OCR model. * @see https://docs.aimlapi.com/api-reference/ocr * * @example * ```typescript * const result = await client.ocr.mistral({ * document: { * type: "image_url", * image_url: "https://example.com/image.jpg" * }, * include_image_base64: true * }); * console.log(result.pages[0].markdown); * ``` */ mistral(params: MistralOCRParams): Promise; /** * Analyze an image using a vision model (legacy method). * @see https://docs.aimlapi.com/api-reference/vision * * @example * ```typescript * const result = await client.ocr.vision({ * image: "https://example.com/photo.jpg", * prompt: "What is in this image?", * model: "gpt-4o" * }); * console.log(result.content[0].text); * ``` */ vision(params: VisionParams): Promise; /** * Legacy process method for backward compatibility * @deprecated Use google() or mistral() instead */ process(params: { image: string; prompt?: string; model?: string; language?: string; extract_tables?: boolean; extract_key_values?: boolean; }): Promise; /** * Legacy analyze method for backward compatibility * @deprecated Use vision() instead */ analyze(params: VisionParams): Promise; } //# sourceMappingURL=ocr.d.ts.map