omnichar-sdk reads .char files from Python. It opens a character and returns its parts. It can also build a new .char. The source is in the ComfyUI-Omnichar repository.
Install
Open a character
get_ref_archs() and get_lora_archs() tell you which models the file carries a reference set or an adapter for. The reference sets currently compiled are flux2-klein, minimax-h3 and fal-ref.
References
get_references() returns references in the order a prompt addresses them. Each one has a role (face, body or cloth), its width and height, and:
bytes()for the raw imageopen()for a Pillow RGB image (needs theimagesextra)fit(size, mode="pad")to resize onto a fixed size:padletterboxes,covercrops,stretchdistorts
role or limit. limit divides the slots between face, body and outfit instead of cutting the end of the list, so a character keeps its wardrobe when a model takes fewer references than the character has. Pass arch for a model’s compiled set, or leave it out (optionally with origin) to read the original references. You can’t pass both.
Prompt text
get_prompt() writes text that names the positions the references will occupy. The style picks the addressing a model was trained on:
first_position sets the number the first reference gets. Use the same value for the prompt and the reference sheet so they agree on which image is image 1.
LoRA
get_lora(arch) returns the adapter trained for that model, or None. With several adapters and no arch, it raises instead of guessing.
strength, not 1.0. An overfitted adapter only works turned down. portability says whether the adapter’s keys match what tools outside Omnichar Studio expect.
Reference sheets
A reference sheet lays the references out in a numbered grid. The numbers are what a prompt refers to, so the sheet can be checked against the prompt it belongs to. Needs theimages extra.
arch, role, limit and origin filters as get_references, plus columns, cell, fit, labels and background.
Voice
get_voice() returns None, or a voice with seconds, sample_rate, read_wav() (the mono clip a model is given) and read_sample() (the clip as recorded).
wanted() applies Omnichar’s rule for when to send the voice: only when the prompt has dialogue.
auto, always and never.
Build a character
encode_character writes a new .char from (image, role) pairs and compiles a reference set for each model, so the result works without a rebuild.
The SDK doesn’t compute identity vectors, because those need face encoders it doesn’t ship. Rendering is unaffected, but Omnichar Studio’s continuity score and verify features stay off for that character until Studio re-encodes the file.