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.2.0.tar.gz (12.0 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.2.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for vizdantic-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b8b2ff2b72f4dc17311f3ae719682fbd5d286ef6de30d23a4b2cab88ee966e87
MD5 6341830684b445dbbf51443af20d4616
BLAKE2b-256 3ce1fe9fa32c520e8a371d7c84161c0d43b11adb55af2f8e463838a94ed265d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for vizdantic-0.2.0.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.2.0-py3-none-any.whl.

File metadata

  • Download URL: vizdantic-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 419a937fbcbc38c03717e776c10aac5a864d6c843a8e16a66fa018db82d631c9
MD5 fd6307411d2a92878ddf1a2f856e0f1e
BLAKE2b-256 dd4d46a6bff4173843fcedd6211bf3a762fd1db86cb807ee1ad2a0d946a99966

See more details on using hashes here.

Provenance

The following attestation bundles were made for vizdantic-0.2.0-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