0
# Model Management
1
2
Access model information, list available models, and manage model lifecycle operations. The models API provides comprehensive information about available models, their capabilities, and management functions.
3
4
## Capabilities
5
6
### List Models
7
8
Retrieve a list of all available models with their metadata and capabilities.
9
10
```python { .api }
11
def list(
12
extra_headers: Headers | None = None,
13
extra_query: Query | None = None,
14
extra_body: Body | None = None,
15
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN
16
) -> ModelListResponse:
17
"""
18
List all available models.
19
20
Returns:
21
ModelListResponse containing list of available models with metadata
22
"""
23
```
24
25
### Retrieve Model
26
27
Get detailed information about a specific model by its identifier.
28
29
```python { .api }
30
def retrieve(
31
model: str,
32
extra_headers: Headers | None = None,
33
extra_query: Query | None = None,
34
extra_body: Body | None = None,
35
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN
36
) -> Model:
37
"""
38
Retrieve information about a specific model.
39
40
Parameters:
41
- model: Model identifier to retrieve information for
42
43
Returns:
44
Model object with detailed information about the specified model
45
"""
46
```
47
48
### Delete Model
49
50
Remove a model from your account (for fine-tuned or custom models).
51
52
```python { .api }
53
def delete(
54
model: str,
55
extra_headers: Headers | None = None,
56
extra_query: Query | None = None,
57
extra_body: Body | None = None,
58
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN
59
) -> ModelDeleted:
60
"""
61
Delete a model.
62
63
Parameters:
64
- model: Model identifier to delete
65
66
Returns:
67
ModelDeleted confirmation object
68
"""
69
```
70
71
### Async Model Operations
72
73
All model operations have asynchronous counterparts with identical parameters.
74
75
```python { .api }
76
async def list(**kwargs) -> ModelListResponse: ...
77
async def retrieve(model: str, **kwargs) -> Model: ...
78
async def delete(model: str, **kwargs) -> ModelDeleted: ...
79
```
80
81
## Usage Examples
82
83
### List Available Models
84
85
```python
86
from groq import Groq
87
88
client = Groq()
89
90
# Get all available models
91
models = client.models.list()
92
93
print(f"Available models: {len(models.data)}")
94
for model in models.data:
95
print(f"- {model.id}: {model.object}")
96
if hasattr(model, 'owned_by'):
97
print(f" Owned by: {model.owned_by}")
98
if hasattr(model, 'created'):
99
print(f" Created: {model.created}")
100
```
101
102
### Get Model Information
103
104
```python
105
from groq import Groq
106
107
client = Groq()
108
109
# Get information about a specific model
110
model = client.models.retrieve("llama3-8b-8192")
111
112
print(f"Model ID: {model.id}")
113
print(f"Object type: {model.object}")
114
print(f"Created: {model.created}")
115
print(f"Owned by: {model.owned_by}")
116
```
117
118
### Check Model Capabilities
119
120
```python
121
from groq import Groq
122
123
client = Groq()
124
125
# List models and check their capabilities
126
models = client.models.list()
127
128
chat_models = []
129
embedding_models = []
130
131
for model in models.data:
132
model_info = client.models.retrieve(model.id)
133
134
# Categorize models based on their ID patterns
135
if "embed" in model.id.lower():
136
embedding_models.append(model.id)
137
else:
138
chat_models.append(model.id)
139
140
print("Chat/Completion Models:")
141
for model_id in chat_models:
142
print(f" - {model_id}")
143
144
print("\nEmbedding Models:")
145
for model_id in embedding_models:
146
print(f" - {model_id}")
147
```
148
149
### Async Usage
150
151
```python
152
import asyncio
153
from groq import AsyncGroq
154
155
async def main():
156
client = AsyncGroq()
157
158
# Async model listing
159
models = await client.models.list()
160
print(f"Found {len(models.data)} models")
161
162
# Async model retrieval
163
if models.data:
164
first_model = await client.models.retrieve(models.data[0].id)
165
print(f"First model: {first_model.id}")
166
167
asyncio.run(main())
168
```
169
170
### Delete Custom Model
171
172
```python
173
from groq import Groq
174
175
client = Groq()
176
177
# Delete a custom or fine-tuned model
178
try:
179
result = client.models.delete("ft:llama3-8b-8192:my-org:custom-model:abc123")
180
print(f"Model deleted: {result.deleted}")
181
print(f"Model ID: {result.id}")
182
except Exception as e:
183
print(f"Failed to delete model: {e}")
184
```
185
186
## Types
187
188
### Model Information Types
189
190
```python { .api }
191
class Model:
192
id: str
193
object: Literal["model"]
194
created: int
195
owned_by: str
196
197
class ModelListResponse:
198
object: Literal["list"]
199
data: List[Model]
200
201
class ModelDeleted:
202
id: str
203
object: Literal["model"]
204
deleted: bool
205
```
206
207
### Common Model Identifiers
208
209
Popular models available through the Groq API:
210
211
#### Chat/Completion Models
212
- `llama3-8b-8192` - Llama 3 8B model with 8192 context length
213
- `llama3-70b-8192` - Llama 3 70B model with 8192 context length
214
- `mixtral-8x7b-32768` - Mixtral 8x7B model with 32768 context length
215
- `gemma-7b-it` - Gemma 7B instruction-tuned model
216
217
#### Audio Models
218
- `whisper-large-v3` - Whisper large v3 for transcription and translation
219
- `tts-1` - Text-to-speech model
220
- `tts-1-hd` - High-definition text-to-speech model
221
222
#### Embedding Models
223
- `nomic-embed-text-v1_5` - Nomic text embedding model v1.5