Python API Reference¶
This section documents the Python API for vector-inference.
Client Interface¶
vec_inf.client.api.VecInfClient
¶
Client for interacting with Vector Inference programmatically.
This class provides methods for launching models, checking their status, retrieving metrics, and shutting down models using the Vector Inference infrastructure.
Examples:
>>> from vec_inf.api import VecInfClient
>>> client = VecInfClient()
>>> response = client.launch_model("Meta-Llama-3.1-8B-Instruct")
>>> job_id = response.slurm_job_id
>>> status = client.get_status(job_id)
>>> if status.status == ModelStatus.READY:
... print(f"Model is ready at {status.base_url}")
>>> client.shutdown_model(job_id)
Source code in vec_inf/client/api.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
|
__init__
¶
list_models
¶
List all available models.
Returns:
Type | Description |
---|---|
list[ModelInfo]
|
ModelInfo objects containing information about available models. |
Source code in vec_inf/client/api.py
get_model_config
¶
Get the configuration for a specific model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name
|
str
|
Name of the model to get configuration for. |
required |
Returns:
Type | Description |
---|---|
ModelConfig
|
Model configuration. |
Source code in vec_inf/client/api.py
launch_model
¶
Launch a model on the cluster.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name
|
str
|
Name of the model to launch. |
required |
options
|
Optional[LaunchOptions]
|
Optional launch options to override default configuration. |
None
|
Returns:
Type | Description |
---|---|
LaunchResponse
|
Information about the launched model. |
Source code in vec_inf/client/api.py
get_status
¶
Get the status of a running model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
slurm_job_id
|
int
|
The Slurm job ID to check. |
required |
log_dir
|
Optional[str]
|
Optional path to the Slurm log directory. |
None
|
Returns:
Type | Description |
---|---|
StatusResponse
|
Model status information. |
Source code in vec_inf/client/api.py
get_metrics
¶
Get the performance metrics of a running model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
slurm_job_id
|
str
|
The Slurm job ID to get metrics for. |
required |
log_dir
|
str
|
Optional path to the Slurm log directory. |
None
|
Returns:
Type | Description |
---|---|
MetricsResponse
|
Object containing the model's performance metrics. |
Source code in vec_inf/client/api.py
shutdown_model
¶
Shutdown a running model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
slurm_job_id
|
int
|
The Slurm job ID to shut down. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the model was successfully shutdown, False otherwise. |
Raises:
Type | Description |
---|---|
SlurmJobError
|
If there was an error shutting down the model. |
Source code in vec_inf/client/api.py
wait_until_ready
¶
Wait until a model is ready or fails.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
slurm_job_id
|
int
|
The Slurm job ID to wait for. |
required |
timeout_seconds
|
int
|
Maximum time to wait in seconds (default: 30 mins). |
1800
|
poll_interval_seconds
|
int
|
How often to check status in seconds (default: 10s). |
10
|
log_dir
|
Optional[str]
|
Optional path to the Slurm log directory. |
None
|
Returns:
Type | Description |
---|---|
StatusResponse
|
Status, if the model is ready or failed. |
Raises:
Type | Description |
---|---|
SlurmJobError
|
If the specified job is not found or there's an error with the job. |
ServerError
|
If the server fails to start within the timeout period. |
APIError
|
If there was an error checking the status. |
Source code in vec_inf/client/api.py
Data Models¶
vec_inf.client._models
¶
Data models for Vector Inference API.
This module contains the data model classes used by the Vector Inference API for both request parameters and response objects.
ModelStatus
¶
Bases: str
, Enum
Enum representing the possible status states of a model.
Source code in vec_inf/client/_models.py
ModelType
¶
LaunchResponse
dataclass
¶
StatusResponse
dataclass
¶
Response from checking a model's status.
Source code in vec_inf/client/_models.py
MetricsResponse
dataclass
¶
LaunchOptions
dataclass
¶
Options for launching a model.
Source code in vec_inf/client/_models.py
LaunchOptionsDict
¶
Bases: TypedDict
TypedDict for LaunchOptions.