docs
Type Support
The SDK converts Python type annotations to JSON Schema automatically. Parameters without a default value are marked as required; those with defaults are optional.
Supported types
| Python annotation | JSON Schema |
|---|---|
str | {"type": "string"} |
int | {"type": "integer"} |
float | {"type": "number"} |
bool | {"type": "boolean"} |
bytes | {"type": "string", "contentEncoding": "base64"} |
list / list[X] | {"type": "array", "items": {...}} |
dict / dict[K, V] | {"type": "object"} |
Optional[X] / X | None | Schema of X, not required |
Literal["a", "b"] | {"type": "string", "enum": ["a", "b"]} |
Tuple, Set, Frozenset | {"type": "array", "items": {...}} |
Any | {} (no type constraint) |
Example
Python
from typing import Literal
from ninetrix import Tool
@Tool
def search_products(
query: str,
category: str | None = None,
sort: Literal["price_asc", "price_desc", "relevance"] = "relevance",
limit: int = 20,
) -> list[dict]:
"""Search the product catalog.
Args:
query: Full-text search query.
category: Optional category filter (e.g. "electronics").
sort: Sort order for results.
limit: Maximum products to return.
"""
...
The generated schema marks only query as required — all others have defaults so they are optional. The sort field gets an enum with the three allowed values.