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 aGenieXLLM 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 aGenieXVLM instance.
from_pretrained()
Accepts all the same parameters as AutoModelForCausalLM.from_pretrained() plus:
Returns:
GenieXVLM
GenieXLLM
Text-only language model instance returned byAutoModelForCausalLM.from_pretrained().
generate()
Run text generation from a formatted prompt string.
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 byAutoModelForVision2Seq.from_pretrained().
generate()
Same parameters as GenieXLLM.generate() plus:
GenerateOutput (or TextIteratorStreamer when stream=True)
reset() / close()
Same as GenieXLLM.
ModelTokenizer
Accessed viamodel.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 byapply_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 bymodel.generate().
ProfileData
TextIteratorStreamer
Returned bymodel.generate(..., stream=True). Yields decoded text chunks as they are generated.
Model manager
The same model manager the CLI uses is available programmatically viageniex.model_manager.
SDK functions
Was this page helpful?