The official Python library for the groq API
—
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.
Retrieve a list of all available models with their metadata and capabilities.
def list(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN
) -> ModelListResponse:
"""
List all available models.
Returns:
ModelListResponse containing list of available models with metadata
"""Get detailed information about a specific model by its identifier.
def retrieve(
model: str,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN
) -> Model:
"""
Retrieve information about a specific model.
Parameters:
- model: Model identifier to retrieve information for
Returns:
Model object with detailed information about the specified model
"""Remove a model from your account (for fine-tuned or custom models).
def delete(
model: str,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN
) -> ModelDeleted:
"""
Delete a model.
Parameters:
- model: Model identifier to delete
Returns:
ModelDeleted confirmation object
"""All model operations have asynchronous counterparts with identical parameters.
async def list(**kwargs) -> ModelListResponse: ...
async def retrieve(model: str, **kwargs) -> Model: ...
async def delete(model: str, **kwargs) -> ModelDeleted: ...from groq import Groq
client = Groq()
# Get all available models
models = client.models.list()
print(f"Available models: {len(models.data)}")
for model in models.data:
print(f"- {model.id}: {model.object}")
if hasattr(model, 'owned_by'):
print(f" Owned by: {model.owned_by}")
if hasattr(model, 'created'):
print(f" Created: {model.created}")from groq import Groq
client = Groq()
# Get information about a specific model
model = client.models.retrieve("llama3-8b-8192")
print(f"Model ID: {model.id}")
print(f"Object type: {model.object}")
print(f"Created: {model.created}")
print(f"Owned by: {model.owned_by}")from groq import Groq
client = Groq()
# List models and check their capabilities
models = client.models.list()
chat_models = []
embedding_models = []
for model in models.data:
model_info = client.models.retrieve(model.id)
# Categorize models based on their ID patterns
if "embed" in model.id.lower():
embedding_models.append(model.id)
else:
chat_models.append(model.id)
print("Chat/Completion Models:")
for model_id in chat_models:
print(f" - {model_id}")
print("\nEmbedding Models:")
for model_id in embedding_models:
print(f" - {model_id}")import asyncio
from groq import AsyncGroq
async def main():
client = AsyncGroq()
# Async model listing
models = await client.models.list()
print(f"Found {len(models.data)} models")
# Async model retrieval
if models.data:
first_model = await client.models.retrieve(models.data[0].id)
print(f"First model: {first_model.id}")
asyncio.run(main())from groq import Groq
client = Groq()
# Delete a custom or fine-tuned model
try:
result = client.models.delete("ft:llama3-8b-8192:my-org:custom-model:abc123")
print(f"Model deleted: {result.deleted}")
print(f"Model ID: {result.id}")
except Exception as e:
print(f"Failed to delete model: {e}")class Model:
id: str
object: Literal["model"]
created: int
owned_by: str
class ModelListResponse:
object: Literal["list"]
data: List[Model]
class ModelDeleted:
id: str
object: Literal["model"]
deleted: boolPopular models available through the Groq API:
llama3-8b-8192 - Llama 3 8B model with 8192 context lengthllama3-70b-8192 - Llama 3 70B model with 8192 context lengthmixtral-8x7b-32768 - Mixtral 8x7B model with 32768 context lengthgemma-7b-it - Gemma 7B instruction-tuned modelwhisper-large-v3 - Whisper large v3 for transcription and translationtts-1 - Text-to-speech modeltts-1-hd - High-definition text-to-speech modelnomic-embed-text-v1_5 - Nomic text embedding model v1.5Install with Tessl CLI
npx tessl i tessl/pypi-groq