Prerequisites
- Install the Morphik SDK:
npm install morphik
- Provide credentials via
MORPHIK_API_KEY
- For the optional OpenAI example, set
OPENAI_API_KEY
and (optionally)OPENAI_MODEL
1. Initialize the Morphik client
2. Helper utilities
3. Multimodal workflow (direct file indexing)
This path indexes the original file contents directly, yielding higher accuracy for scanned pages, tables, and images.Retrieve multimodal chunks first
- ask Morphik to draft the answer for you, or
- forward the curated chunks to your own LLM (see Use your own LLM).
Option A: generate a Morphik completion (multimodal)
4. Text workflow (OCR + chunking)
This path OCRs the document before chunking it, making the text immediately available for retrieval.Retrieve text chunks first
- stick with Morphik completions for a managed response, or
- jump to Use your own LLM to prompt your custom model with these chunks.