Dhi Python logo

Dhi Python

Community
justrach
dhi-python

Ultra-fast data validation library for Python (520x faster than Pydantic). Use when building validated data models, API request/response schemas, or configuration objects. Provides Pydantic v2-compatible BaseModel API with Zig-powered native validation.

Overview

Publisherjustrach
Repositorydhi
Skill namedhi-python
Stars
385
Forks
6
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by justrach on GitHub. Read the source before you install it.

Installation

Install the Dhi Python AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/justrach/dhi.git /tmp/dhi
mkdir -p .claude/skills
cp -r /tmp/dhi/python-bindings/dhi-python .claude/skills/dhi-python
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Dhi Python in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Dhi Python on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Dhi Python is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

dhi - Ultra-Fast Python Validation

Overview

dhi is a high-performance data validation library for Python, powered by Zig and native C extensions. It provides a Pydantic v2-compatible API while being 520x faster for validation operations.

Use dhi when you need:

  • Validated data models for APIs
  • Fast request/response parsing
  • Configuration object validation
  • Type-safe data structures

Installation

bash
pip install dhi

Quick Start

Basic Model

python
from dhi import BaseModel, Field
from typing import Annotated

class User(BaseModel):
    name: Annotated[str, Field(min_length=1, max_length=100)]
    age: Annotated[int, Field(ge=0, le=120)]
    email: str
    score: float = 0.0

# Create and validate
user = User(name="Alice", age=25, email="alice@example.com")
print(user.model_dump())
# {'name': 'Alice', 'age': 25, 'email': 'alice@example.com', 'score': 0.0}

Nested Models

python
from dhi import BaseModel

class Address(BaseModel):
    street: str
    city: str
    zip_code: str

class Person(BaseModel):
    name: str
    address: Address  # Nested model

# Works with dict or pre-built model
person = Person(
    name="Bob",
    address={"street": "123 Main St", "city": "NYC", "zip_code": "10001"}
)

Constrained Types

python
from dhi import BaseModel, PositiveInt, EmailStr, HttpUrl
from typing import Annotated

class Account(BaseModel):
    user_id: PositiveInt
    email: EmailStr
    website: HttpUrl
    balance: Annotated[float, Field(ge=0)]

Key Features

Pydantic v2 Compatible API

python
# All standard Pydantic methods work
user = User.model_validate({"name": "Alice", "age": 25, "email": "a@b.com"})
user_dict = user.model_dump()
user_json = user.model_dump_json()
user_copy = user.model_copy(update={"age": 26})

ConfigDict Support

python
from dhi import BaseModel, ConfigDict

class StrictUser(BaseModel):
    model_config = ConfigDict(
        strict=True,
        frozen=True,
        extra='forbid',
        str_strip_whitespace=True
    )

    name: str
    age: int

Validators

python
from dhi import BaseModel, field_validator, model_validator

class User(BaseModel):
    name: str
    password: str
    confirm_password: str

    @field_validator('name')
    @classmethod
    def name_must_be_alpha(cls, v):
        if not v.isalpha():
            raise ValueError('must be alphabetic')
        return v.title()

    @model_validator(mode='after')
    def passwords_match(self):
        if self.password != self.confirm_password:
            raise ValueError('passwords do not match')
        return self

Computed Fields

python
from dhi import BaseModel, computed_field

class Rectangle(BaseModel):
    width: float
    height: float

    @computed_field
    @property
    def area(self) -> float:
        return self.width * self.height

Private Attributes

python
from dhi import BaseModel, PrivateAttr

class Model(BaseModel):
    name: str
    _secret: str = PrivateAttr(default="hidden")
    _counter: int = PrivateAttr(default_factory=int)

Available Constrained Types

String Types

  • EmailStr - Valid email addresses
  • HttpUrl / AnyUrl - URL validation
  • IPvAnyAddress - IP address validation

Numeric Types

  • PositiveInt / NegativeInt
  • PositiveFloat / NegativeFloat
  • NonNegativeInt / NonPositiveInt
  • StrictInt / StrictFloat / StrictBool

Other Types

  • SecretStr / SecretBytes - Masked sensitive data
  • Json - JSON string parsing
  • UUID types

Field Constraints

python
from dhi import Field

# Numeric constraints
Field(gt=0)           # Greater than
Field(ge=0)           # Greater than or equal
Field(lt=100)         # Less than
Field(le=100)         # Less than or equal
Field(multiple_of=5)  # Must be multiple of

# String constraints
Field(min_length=1)
Field(max_length=100)
Field(pattern=r"^[a-z]+$")  # Regex pattern

# Other
Field(strict=True)    # No type coercion
Field(frozen=True)    # Immutable field
Field(exclude=True)   # Exclude from serialization

Serialization Options

python
user.model_dump(
    mode='json',           # JSON-compatible types
    by_alias=True,         # Use field aliases
    exclude_unset=True,    # Exclude fields not explicitly set
    exclude_defaults=True, # Exclude fields with default values
    exclude_none=True,     # Exclude None values
    include={'name'},      # Only include specific fields
    exclude={'password'},  # Exclude specific fields
)

Performance

dhi is 520x faster than Pydantic for validation operations:

OperationdhiPydanticSpeedup
Basic model2.55M/sec2.16M/sec1.18x
Nested model2.59M/sec2.23M/sec1.16x
model_dump4.37M/sec1.97M/sec2.22x
model_dump_json2.56M/sec1.77M/sec1.45x

When to Use

Use dhi when:

  • Building high-performance APIs (FastAPI, Flask, etc.)
  • Processing large volumes of validated data
  • Need Pydantic compatibility with better performance
  • Building configuration systems with validation

Migration from Pydantic

dhi is designed as a drop-in replacement:

python
# Before (Pydantic)
from pydantic import BaseModel, Field

# After (dhi)
from dhi import BaseModel, Field

Most Pydantic v2 code works unchanged with dhi.


Resources

Frequently asked questions

What does the Dhi Python AI skill do?

Ultra-fast data validation library for Python (520x faster than Pydantic). Use when building validated data models, API request/response schemas, or configuration objects. Provides Pydantic v2-compatible BaseModel API with Zig-powered native validation.

Why use Dhi Python on TypingMind?

Because you install it once and use it with any model. Dhi Python is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Dhi Python in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/justrach/dhi/tree/main/python-bindings/dhi-python. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Dhi Python?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Dhi Python?

As many as you like. As long as a model supports skills, you can use Dhi Python with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Dhi Python AI skill free?

Yes. It is published on GitHub by justrach under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇