Prerequisites
- Morphik API endpoint (e.g.,
http://localhost:8000
orhttps://api.morphik.ai
)- API credentials via
MORPHIK_API_KEY
(if authentication is enabled)- For the optional OpenAI example, set
OPENAI_API_KEY
1. Environment setup
2. Multimodal ingestion (ColPali)
This path indexes the original file contents directly, yielding higher accuracy for scanned pages, tables, and images.Wait for processing to complete
3. Text ingestion (OCR + chunking)
This path OCRs the document before chunking it, making the text immediately available for retrieval.4. Query with Morphik completion
Generate a completion directly using Morphik’s configured LLM.Multimodal query (ColPali)
Text query (standard)
5. Query with system prompt override
Override the default system prompt to customize the LLM’s behavior and response style.6. Retrieve chunks for your own LLM
For production workloads, retrieve Morphik’s curated chunks and forward them to your preferred LLM. This gives you full control over prompts, orchestration, and rate limits.Step 1: Retrieve relevant chunks
Step 2: Forward to your LLM (OpenAI example)
Text-only chunks with OpenAI
Multimodal chunks with OpenAI (vision)
Step 3: Using other LLM providers
The same pattern works with any LLM provider. Morphik handles retrieval and chunking; you control the completion: Anthropic Claude:7. Advanced: Custom prompt template
You can also override the prompt template that formats the context and question:Summary
Morphik’s REST API provides flexible integration options:- Managed completions: Use Morphik’s configured LLM with optional system prompt overrides
- Bring your own LLM: Retrieve curated chunks and forward to any LLM provider
- Multimodal support: Handle both text and visual content seamlessly
- Full control: Override system prompts, prompt templates, and completion parameters