CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-groq

The official Python library for the groq API

Pending
Overview
Eval results
Files

models.mddocs/

Model Management

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.

Capabilities

List Models

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
    """

Retrieve Model

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
    """

Delete 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
    """

Async Model Operations

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: ...

Usage Examples

List Available Models

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}")

Get Model Information

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}")

Check Model Capabilities

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}")

Async Usage

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())

Delete Custom Model

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}")

Types

Model Information Types

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: bool

Common Model Identifiers

Popular models available through the Groq API:

Chat/Completion Models

  • llama3-8b-8192 - Llama 3 8B model with 8192 context length
  • llama3-70b-8192 - Llama 3 70B model with 8192 context length
  • mixtral-8x7b-32768 - Mixtral 8x7B model with 32768 context length
  • gemma-7b-it - Gemma 7B instruction-tuned model

Audio Models

  • whisper-large-v3 - Whisper large v3 for transcription and translation
  • tts-1 - Text-to-speech model
  • tts-1-hd - High-definition text-to-speech model

Embedding Models

  • nomic-embed-text-v1_5 - Nomic text embedding model v1.5

Install with Tessl CLI

npx tessl i tessl/pypi-groq

docs

audio.md

batches.md

chat-completions.md

embeddings.md

files.md

index.md

models.md

tile.json