0
# Models
1
2
List and manage available models including base models and fine-tuned models. The models API provides access to model metadata, capabilities, and management operations.
3
4
## Capabilities
5
6
### List Models
7
8
Retrieve information about all available models including base models and fine-tuned models.
9
10
```python { .api }
11
def list(**kwargs) -> ModelList:
12
"""
13
List all available models.
14
15
Returns:
16
ModelList containing model information and metadata
17
"""
18
```
19
20
### Retrieve Model
21
22
Get detailed information about a specific model including its capabilities and configuration.
23
24
```python { .api }
25
def retrieve(model_id: str, **kwargs) -> Union[BaseModelCard, FTModelCard]:
26
"""
27
Retrieve detailed information about a specific model.
28
29
Parameters:
30
- model_id: Unique identifier of the model
31
32
Returns:
33
Model card with detailed information (BaseModelCard for base models,
34
FTModelCard for fine-tuned models)
35
"""
36
```
37
38
### Delete Model
39
40
Delete a fine-tuned model that is no longer needed.
41
42
```python { .api }
43
def delete(model_id: str, **kwargs) -> DeleteModelOut:
44
"""
45
Delete a fine-tuned model.
46
47
Parameters:
48
- model_id: Unique identifier of the fine-tuned model to delete
49
50
Returns:
51
Deletion confirmation with model information
52
53
Note: Only fine-tuned models can be deleted, not base models
54
"""
55
```
56
57
## Usage Examples
58
59
### List Available Models
60
61
```python
62
from mistralai import Mistral
63
64
client = Mistral(api_key="your-api-key")
65
66
# Get all available models
67
models = client.models.list()
68
69
print(f"Total models: {len(models.data)}")
70
for model in models.data:
71
print(f"- {model.id}: {model.description or 'No description'}")
72
if hasattr(model, 'capabilities'):
73
print(f" Capabilities: {', '.join(model.capabilities)}")
74
print()
75
```
76
77
### Get Model Details
78
79
```python
80
# Get details for a specific model
81
model_id = "mistral-small-latest"
82
model_info = client.models.retrieve(model_id)
83
84
print(f"Model ID: {model_info.id}")
85
print(f"Type: {model_info.type}")
86
print(f"Created: {model_info.created}")
87
88
if hasattr(model_info, 'max_context_length'):
89
print(f"Max context length: {model_info.max_context_length}")
90
91
if hasattr(model_info, 'capabilities'):
92
print(f"Capabilities: {model_info.capabilities}")
93
94
if hasattr(model_info, 'description'):
95
print(f"Description: {model_info.description}")
96
```
97
98
### Model Filtering and Selection
99
100
```python
101
# Filter models by capabilities
102
models = client.models.list()
103
chat_models = []
104
embedding_models = []
105
106
for model in models.data:
107
if hasattr(model, 'capabilities'):
108
if 'completion' in model.capabilities or 'chat' in model.capabilities:
109
chat_models.append(model)
110
if 'embedding' in model.capabilities:
111
embedding_models.append(model)
112
113
print("Chat/Completion Models:")
114
for model in chat_models:
115
print(f" - {model.id}")
116
117
print("\nEmbedding Models:")
118
for model in embedding_models:
119
print(f" - {model.id}")
120
```
121
122
### Delete Fine-tuned Model
123
124
```python
125
# Delete a fine-tuned model (only works for custom fine-tuned models)
126
try:
127
result = client.models.delete("ft-model-id-example")
128
print(f"Deleted model: {result.id}")
129
print(f"Status: {result.deleted}")
130
except Exception as e:
131
print(f"Error deleting model: {e}")
132
```
133
134
## Types
135
136
### Model List Types
137
138
```python { .api }
139
class ModelList:
140
object: str
141
data: List[Union[BaseModelCard, FTModelCard]]
142
143
class BaseModelCard:
144
id: str
145
object: str
146
created: int
147
owned_by: str
148
type: str
149
description: Optional[str]
150
max_context_length: Optional[int]
151
aliases: Optional[List[str]]
152
capabilities: Optional[List[str]]
153
default_model_temperature: Optional[float]
154
max_temperature: Optional[float]
155
156
class FTModelCard:
157
id: str
158
object: str
159
created: int
160
owned_by: str
161
type: str
162
description: Optional[str]
163
capabilities: Optional[List[str]]
164
job: Optional[str]
165
archived: Optional[bool]
166
```
167
168
### Model Operations
169
170
```python { .api }
171
class DeleteModelOut:
172
id: str
173
object: str
174
deleted: bool
175
```
176
177
### Model Capabilities
178
179
```python { .api }
180
class ModelCapabilities:
181
completion: bool
182
chat: bool
183
embedding: bool
184
fine_tuning: bool
185
function_calling: bool
186
vision: bool
187
```
188
189
## Model Categories
190
191
### Base Models
192
193
**Chat/Completion Models:**
194
- `mistral-large-latest`: Most capable model for complex tasks
195
- `mistral-small-latest`: Efficient model for most tasks
196
- `mistral-medium-latest`: Balanced performance and capability
197
- `codestral-latest`: Specialized for code generation and completion
198
199
**Embedding Models:**
200
- `mistral-embed`: General-purpose text embedding model
201
202
### Fine-tuned Models
203
204
Fine-tuned models have custom identifiers and are created through the fine-tuning API. They inherit capabilities from their base models but are customized for specific use cases.
205
206
### Model Selection Guidelines
207
208
- **mistral-large-latest**: Complex reasoning, analysis, creative tasks
209
- **mistral-small-latest**: General conversations, simple tasks, cost-effective
210
- **codestral-latest**: Code generation, programming assistance, technical documentation
211
- **mistral-embed**: Semantic search, similarity comparison, text classification
212
213
### Model Properties
214
215
- **Context Length**: Maximum number of tokens the model can process in a single request
216
- **Temperature Range**: Supported temperature values for controlling randomness
217
- **Capabilities**: List of supported features (completion, chat, embedding, etc.)
218
- **Aliases**: Alternative names for the same model
219
- **Ownership**: Organization or entity that owns/created the model