Use Example
LLM
Python
VLM
Python
LLM
Initialize LLM with model path
Python
API Use cases
Generate text from prompt
Python
Generate text by streaming
Python
Chat Template
Python
KV Cache
Python
Profiling Data
Python
VLM
Initialize VLM from model files
Python
API Use cases
Generate text from prompt
Python
Generate text by streaming
Python
Audio/Image Processing
Python
Profiling Data
Python
Embedder
Initialize
Python
Generate embeddings for input texts
Python
Similarity Analysis
Python
Reranker
Initialize
Python
Rerank documents against a query
Python
CV (Computer Vision)
OCR (Optical Character Recognition)
Python
ASR (Automatic Speech Recognition)
Initialize
Python
Transcribe audio file
Python
ASR Configuration Options
Python
Configuration
ModelConfig
Python
GenerationConfig
Python
EmbeddingConfig
Python
RerankConfig
Python
ASRConfig
Python
Plugin ID Options
Theplugin_id
parameter supports different backends:
cpu_gpu
: Default, supports both CPU and GPUmlx
: Apple Silicon optimized (for supported models)llama_cpp
: For GGUF format modelsonnx
: ONNX runtime backendnpu
: For NPU acceleration (Windows ARM64, Snapdragon X Elite)
Example Usage with Different Backends
Python
Example Scripts
The NexaAI SDK repository includes example scripts that demonstrate various use cases. These scripts are located in the/bindings/python/
directory and can be used as reference implementations:
llm.py
- LLM usage examples with command line interfacevlm.py
- VLM usage examples with multimodal supportembedder.py
- Text embedding generation examplesrerank.py
- Document reranking examplescv_ocr.py
- OCR (Optical Character Recognition) examplesasr.py
- Automatic Speech Recognition examples
Was this page helpful?