Skip to main content
The GenieX Python SDK follows the same design patterns as Hugging Face transformers — use AutoModel*.from_pretrained() to load a model, then call .generate() for inference.

AutoModelForCausalLM

Factory for loading causal language models — both text-only and multimodal. Returns a GenieXLLM for text-only models, or a GenieXVLM when a multimodal model is detected (e.g. phi4_multimodal, qwen3.5-vl, gemma4).

from_pretrained()

Returns: GenieXLLM or GenieXVLM (auto-detected based on the model)

AutoModelForVision2Seq

Factory for loading vision-language / multimodal models. Returns a GenieXVLM instance.

from_pretrained()

Accepts all the same parameters as AutoModelForCausalLM.from_pretrained() plus: Returns: GenieXVLM

GenieXLLM

Text-only language model instance returned by AutoModelForCausalLM.from_pretrained().

generate()

Run text generation from a formatted prompt string.
To apply a tool grammar produced by the chat template, request the metadata and pass it to generation:
Returns: GenerateOutput (or TextIteratorStreamer when stream=True)

reset()

Resets conversation state and clears the KV cache.

save_kv_cache(path) / load_kv_cache(path)

Save or load the key-value cache to/from a file path (str).

close()

Releases the model handle and frees resources. Also supports context-manager usage:

GenieXVLM

Vision-language model instance returned by AutoModelForVision2Seq.from_pretrained().

generate()

Same parameters as GenieXLLM.generate() plus:
Returns: GenerateOutput (or TextIteratorStreamer when stream=True)

reset() / close()

Same as GenieXLLM.

ModelTokenizer

Accessed via model.tokenizer. Provides a transformers-compatible chat template interface.

apply_chat_template()

Formats a list of chat messages using the model’s built-in chat template.
By default, returns a str — formatted prompt ready for model.generate(). With include_grammar=True, pass both values explicitly:

Output classes

ChatTemplateOutput

Returned by apply_chat_template(..., include_grammar=True). formatted_text contains the prompt, and chat_template_grammar is an owned ChatTemplateGrammar value that can be passed to generate().

ChatTemplateGrammar

Contains the grammar type, grammar text, lazy flag, generation prompt, trigger list, and preserved token IDs. It owns Python strings and tuples and remains valid after the template call returns.

GenerateOutput

Returned by model.generate().

ProfileData

TextIteratorStreamer

Returned by model.generate(..., stream=True). Yields decoded text chunks as they are generated.

Model manager

The same model manager the CLI uses is available programmatically via geniex.model_manager.

SDK functions