LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-corerunnablesgraphGraphdraw_mermaid_png
    Method●Since v0.1

    draw_mermaid_png

    Draw the graph as a PNG image using Mermaid.

    Copy
    draw_mermaid_png(
      self,
      *,
      curve_style: CurveStyle = CurveStyle.LINEAR,
      node_colors: NodeStyles | None = None,
      wrap_label_n_words: int = 9,
      output_file_path: str | None = None,
      draw_method: MermaidDrawMethod = MermaidDrawMethod.API,
      background_color: str = 'white',
      padding: int = 10,
      max_retries: int = 1,
      retry_delay: float = 1.0,
      frontmatter_config: dict[str, Any] | None = None,
      base_url: str | None = None,
      proxies: dict[str, str] | None = None
    ) -> bytes

    Parameters

    NameTypeDescription
    curve_styleCurveStyle
    Default:CurveStyle.LINEAR

    The style of the edges.

    node_colorsNodeStyles | None
    Default:None

    The colors of the nodes.

    wrap_label_n_wordsint
    Default:9

    The number of words to wrap the node labels at.

    output_file_pathstr | None
    Default:None

    The path to save the image to. If None, the image is not saved.

    draw_methodMermaidDrawMethod
    Default:MermaidDrawMethod.API

    The method to use to draw the graph.

    background_colorstr
    Default:'white'

    The color of the background.

    paddingint
    Default:10

    The padding around the graph.

    max_retriesint
    Default:1

    The maximum number of retries (MermaidDrawMethod.API).

    retry_delayfloat
    Default:1.0

    The delay between retries (MermaidDrawMethod.API).

    frontmatter_configdict[str, Any] | None
    Default:None

    Mermaid frontmatter config. Can be used to customize theme and styles. Will be converted to YAML and added to the beginning of the mermaid graph.

    See more here: https://mermaid.js.org/config/configuration.html.

    Example config:

    {
        "config": {
            "theme": "neutral",
            "look": "handDrawn",
            "themeVariables": {"primaryColor": "#e2e2e2"},
        }
    }
    base_urlstr | None
    Default:None

    The base URL of the Mermaid server for rendering via API.

    proxiesdict[str, str] | None
    Default:None

    HTTP/HTTPS proxies for requests (e.g. {"http": "http://127.0.0.1:7890"}).

    View source on GitHub