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.3.tar.gz (10.5 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.3-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vizdantic-0.1.3.tar.gz
  • Upload date:
  • Size: 10.5 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.3.tar.gz
Algorithm Hash digest
SHA256 824b6960ec08f06850fa0deb2fe71ec9973078d349af9b6c40a56e69dff42bbe
MD5 64b1ca4aa452775161d4faa511c9c27e
BLAKE2b-256 a0c517b787d2e29851e11ef9a93d0bb100f12eeb6ec3f076f00a621c1cc6ffdd

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: vizdantic-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.5 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6828b461a2b4de396c0f1e7c9d60fe0a6d4c043d1f3b30dca99fe1be970885b4
MD5 fc7e4080b91b0afdcfc798fdfd6795c8
BLAKE2b-256 f33db95375bce9be45c994c120da3f123c9b43c02352032498dbb5f5e465f3bc

See more details on using hashes here.

Provenance

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