Skip to main content

Schema-first visualization specifications for LLMs

Project description

Vizdantic

Python Status License

Vizdantic is a schema-first visualization layer for LLMs.

It allows language models to describe what to visualize using structured, validated specifications, while developers remain in full control of how charts are rendered.


Why Vizdantic?

LLMs are good at describing intent, but unreliable at writing plotting code.

They often:

  • hallucinate APIs
  • mix incompatible chart parameters
  • produce brittle, unvalidated code

Vizdantic solves this by separating responsibilities:

LLMs choose visualization intent. Developers choose the plotting library.


What Vizdantic Does

  • Provides Pydantic schemas for common visualization types
  • Validates LLM-generated visualization intent
  • Is library-agnostic by design
  • Renders charts via optional plugins (e.g. Plotly)

Vizdantic does not replace plotting libraries. It sits between LLMs and visualization backends.


Quick Start

Install

pip install vizdantic

Validate LLM output

from vizdantic import validate llm_output = { "kind": "cartesian", "chart": "bar", "x": "category", "y": "value", "title": "Sales by Category", } spec = validate(llm_output)

Render with Plotly Example

from vizdantic.plugins.plotly import render import pandas as pd df = pd.DataFrame({ "category": ["A", "B", "C"], "value": [10, 20, 15], }) fig = render(spec, df) fig.show()

Using Vizdantic with LLMs

Vizdantic works with any LLM and supports two common integration patterns .

Prompt-based (Universal) Tool / Function Calling (Structured)
Use when your LLM doesnot support tools or function calling. Use when your LLMsupports JSON schema tools(OpenAI, Anthropic, etc.).
You embed the schema directly in the prompt. You pass the schema as a tool input contract.

Prompt-based integration

You are an assistant that creates visualization specifications. Return JSON that strictly conforms to the following schema: {{ vizdantic.schema() }} Rules: - Return JSON only - Choose the most appropriate chart type - Use column names exactly as provided

Example model output:

{ "kind":"cartesian", "chart":"bar", "x":"category", "y":"value", "title":"Sales by Category" }

Tool / function calling integration

tool = { "name": "create_visualization", "description": "Create a visualization specification", "input_schema": vizdantic.schema(), }

The LLM is now constrained to valid Vizdantic output only .


Validate and Render

Once the LLM returns JSON, the workflow is the same:

from vizdantic import validate from vizdantic.plugins.plotly import render spec = validate(llm_output) fig = render(spec, df) fig.show()

Custom Styling and Branding

Vizdantic does not control styling.

It intentionally avoids:

  • colors
  • themes
  • fonts
  • layout decisions

Vizdantic only defines visualization intent. All styling remains fully under user control.

This makes it safe to use in production environments with strict brand or design requirements.


Example: Company styling (Evil Corp)

from vizdantic.plugins.plotly import render

def evil_corp_theme(fig):
    fig.update_layout(
        template="plotly_dark",
        colorway=["#ff0000", "#000000"],
        font=dict(family="Inter"),
    )
    return fig

fig = render(spec, df)
fig = evil_corp_theme(fig)
fig.show()

The LLM decides what to visualize. Your code decides how it looks.

Vizdantic never overrides user-defined styling.

How It Works

  1. An LLM produces structured visualization intent (JSON)
  2. Vizdantic validates it using Pydantic
  3. A plugin translates the spec into a concrete chart

The schema is stable and backend-agnostic.

Rendering is handled entirely by plugins.


Plugins

Currently supported:

  • Plotly (vizdantic.plugins.plotly)

Planned:

  • Matplotlib
  • Altair
  • Vega-Lite

Each plugin exposes a simple:

render(spec, data)

function.


Status

  • Version: 0.1.0
  • Stability: Experimental
  • Breaking changes: Possible until 1.0

Vizdantic is under active development and feedback is welcome.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vizdantic-0.1.2.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vizdantic-0.1.2-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file vizdantic-0.1.2.tar.gz.

File metadata

  • Download URL: vizdantic-0.1.2.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vizdantic-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4eeefb610b80b17c1c4ea0449e5eb0943f2485605b011fbb7fa907739ad790ec
MD5 6a1f8aa7cddaa464d283826cb18a54c3
BLAKE2b-256 868596dd57e3272ce481cb64046147d44807fd6c332589204b72481126a9bf77

See more details on using hashes here.

Provenance

The following attestation bundles were made for vizdantic-0.1.2.tar.gz:

Publisher: release.yaml on ivogarais/vizdantic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vizdantic-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: vizdantic-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vizdantic-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c978bd7682e222b4a394882ea40a5ec0c6003c0c34d436b36f87d4b1adce9a8d
MD5 7e57cf097ee3ea86eb0f2325568afbb4
BLAKE2b-256 99eaf3d5ea9347694aff04c9bea41ed866d6ca0410567ee4c4d132d96ebcbf30

See more details on using hashes here.

Provenance

The following attestation bundles were made for vizdantic-0.1.2-py3-none-any.whl:

Publisher: release.yaml on ivogarais/vizdantic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page