Overview
Struktur exports a comprehensive set of TypeScript types for type-safe extraction workflows. All types are exported from the main package entry point.Artifact types
Artifact
The core interface representing a pre-parsed document with text and optional media content.Unique identifier for this artifact.
The type of artifact:
"text", "image", "pdf", or "file".Async function that returns the raw buffer of the original source.
Array of content slices. Each slice can contain text and/or media for a specific page or section.
Optional metadata associated with the artifact.
Optional pre-calculated token count for this artifact.
ArtifactType
Union type defining the possible artifact types.ArtifactContent
Represents a single content slice within an artifact.Optional page number for multi-page documents.
Text content for this slice.
Array of images associated with this content slice.
ArtifactImage
Represents an image within artifact content.Fixed value identifying this as an image.
URL to the image resource.
Base64-encoded image data.
Raw image buffer.
Optional alt text or OCR text associated with the image.
X-coordinate for positioned images.
Y-coordinate for positioned images.
Image width in pixels or points.
Image height in pixels or points.
Extraction types
ExtractionOptions
Configuration object passed to theextract() function.
Array of artifacts to extract from.
JSON Schema for validation and type inference.
Strategy instance that defines the extraction workflow.
Optional event handlers for progress and debugging.
ExtractionResult
The result returned byextract().
The extracted data, validated against the schema. Will be
null (cast to T) if extraction failed.Token usage statistics.
Error object if extraction failed.
ExtractionStrategy
Interface that all strategy implementations must satisfy.Unique identifier for the strategy (e.g., “simple”, “parallel”).
Executes the extraction workflow.
Optional method that returns the estimated number of steps for progress tracking.
Usage
Token usage statistics.Total input tokens consumed.
Total output tokens generated.
Sum of input and output tokens.
Event types
ExtractionEvents
Event handlers for monitoring extraction progress.Called at each major step.
Called when LLM messages are exchanged.
Called during batch processing.
Called after each LLM call with usage stats.
StepInfo
MessageInfo
ProgressInfo
TokenUsageInfo
Usage with an optional model identifier.
Schema types
TypedJSONSchema
Ajv’s typed JSON Schema type for type inference.JSONSchemaType<T>, the extract() function can infer the type of result.data.
AnyJSONSchema
Untyped JSON Schema.Usage example
See also
- extract() - Core extraction function
- Artifacts - Working with artifacts
- Strategies - Extraction strategies