### Add and Run a Python Example Source: https://github.com/groq/groq-python/blob/main/CONTRIBUTING.md Create new example files in the 'examples/' directory. Make them executable and run them against your API. ```py # add an example to examples/.py #!/usr/bin/env -S rye run python … ``` ```sh $ chmod +x examples/.py # run the example against your api $ ./examples/.py ``` -------------------------------- ### Install Dependencies with Rye Source: https://github.com/groq/groq-python/blob/main/CONTRIBUTING.md Use Rye to automatically provision a Python environment and install dependencies. Ensure you have Rye installed or follow the manual installation guide. ```sh $ ./scripts/bootstrap ``` ```sh $ rye sync --all-features ``` -------------------------------- ### Install Groq Python SDK from Git Source: https://github.com/groq/groq-python/blob/main/CONTRIBUTING.md Install the SDK directly from its Git repository using pip. This is useful for using the latest development version. ```sh $ pip install git+ssh://git@github.com/groq/groq-python.git ``` -------------------------------- ### Build and Install Groq Python SDK from Source Source: https://github.com/groq/groq-python/blob/main/CONTRIBUTING.md Build a distributable version of the library from source using Rye or Python's build module. Then, install the generated wheel file. ```sh $ rye build # or $ python -m build ``` ```sh $ pip install ./path-to-wheel-file.whl ``` -------------------------------- ### Install Groq Python Library Source: https://github.com/groq/groq-python/blob/main/README.md Installs the Groq Python API library from PyPI. This is the first step to using the library in your Python application. ```shell pip install groq ``` -------------------------------- ### Install Dependencies with Pip Source: https://github.com/groq/groq-python/blob/main/CONTRIBUTING.md If not using Rye, install development dependencies using pip by referencing the requirements-dev.lock file. Ensure your Python version matches the one specified in .python-version. ```sh $ pip install -r requirements-dev.lock ``` -------------------------------- ### Install Groq Python Library with aiohttp support Source: https://github.com/groq/groq-python/blob/main/README.md Installs the Groq Python API library with optional aiohttp support for enhanced asynchronous concurrency. This is required for using `DefaultAioHttpClient`. ```shell pip install groq[aiohttp] ``` -------------------------------- ### Groq File Upload Example (Python) Source: https://github.com/groq/groq-python/blob/main/README.md Shows how to upload files to the Groq API, for example, for audio transcriptions. Files can be provided as bytes, a `PathLike` object, or a tuple containing filename, contents, and media type. ```python from pathlib import Path from groq import Groq client = Groq() client.audio.transcriptions.create( model="whisper-large-v3-turbo", file=Path("/path/to/file"), ) ``` -------------------------------- ### GET /openai/v1/files Source: https://github.com/groq/groq-python/blob/main/api.md Retrieves a list of all files associated with the account. ```APIDOC ## GET /openai/v1/files ### Description Returns a list of files that have been uploaded to the account. ### Method GET ### Endpoint /openai/v1/files ### Response #### Success Response (200) - **data** (array) - A list of file objects. ### Response Example { "data": [{"id": "file_1", "filename": "test.json"}] } ``` -------------------------------- ### Get Groq Python Package Version Source: https://github.com/groq/groq-python/blob/main/README.md This snippet demonstrates how to import the groq library and print its installed version. It's useful for debugging or verifying that the correct version is active in your Python environment. ```python import groq print(groq.__version__) ``` -------------------------------- ### GET /openai/v1/files/{file_id} Source: https://github.com/groq/groq-python/blob/main/api.md Retrieves metadata information for a specific file. ```APIDOC ## GET /openai/v1/files/{file_id} ### Description Returns metadata and status information for a specific file. ### Method GET ### Endpoint /openai/v1/files/{file_id} ### Parameters #### Path Parameters - **file_id** (string) - Required - The unique identifier of the file. ### Response #### Success Response (200) - **id** (string) - The file ID. - **filename** (string) - The file name. - **created_at** (integer) - Timestamp of creation. ``` -------------------------------- ### GET /openai/v1/models Source: https://github.com/groq/groq-python/blob/main/api.md Retrieves a list of available models or details for a specific model. ```APIDOC ## GET /openai/v1/models ### Description Lists all models available for use or retrieves details for a specific model ID. ### Method GET ### Endpoint /openai/v1/models/{model} ### Parameters #### Path Parameters - **model** (string) - Optional - The ID of the model to retrieve. ### Response #### Success Response (200) - **ModelListResponse** (object) - A list of available models. ``` -------------------------------- ### GET /openai/v1/files/{file_id}/content Source: https://github.com/groq/groq-python/blob/main/api.md Retrieves the raw content of a specific file. ```APIDOC ## GET /openai/v1/files/{file_id}/content ### Description Downloads the binary content of the specified file. ### Method GET ### Endpoint /openai/v1/files/{file_id}/content ### Parameters #### Path Parameters - **file_id** (string) - Required - The unique identifier of the file. ``` -------------------------------- ### Get File Info using Groq Python SDK Source: https://github.com/groq/groq-python/blob/main/api.md Retrieves metadata and information about a specific file using its file_id with the Groq Python SDK. It returns a FileInfoResponse object containing details about the file. ```python from groq import Groq client = Groq( api_key=os.environ.get("GROQ_API_KEY"), ) file_info = client.files.info("file-id-to-get-info") print(file_info) ``` -------------------------------- ### List Models (Python) Source: https://github.com/groq/groq-python/blob/main/api.md Defines the method for listing all available models using the Groq client. This method returns a ModelListResponse object and corresponds to the GET /openai/v1/models API endpoint. ```python # client.models.list() -> ModelListResponse ``` -------------------------------- ### Get File Content using Groq Python SDK Source: https://github.com/groq/groq-python/blob/main/api.md Retrieves the content of a specific file using its file_id with the Groq Python SDK. The content is returned as a BinaryAPIResponse, which can be processed as binary data. ```python from groq import Groq client = Groq( api_key=os.environ.get("GROQ_API_KEY"), ) file_content = client.files.content("file-id-to-retrieve") # Process file_content as binary data, e.g., save to a file with open("downloaded_file.txt", "wb") as f: f.write(file_content.content) print("File content downloaded.") ``` -------------------------------- ### List Batches (Python) Source: https://github.com/groq/groq-python/blob/main/api.md Defines the method for listing all batch jobs using the Groq client. This method returns a BatchListResponse object and corresponds to the GET /openai/v1/batches API endpoint. ```python # client.batches.list() -> BatchListResponse ``` -------------------------------- ### Retrieve Model (Python) Source: https://github.com/groq/groq-python/blob/main/api.md Defines the method for retrieving a specific model by its ID using the Groq client. This method returns a Model object and corresponds to the GET /openai/v1/models/{model} API endpoint. ```python # client.models.retrieve(model) -> Model ``` -------------------------------- ### Retrieve Batch (Python) Source: https://github.com/groq/groq-python/blob/main/api.md Defines the method for retrieving a specific batch job by its ID using the Groq client. This method returns a BatchRetrieveResponse object and corresponds to the GET /openai/v1/batches/{batch_id} API endpoint. ```python # client.batches.retrieve(batch_id) -> BatchRetrieveResponse ``` -------------------------------- ### Set up Mock Server for Tests Source: https://github.com/groq/groq-python/blob/main/CONTRIBUTING.md Before running tests, set up a mock server against the OpenAPI spec. This is typically done using the provided script. ```sh $ ./scripts/mock ``` -------------------------------- ### Run Tests Source: https://github.com/groq/groq-python/blob/main/CONTRIBUTING.md Execute the test suite for the Groq Python SDK. Ensure the mock server is running if required by the tests. ```sh $ ./scripts/test ``` -------------------------------- ### Enable Logging for Groq SDK Source: https://github.com/groq/groq-python/blob/main/README.md Demonstrates how to enable debug or info level logging using environment variables. ```shell $ export GROQ_LOG=info ``` -------------------------------- ### Configuring Groq Python HTTP Client with httpx Source: https://github.com/groq/groq-python/blob/main/README.md Demonstrates how to configure the underlying httpx client for the Groq Python SDK. This includes setting a custom base URL, configuring proxies, custom transports, and other advanced httpx client options. It also shows how to apply these configurations per-request using `with_options()`. ```python import httpx from groq import Groq, DefaultHttpxClient client = Groq( # Or use the `GROQ_BASE_URL` env var base_url="http://my.test.server.example.com:8083", http_client=DefaultHttpxClient( proxy="http://my.test.proxy.example.com", transport=httpx.HTTPTransport(local_address="0.0.0.0"), ), ) client.with_options(http_client=DefaultHttpxClient(...)) ``` -------------------------------- ### POST /openai/v1/files Source: https://github.com/groq/groq-python/blob/main/api.md Uploads a file to the Groq platform. ```APIDOC ## POST /openai/v1/files ### Description Uploads a new file to the Groq platform for use with other APIs. ### Method POST ### Endpoint /openai/v1/files ### Request Body - **file** (binary) - Required - The file object to be uploaded. - **purpose** (string) - Required - The intended purpose of the uploaded file. ### Response #### Success Response (200) - **id** (string) - The unique identifier for the file. - **filename** (string) - The name of the file. ### Response Example { "id": "file_abc123", "filename": "data.json" } ``` -------------------------------- ### Async Groq API Usage with aiohttp (Python) Source: https://github.com/groq/groq-python/blob/main/README.md Demonstrates using the asynchronous Groq client with `aiohttp` as the HTTP backend for improved performance. It requires instantiating the client with `http_client=DefaultAioHttpClient()` and managing the client within an async context manager. ```python import os import asyncio from groq import DefaultAioHttpClient from groq import AsyncGroq async def main() -> None: async with AsyncGroq( api_key=os.environ.get("GROQ_API_KEY"), # This is the default and can be omitted http_client=DefaultAioHttpClient(), ) as client: chat_completion = await client.chat.completions.create( messages=[ { "role": "user", "content": "Explain the importance of low latency LLMs", } ], model="openai/gpt-oss-20b", ) print(chat_completion.id) asyncio.run(main()) ``` -------------------------------- ### POST /openai/v1/audio/transcriptions Source: https://github.com/groq/groq-python/blob/main/api.md Transcribes audio files into text. ```APIDOC ## POST /openai/v1/audio/transcriptions ### Description Transcribes audio from a file into text format. ### Method POST ### Endpoint /openai/v1/audio/transcriptions ### Request Body - **file** (file) - Required - The audio file object. - **model** (string) - Required - The model to use for transcription. ### Response #### Success Response (200) - **Transcription** (object) - The transcribed text and metadata. ``` -------------------------------- ### Activate Virtual Environment with Rye Source: https://github.com/groq/groq-python/blob/main/CONTRIBUTING.md After syncing dependencies with Rye, activate the virtual environment to run Python scripts without the 'rye run' prefix. ```sh # Activate the virtual environment - https://docs.python.org/3/library/venv.html#how-venvs-work $ source .venv/bin/activate # now you can omit the `rye run` prefix $ python script.py ``` -------------------------------- ### Create File using Groq Python SDK Source: https://github.com/groq/groq-python/blob/main/api.md Creates a new file using the Groq Python SDK. This method requires file content and optionally a purpose. It returns a FileCreateResponse object upon successful creation. ```python from groq import Groq client = Groq( api_key=os.environ.get("GROQ_API_KEY"), ) file = client.files.create( file=open("my_file.txt", "rb"), purpose="fine-tune", ) print(file) ``` -------------------------------- ### List Files using Groq Python SDK Source: https://github.com/groq/groq-python/blob/main/api.md Retrieves a list of all files associated with the account using the Groq Python SDK. It returns a FileListResponse object containing file information. ```python from groq import Groq client = Groq( api_key=os.environ.get("GROQ_API_KEY"), ) files = client.files.list() print(files) ``` -------------------------------- ### Synchronous Groq API Usage (Python) Source: https://github.com/groq/groq-python/blob/main/README.md Demonstrates how to use the synchronous Groq client to create a chat completion. It requires an API key, preferably set as an environment variable, and specifies the messages and the model to use. ```python import os from groq import Groq client = Groq( api_key=os.environ.get("GROQ_API_KEY"), # This is the default and can be omitted ) chat_completion = client.chat.completions.create( messages=[ { "role": "user", "content": "Explain the importance of low latency LLMs", } ], model="openai/gpt-oss-20b", ) print(chat_completion.choices[0].message.content) ``` -------------------------------- ### Publish PyPI Package Manually Source: https://github.com/groq/groq-python/blob/main/CONTRIBUTING.md Manually publish a new release to PyPI by setting the PYPI_TOKEN environment variable and running the publish script. ```sh PYPI_TOKEN=your_pypi_token bin/publish-pypi ``` -------------------------------- ### POST /openai/v1/chat/completions Source: https://github.com/groq/groq-python/blob/main/api.md Creates a chat completion response using the specified model and messages. ```APIDOC ## POST /openai/v1/chat/completions ### Description Generates a chat completion response based on the provided conversation history and parameters. ### Method POST ### Endpoint /openai/v1/chat/completions ### Request Body - **messages** (array) - Required - A list of messages comprising the conversation. - **model** (string) - Required - The ID of the model to use. ### Response #### Success Response (200) - **ChatCompletion** (object) - The generated chat completion object. ### Response Example { "id": "chatcmpl-123", "object": "chat.completion", "choices": [] } ``` -------------------------------- ### Create Speech (Python) Source: https://github.com/groq/groq-python/blob/main/api.md Defines the method for creating speech audio from text using the Groq client. This method takes speech creation parameters and returns a BinaryAPIResponse. It maps to the POST /openai/v1/audio/speech API endpoint. ```python # client.audio.speech.create(**params) -> BinaryAPIResponse ``` -------------------------------- ### Managing HTTP Resources with Groq Python Client Context Manager Source: https://github.com/groq/groq-python/blob/main/README.md Explains how to manage HTTP resources for the Groq Python client, ensuring connections are properly closed. It shows using the client as a context manager (`with Groq() as client:`), which automatically closes the client and its underlying HTTP connections upon exiting the block. ```python from groq import Groq with Groq() as client: # make requests here ... ``` -------------------------------- ### Create Batch (Python) Source: https://github.com/groq/groq-python/blob/main/api.md Defines the method for creating a batch job using the Groq client. This method accepts batch creation parameters and returns a BatchCreateResponse object, corresponding to the POST /openai/v1/batches API endpoint. ```python # client.batches.create(**params) -> BatchCreateResponse ``` -------------------------------- ### Asynchronous Groq API Usage (Python) Source: https://github.com/groq/groq-python/blob/main/README.md Shows how to use the asynchronous Groq client for non-blocking API calls. It requires importing `AsyncGroq` and using `await` for API operations, typically within an `asyncio` event loop. ```python import os import asyncio from groq import AsyncGroq client = AsyncGroq( api_key=os.environ.get("GROQ_API_KEY"), # This is the default and can be omitted ) async def main() -> None: chat_completion = await client.chat.completions.create( messages=[ { "role": "user", "content": "Explain the importance of low latency LLMs", } ], model="openai/gpt-oss-20b", ) print(chat_completion.choices[0].message.content) asyncio.run(main()) ``` -------------------------------- ### Handle API Errors in Groq Python SDK Source: https://github.com/groq/groq-python/blob/main/README.md Demonstrates how to catch and handle specific API exceptions such as connection errors, rate limits, and general status errors when making requests. ```python import groq from groq import Groq client = Groq() try: client.chat.completions.create( messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Explain the importance of low latency LLMs"}, ], model="openai/gpt-oss-20b", ) except groq.APIConnectionError as e: print("The server could not be reached") print(e.__cause__) except groq.RateLimitError as e: print("A 429 status code was received; we should back off a bit.") except groq.APIStatusError as e: print("Another non-200-range status code was received") print(e.status_code) print(e.response) ``` -------------------------------- ### Create Chat Completion (Python) Source: https://github.com/groq/groq-python/blob/main/api.md Defines the method for creating chat completions using the Groq client. This method takes parameters and returns a ChatCompletion object. It corresponds to the POST /openai/v1/chat/completions API endpoint. ```python # client.chat.completions.create(**params) -> ChatCompletion ``` -------------------------------- ### Create Transcription (Python) Source: https://github.com/groq/groq-python/blob/main/api.md Defines the method for creating audio transcriptions using the Groq client. This method accepts transcription parameters and returns a Transcription object, corresponding to the POST /openai/v1/audio/transcriptions API endpoint. ```python # client.audio.transcriptions.create(**params) -> Transcription ``` -------------------------------- ### Create Translation (Python) Source: https://github.com/groq/groq-python/blob/main/api.md Defines the method for creating audio translations using the Groq client. This method takes translation parameters and returns a Translation object, corresponding to the POST /openai/v1/audio/translations API endpoint. ```python # client.audio.translations.create(**params) -> Translation ``` -------------------------------- ### Lint and Format Code Source: https://github.com/groq/groq-python/blob/main/CONTRIBUTING.md Maintain code quality using Ruff for linting and Black for formatting. Run the provided scripts to check and automatically fix issues. ```sh $ ./scripts/lint ``` ```sh $ ./scripts/format ``` -------------------------------- ### Making Undocumented Requests with Groq Python SDK Source: https://github.com/groq/groq-python/blob/main/README.md Illustrates how to make requests to undocumented endpoints or with custom parameters using the Groq Python SDK. It shows using `client.post` for custom endpoints and accessing undocumented response properties via `response.unknown_prop` or `response.model_extra`. ```python import httpx response = client.post( "/foo", cast_to=httpx.Response, body={"my_param": True}, ) print(response.headers.get("x-foo")) ``` -------------------------------- ### Import Chat Completion Types (Python) Source: https://github.com/groq/groq-python/blob/main/api.md Imports a comprehensive set of types related to chat completions from the groq.types.chat module. These include various message formats, role definitions, and response structures. ```python from groq.types.chat import ( ChatCompletion, ChatCompletionAssistantMessageParam, ChatCompletionChunk, ChatCompletionContentPart, ChatCompletionContentPartImage, ChatCompletionContentPartText, ChatCompletionFunctionCallOption, ChatCompletionFunctionMessageParam, ChatCompletionMessage, ChatCompletionMessageParam, ChatCompletionMessageToolCall, ChatCompletionNamedToolChoice, ChatCompletionRole, ChatCompletionSystemMessageParam, ChatCompletionTokenLogprob, ChatCompletionTool, ChatCompletionToolChoiceOption, ChatCompletionToolMessageParam, ChatCompletionUserMessageParam, ) ``` -------------------------------- ### Configure Retry Logic for Groq Requests Source: https://github.com/groq/groq-python/blob/main/README.md Shows how to adjust the maximum number of retries for failed requests, either globally during client initialization or on a per-request basis. ```python from groq import Groq # Configure the default for all requests: client = Groq(max_retries=0) # Or, configure per-request: client.with_options(max_retries=5).chat.completions.create( messages=[{"role": "system", "content": "You are a helpful assistant."}], model="openai/gpt-oss-20b" ) ``` -------------------------------- ### Set Request Timeouts for Groq Client Source: https://github.com/groq/groq-python/blob/main/README.md Explains how to define request timeout durations globally or per-request using float values or httpx.Timeout objects. ```python from groq import Groq import httpx # Configure the default for all requests: client = Groq(timeout=20.0) # More granular control: client = Groq(timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0)) # Override per-request: client.with_options(timeout=5.0).chat.completions.create( messages=[{"role": "system", "content": "You are a helpful assistant."}], model="openai/gpt-oss-20b" ) ``` -------------------------------- ### Stream Response Data with Groq Python SDK Source: https://github.com/groq/groq-python/blob/main/README.md Shows how to stream response data using the Groq Python SDK with `.with_streaming_response`. This method requires a context manager and allows reading the response body incrementally using methods like `iter_lines()`. It also provides access to response headers. ```python with client.chat.completions.with_streaming_response.create( messages=[ { "role": "system", "content": "You are a helpful assistant.", }, { "role": "user", "content": "Explain the importance of low latency LLMs", }, ], model="openai/gpt-oss-20b", ) as response: print(response.headers.get("X-My-Header")) for line in response.iter_lines(): print(line) ``` -------------------------------- ### DELETE /openai/v1/files/{file_id} Source: https://github.com/groq/groq-python/blob/main/api.md Deletes an existing file by its unique identifier. ```APIDOC ## DELETE /openai/v1/files/{file_id} ### Description Permanently removes a file from the Groq platform. ### Method DELETE ### Endpoint /openai/v1/files/{file_id} ### Parameters #### Path Parameters - **file_id** (string) - Required - The unique identifier of the file to delete. ### Response #### Success Response (200) - **id** (string) - The ID of the deleted file. - **deleted** (boolean) - Confirmation of deletion. ``` -------------------------------- ### Access Raw Response Headers and Data with Groq Python Source: https://github.com/groq/groq-python/blob/main/README.md Demonstrates how to retrieve raw response headers and parse the completion object from a Groq API call. It utilizes `.with_raw_response.` to access the `APIResponse` object, allowing inspection of headers like 'X-My-Header' and parsing the actual completion data. ```python from groq import Groq client = Groq() response = client.chat.completions.with_raw_response.create( messages=[ { "role": "system", "content": "You are a helpful assistant.", }, { "role": "user", "content": "Explain the importance of low latency LLMs", } ], model="openai/gpt-oss-20b", ) print(response.headers.get('X-My-Header')) completion = response.parse() # get the object that `chat.completions.create()` would have returned print(completion.id) ``` -------------------------------- ### Differentiate Null vs Missing Fields in API Responses Source: https://github.com/groq/groq-python/blob/main/README.md Shows how to use model_fields_set to determine if a field was explicitly returned as null or if it was omitted from the API response. ```python if response.my_field is None: if 'my_field' not in response.model_fields_set: print('Got json like {}, without a "my_field" key present at all.') else: print('Got json like {"my_field": null}.') ``` -------------------------------- ### Create Embedding (Python) Source: https://github.com/groq/groq-python/blob/main/api.md Defines the method for creating embeddings using the Groq client. This method accepts parameters and returns a CreateEmbeddingResponse object, corresponding to the POST /openai/v1/embeddings API endpoint. ```python # client.embeddings.create(**params) -> CreateEmbeddingResponse ``` -------------------------------- ### Import Completion Usage Type (Python) Source: https://github.com/groq/groq-python/blob/main/api.md Imports the CompletionUsage type from the groq.types module. This type is used to provide information about token usage for completion requests. ```python from groq.types import CompletionUsage ``` -------------------------------- ### Groq API Usage with Nested Parameters (Python) Source: https://github.com/groq/groq-python/blob/main/README.md Illustrates how to use nested parameters in Groq API calls, specifically for chat completions. Nested parameters are defined as `TypedDict` objects in Python. ```python from groq import Groq client = Groq() chat_completion = client.chat.completions.create( messages=[ { "content": "string", "role": "system", } ], model="meta-llama/llama-4-scout-17b-16e-instruct", compound_custom={}, ) print(chat_completion.compound_custom) ``` -------------------------------- ### Import Audio Translation Type (Python) Source: https://github.com/groq/groq-python/blob/main/api.md Imports the Translation type from the groq.types.audio module. This type represents the result of an audio translation request. ```python from groq.types.audio import Translation ``` -------------------------------- ### Import Batch Types (Python) Source: https://github.com/groq/groq-python/blob/main/api.md Imports types related to batch operations: BatchCreateResponse, BatchRetrieveResponse, BatchListResponse, and BatchCancelResponse from the groq.types module. These are essential for managing batch jobs. ```python from groq.types import ( BatchCreateResponse, BatchRetrieveResponse, BatchListResponse, BatchCancelResponse, ) ``` -------------------------------- ### Import Audio Transcription Type (Python) Source: https://github.com/groq/groq-python/blob/main/api.md Imports the Transcription type from the groq.types.audio module. This type is used to represent the result of an audio transcription request. ```python from groq.types.audio import Transcription ``` -------------------------------- ### Import Model Types (Python) Source: https://github.com/groq/groq-python/blob/main/api.md Imports types related to models: Model, ModelDeleted, and ModelListResponse from the groq.types module. These are used for retrieving and managing available models. ```python from groq.types import Model, ModelDeleted, ModelListResponse ``` -------------------------------- ### Import Embedding Types (Python) Source: https://github.com/groq/groq-python/blob/main/api.md Imports types related to embeddings, specifically CreateEmbeddingResponse and Embedding, from the groq.types module. These are used for creating and processing text embeddings. ```python from groq.types import CreateEmbeddingResponse, Embedding ``` -------------------------------- ### Delete File using Groq Python SDK Source: https://github.com/groq/groq-python/blob/main/api.md Deletes a specific file identified by its file_id using the Groq Python SDK. This operation returns a FileDeleteResponse object indicating the success of the deletion. ```python from groq import Groq client = Groq( api_key=os.environ.get("GROQ_API_KEY"), ) deletion_status = client.files.delete("file-id-to-delete") print(deletion_status) ``` -------------------------------- ### Import Shared Groq Types (Python) Source: https://github.com/groq/groq-python/blob/main/api.md Imports common types used across the Groq SDK, such as ErrorObject, FunctionDefinition, and FunctionParameters. These types are fundamental for defining and handling various API objects. ```python from groq.types import ErrorObject, FunctionDefinition, FunctionParameters ``` -------------------------------- ### Cancel Batch (Python) Source: https://github.com/groq/groq-python/blob/main/api.md Defines the method for canceling a specific batch job by its ID using the Groq client. This method returns a BatchCancelResponse object and corresponds to the POST /openai/v1/batches/{batch_id}/cancel API endpoint. ```python # client.batches.cancel(batch_id) -> BatchCancelResponse ``` -------------------------------- ### Delete Model (Python) Source: https://github.com/groq/groq-python/blob/main/api.md Defines the method for deleting a specific model by its ID using the Groq client. This method returns a ModelDeleted object and corresponds to the DELETE /openai/v1/models/{model} API endpoint. ```python # client.models.delete(model) -> ModelDeleted ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.