Iteration Layer
Products
Use Cases
Resources
Pricing
Documentation navigation

LangGraph

LangGraph is a good fit for stateful, long-running agents that need explicit workflow control. Use Iteration Layer inside LangGraph nodes when a graph needs deterministic file-processing steps before or after LLM reasoning.

When To Use This

Use LangGraph plus Iteration Layer when your workflow has clear stages:

  • Convert a document to Markdown
  • Extract structured fields
  • Route low-confidence results to review
  • Generate a PDF, image, or spreadsheet deliverable
  • Persist state between retries or human review steps

Install

pip install langgraph iterationlayer

Example Node

from typing import TypedDict

from iterationlayer import IterationLayer
from langgraph.graph import END, StateGraph


class WorkflowState(TypedDict):
    file_url: str
    invoice: dict


client = IterationLayer(api_key="YOUR_API_KEY")


def extract_invoice(state: WorkflowState) -> WorkflowState:
    result = client.extract_document(
        files=[
            {
                "type": "url",
                "name": "invoice.pdf",
                "url": state["file_url"],
            }
        ],
        schema={
            "fields": [
                {"name": "vendor", "type": "TEXT", "description": "Vendor name"},
                {"name": "total", "type": "CURRENCY_AMOUNT", "description": "Total amount"},
                {"name": "due_date", "type": "DATE", "description": "Payment due date"},
            ]
        },
    )

    return {**state, "invoice": result}


graph = StateGraph(WorkflowState)
graph.add_node("extract_invoice", extract_invoice)
graph.set_entry_point("extract_invoice")
graph.add_edge("extract_invoice", END)

invoice_graph = graph.compile()

Where Iteration Layer Fits

LangGraph stage Iteration Layer API
Ingest uploaded files Document to Markdown
Extract structured fields Document Extraction
Fetch public pages Website Extraction
Prepare images Image Transformation
Create visual output Image Generation
Create reports Document Generation
Create exports Sheet Generation

Production Guidance

Keep Iteration Layer calls in explicit graph nodes instead of hiding them inside broad LLM tools when the result affects control flow. This makes retries, human review, and audit records easier to reason about.

Use LLM tools when the agent should decide whether a file-processing operation is needed. Use graph nodes when the operation is mandatory.