- Sync
- Async
Parameters
file(Union[str, bytes, BinaryIO, Path]): Document to analyse inline. Accepts a file path, bytes buffer, or file-like object.prompt(str): Instruction Morphik On-the-Fly should execute against the document.schema(dict | BaseModel | Type[BaseModel] | str, optional): Schema that enforces structured output. Accepts a plain dict, a Pydantic model or class, or a pre-serialized JSON string.ingestion_options(Dict[str, Any], optional): Controls follow-up ingestion. Supported keys:ingest(bool): Queue the file for ingestion after analysis.metadata(dict): Metadata supplied with the request. Whenschemayields a JSON object, those fields are merged into this metadata before ingestion.use_colpali(bool): Override the embedding strategy used during ingestion.folder_name(str | list[str]): Folder scope for the queued ingestion.end_user_id(str): End-user scope for the queued ingestion. Unsupported keys are ignored.
filename(str, optional): Filename override when uploading bytes or file-like objects.folder_name(str | list[str], optional): Folder scope applied to the inline request. Automatically set when calling from folder helpers; merged intoingestion_optionsif not already present.end_user_id(str, optional): End-user scope for the inline request. Automatically set when using user scope helpers; merged intoingestion_optionsif not already present.
Returns
DocumentQueryResponse: Containsstructured_output,text_output,input_metadata,combined_metadata, and ingestion status. When ingestion is requested and the schema produces a JSON object,combined_metadatareflects the union of the supplied metadata and the extracted fields used for ingestion.
Behaviour
- Structured extraction: When
schemais provided, Morphik validates the response against the schema. If the structured output is a dict, it is returned instructured_outputand copied toextracted_metadata. - Metadata merge:
combined_metadatais always derived from the originalmetadatasupplied iningestion_options. When structured extraction returns a dict, those fields are merged into the metadata before any ingestion takes place. - Ingestion queuing: Setting
ingest=Trueenqueues the document for ingestion (requireswritepermission). The response includesingestion_enqueuedand, when available, aningestion_documentstub you can monitor.
Examples
Extract structured data and ingest
- Sync
- Async
Quick inline analysis without ingestion
- Sync
- Async

