datamodel-codegen. These models provide full type safety when working with the platform API.
How They’re Generated
The models inkodexa_document.model._generated are produced by running datamodel-codegen against the api-docs.yaml OpenAPI specification from kodexa-api. This happens as part of the CI pipeline and ensures the Python models always match the API.
Importing Models
Key Model Categories
Organizations & Projects
| Model | Description |
|---|---|
Organization | Organization with members, subscriptions, and settings |
Project | Project containing assistants, stores, and taxonomies |
Membership | User membership in an organization |
Assistants & Execution
| Model | Description |
|---|---|
Assistant | Assistant configuration within a project |
AssistantDefinition | Deployable assistant definition (module-level) |
Execution | An execution of an assistant pipeline |
ExecutionEvent | Events emitted during execution |
Documents & Storage
| Model | Description |
|---|---|
DocumentFamily | A document family in a store |
Store | Document or data store |
ContentObject | A content object (KDDB, native file, etc.) |
Knowledge System
| Model | Description |
|---|---|
KnowledgeSet | A set of knowledge items |
KnowledgeItem | An individual knowledge item |
KnowledgeFeature | A feature attached to knowledge items or document families |
KnowledgeItemType | Type definition for knowledge items |
KnowledgeFeatureType | Type definition for knowledge features |
Tasks & Workflow
| Model | Description |
|---|---|
Task | A workflow task |
TaskTemplate | Template for creating tasks |
TaskActivity | Activity log entry for a task |
TaskDocumentFamily | Association between a task and a document family |
Users & Access
| Model | Description |
|---|---|
User | Platform user |
PlatformOverview | Platform configuration and version info |
KodexaBaseModel
All generated models inherit fromKodexaBaseModel, which extends Pydantic’s BaseModel with:
camelCase / snake_case Support
Models accept both camelCase (matching the JSON API) and snake_case (Pythonic) field names:Dict-like Access
Models support dict-style bracket access andget():
Extra Fields
Theextra='allow' configuration means models accept fields not in the schema without raising errors. This handles forward-compatibility when the API adds new fields.
Taxonomy and Taxon Extensions
The SDK extends the generatedTaxonomyBase and TaxonBase models with navigation methods. These are imported from the top-level package, not from _generated:
Taxon Methods
| Method | Description |
|---|---|
update_path(parent_path) | Recursively sets path on this taxon and its children |
find_taxon(*path_parts) | Search children by name at each level |
get_taxon_by_path(path) | Find a taxon matching the exact path string |
groups() | Return all group-type taxons at this level and below |
get_simplified_structure() | Return a minimal dict representation |
Taxonomy Methods
| Method | Description |
|---|---|
get_taxon_by_path(path) | Search all root taxons and children by path |
update_paths() | Call update_path() on every root taxon |
build_guidance_tags() | Build {path: [examples]} dict for guidance |
Deserializing API Responses
The models integrate naturally with API response data:DateTime Handling
KodexaBaseModel uses a custom StandardDateTime type that serializes datetimes to millisecond-precision ISO 8601 strings with Z suffix (e.g., 2026-01-15T10:30:000.000Z). This matches the Java/Go API format.