Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
timeout-minutes: 10
name: lint
runs-on: ${{ github.repository == 'stainless-sdks/groqcloud-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@v4

Expand All @@ -34,17 +35,31 @@ jobs:
- name: Run lints
run: ./scripts/lint

upload:
if: github.repository == 'stainless-sdks/groqcloud-python'
build:
if: github.repository == 'stainless-sdks/groqcloud-python' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork)
timeout-minutes: 10
name: upload
name: build
permissions:
contents: read
id-token: write
runs-on: depot-ubuntu-24.04
steps:
- uses: actions/checkout@v4

- name: Install Rye
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'

- name: Install dependencies
run: rye sync --all-features

- name: Run build
run: rye build

- name: Get GitHub OIDC Token
id: github-oidc
uses: actions/github-script@v6
Expand All @@ -62,6 +77,7 @@ jobs:
timeout-minutes: 10
name: test
runs-on: ${{ github.repository == 'stainless-sdks/groqcloud-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.29.0"
".": "0.30.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 17
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/groqcloud%2Fgroqcloud-1cdb4a5cd72775ee5627d03ec76df2a4d1dc5d2de4a5352ff76e0e4a228fd1a3.yml
openapi_spec_hash: ce67895609996ea0c6086814d47641ab
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/groqcloud%2Fgroqcloud-f687d041a4a85f21b5f6a9fe6592ca87a031aeae448c535bad1bee61114f7818.yml
openapi_spec_hash: f4d39fb37c4e890c8e1e4fc182d7c50a
config_hash: 6b1c374dcc1ffa3165dd22f52a77ff89
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# Changelog

## 0.30.0 (2025-07-11)

Full Changelog: [v0.29.0...v0.30.0](https://github.com/groq/groq-python/compare/v0.29.0...v0.30.0)

### Features

* **api:** api update ([55abbbc](https://github.com/groq/groq-python/commit/55abbbc39b85f5f179ce698b67d493e0ad359773))
* **api:** api update ([cbd7df0](https://github.com/groq/groq-python/commit/cbd7df040d8b70d22ba5527d29a915459c69d482))


### Bug Fixes

* **ci:** correct conditional ([a470509](https://github.com/groq/groq-python/commit/a4705094213290bf95c599dbfe30be078d584677))
* **ci:** release-doctor — report correct token name ([b036bba](https://github.com/groq/groq-python/commit/b036bba0a7e3a306cb9849fc701fce32aec00501))
* **parsing:** correctly handle nested discriminated unions ([f57dd03](https://github.com/groq/groq-python/commit/f57dd033543b07c24a6c2ae11d8e7303e3888cd7))
* performance tier enum overloads ([dc7c41b](https://github.com/groq/groq-python/commit/dc7c41bdfc2759e36711d6faae0c3e29d8882b84))


### Chores

* Add bklieger-groq to CODEOWNERS ([5b9fc30](https://github.com/groq/groq-python/commit/5b9fc30d6aa58a9b9fd3eb32b79618f4551316e2))
* **ci:** change upload type ([7044a2b](https://github.com/groq/groq-python/commit/7044a2b6fbdb996aab8e11a9c56bcbccb72530dc))
* **ci:** only run for pushes and fork pull requests ([dc1b9ee](https://github.com/groq/groq-python/commit/dc1b9eea773fe7d9c8f972ad375024a99e03a58f))
* fix code owners ([464ada9](https://github.com/groq/groq-python/commit/464ada9d4cde3fb7525e383e747178c94348472d))
* **internal:** bump pinned h11 dep ([47bddbd](https://github.com/groq/groq-python/commit/47bddbdf76ec98464b97886d5e6c0fd5f25af453))
* **internal:** codegen related update ([9d7f071](https://github.com/groq/groq-python/commit/9d7f071f7947f7895258bdee533e0e99f20aa5b8))
* **package:** mark python 3.13 as supported ([55353b9](https://github.com/groq/groq-python/commit/55353b9f792db825a7b14be2221e342a11261c59))
* **readme:** fix version rendering on pypi ([e145b51](https://github.com/groq/groq-python/commit/e145b5135125b25f1a0a5856dcf1223503882590))

## 0.29.0 (2025-06-25)

Full Changelog: [v0.28.0...v0.29.0](https://github.com/groq/groq-python/compare/v0.28.0...v0.29.0)
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Groq Python API library

[![PyPI version](<https://img.shields.io/pypi/v/groq.svg?label=pypi%20(stable)>)](https://pypi.org/project/groq/)
<!-- prettier-ignore -->
[![PyPI version](https://img.shields.io/pypi/v/groq.svg?label=pypi%20(stable))](https://pypi.org/project/groq/)

The Groq Python library provides convenient access to the Groq REST API from any Python 3.8+
application. The library includes type definitions for all request params and response fields,
Expand Down Expand Up @@ -141,7 +142,7 @@ client = Groq()
chat_completion = client.chat.completions.create(
messages=[
{
"content": "content",
"content": "string",
"role": "system",
}
],
Expand Down
2 changes: 1 addition & 1 deletion bin/check-release-environment
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
errors=()

if [ -z "${PYPI_TOKEN}" ]; then
errors+=("The GROQ_PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.")
errors+=("The PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.")
fi

lenErrors=${#errors[@]}
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "groq"
version = "0.29.0"
version = "0.30.0"
description = "The official Python library for the groq API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand All @@ -24,6 +24,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Operating System :: OS Independent",
"Operating System :: POSIX",
"Operating System :: MacOS",
Expand Down
6 changes: 3 additions & 3 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ filelock==3.12.4
frozenlist==1.6.2
# via aiohttp
# via aiosignal
h11==0.14.0
h11==0.16.0
# via httpcore
httpcore==1.0.2
httpcore==1.0.9
# via httpx
httpx==0.28.1
# via groq
# via httpx-aiohttp
# via respx
httpx-aiohttp==0.1.6
httpx-aiohttp==0.1.8
# via groq
idna==3.4
# via anyio
Expand Down
6 changes: 3 additions & 3 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ exceptiongroup==1.2.2
frozenlist==1.6.2
# via aiohttp
# via aiosignal
h11==0.14.0
h11==0.16.0
# via httpcore
httpcore==1.0.2
httpcore==1.0.9
# via httpx
httpx==0.28.1
# via groq
# via httpx-aiohttp
httpx-aiohttp==0.1.6
httpx-aiohttp==0.1.8
# via groq
idna==3.4
# via anyio
Expand Down
12 changes: 7 additions & 5 deletions scripts/utils/upload-artifact.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env bash
set -exuo pipefail

RESPONSE=$(curl -X POST "$URL" \
FILENAME=$(basename dist/*.whl)

RESPONSE=$(curl -X POST "$URL?filename=$FILENAME" \
-H "Authorization: Bearer $AUTH" \
-H "Content-Type: application/json")

Expand All @@ -12,13 +14,13 @@ if [[ "$SIGNED_URL" == "null" ]]; then
exit 1
fi

UPLOAD_RESPONSE=$(tar -cz . | curl -v -X PUT \
-H "Content-Type: application/gzip" \
--data-binary @- "$SIGNED_URL" 2>&1)
UPLOAD_RESPONSE=$(curl -v -X PUT \
-H "Content-Type: binary/octet-stream" \
--data-binary "@dist/$FILENAME" "$SIGNED_URL" 2>&1)

if echo "$UPLOAD_RESPONSE" | grep -q "HTTP/[0-9.]* 200"; then
echo -e "\033[32mUploaded build to Stainless storage.\033[0m"
echo -e "\033[32mInstallation: pip install 'https://pkg.stainless.com/s/groqcloud-python/$SHA'\033[0m"
echo -e "\033[32mInstallation: pip install 'https://pkg.stainless.com/s/groqcloud-python/$SHA/$FILENAME'\033[0m"
else
echo -e "\033[31mFailed to upload artifact.\033[0m"
exit 1
Expand Down
13 changes: 8 additions & 5 deletions src/groq/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import os
import inspect
from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, cast
from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, Optional, cast
from datetime import date, datetime
from typing_extensions import (
List,
Unpack,
Literal,
ClassVar,
Expand Down Expand Up @@ -366,7 +367,7 @@ def _construct_field(value: object, field: FieldInfo, key: str) -> object:
if type_ is None:
raise RuntimeError(f"Unexpected field type is None for {key}")

return construct_type(value=value, type_=type_)
return construct_type(value=value, type_=type_, metadata=getattr(field, "metadata", None))


def is_basemodel(type_: type) -> bool:
Expand Down Expand Up @@ -420,7 +421,7 @@ def construct_type_unchecked(*, value: object, type_: type[_T]) -> _T:
return cast(_T, construct_type(value=value, type_=type_))


def construct_type(*, value: object, type_: object) -> object:
def construct_type(*, value: object, type_: object, metadata: Optional[List[Any]] = None) -> object:
"""Loose coercion to the expected type with construction of nested values.

If the given value does not match the expected type then it is returned as-is.
Expand All @@ -438,8 +439,10 @@ def construct_type(*, value: object, type_: object) -> object:
type_ = type_.__value__ # type: ignore[unreachable]

# unwrap `Annotated[T, ...]` -> `T`
if is_annotated_type(type_):
meta: tuple[Any, ...] = get_args(type_)[1:]
if metadata is not None:
meta: tuple[Any, ...] = tuple(metadata)
elif is_annotated_type(type_):
meta = get_args(type_)[1:]
type_ = extract_type_arg(type_, 0)
else:
meta = tuple()
Expand Down
2 changes: 1 addition & 1 deletion src/groq/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "groq"
__version__ = "0.29.0" # x-release-please-version
__version__ = "0.30.0" # x-release-please-version
16 changes: 8 additions & 8 deletions src/groq/resources/chat/completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def create(
response_format: Optional[completion_create_params.ResponseFormat] | NotGiven = NOT_GIVEN,
search_settings: Optional[completion_create_params.SearchSettings] | NotGiven = NOT_GIVEN,
seed: Optional[int] | NotGiven = NOT_GIVEN,
service_tier: Optional[Literal["auto", "on_demand", "flex"]] | NotGiven = NOT_GIVEN,
service_tier: Optional[Literal["auto", "on_demand", "flex", "performance"]] | NotGiven = NOT_GIVEN,
stop: Union[Optional[str], List[str], None] | NotGiven = NOT_GIVEN,
store: Optional[bool] | NotGiven = NOT_GIVEN,
stream: Optional[Literal[False]] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -116,7 +116,7 @@ def create(
response_format: Optional[completion_create_params.ResponseFormat] | NotGiven = NOT_GIVEN,
search_settings: Optional[completion_create_params.SearchSettings] | NotGiven = NOT_GIVEN,
seed: Optional[int] | NotGiven = NOT_GIVEN,
service_tier: Optional[Literal["auto", "on_demand", "flex"]] | NotGiven = NOT_GIVEN,
service_tier: Optional[Literal["auto", "on_demand", "flex", "performance"]] | NotGiven = NOT_GIVEN,
stop: Union[Optional[str], List[str], None] | NotGiven = NOT_GIVEN,
store: Optional[bool] | NotGiven = NOT_GIVEN,
stream: Literal[True],
Expand Down Expand Up @@ -159,7 +159,7 @@ def create(
response_format: Optional[completion_create_params.ResponseFormat] | NotGiven = NOT_GIVEN,
search_settings: Optional[completion_create_params.SearchSettings] | NotGiven = NOT_GIVEN,
seed: Optional[int] | NotGiven = NOT_GIVEN,
service_tier: Optional[Literal["auto", "on_demand", "flex"]] | NotGiven = NOT_GIVEN,
service_tier: Optional[Literal["auto", "on_demand", "flex", "performance"]] | NotGiven = NOT_GIVEN,
stop: Union[Optional[str], List[str], None] | NotGiven = NOT_GIVEN,
store: Optional[bool] | NotGiven = NOT_GIVEN,
stream: bool,
Expand Down Expand Up @@ -211,7 +211,7 @@ def create(
response_format: Optional[completion_create_params.ResponseFormat] | NotGiven = NOT_GIVEN,
search_settings: Optional[completion_create_params.SearchSettings] | NotGiven = NOT_GIVEN,
seed: Optional[int] | NotGiven = NOT_GIVEN,
service_tier: Optional[Literal["auto", "on_demand", "flex"]] | NotGiven = NOT_GIVEN,
service_tier: Optional[Literal["auto", "on_demand", "flex", "performance"]] | NotGiven = NOT_GIVEN,
stop: Union[Optional[str], List[str], None] | NotGiven = NOT_GIVEN,
store: Optional[bool] | NotGiven = NOT_GIVEN,
stream: Optional[Literal[False]] | Literal[True] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -455,7 +455,7 @@ async def create(
response_format: Optional[completion_create_params.ResponseFormat] | NotGiven = NOT_GIVEN,
search_settings: Optional[completion_create_params.SearchSettings] | NotGiven = NOT_GIVEN,
seed: Optional[int] | NotGiven = NOT_GIVEN,
service_tier: Optional[Literal["auto", "on_demand", "flex"]] | NotGiven = NOT_GIVEN,
service_tier: Optional[Literal["auto", "on_demand", "flex", "performance"]] | NotGiven = NOT_GIVEN,
stop: Union[Optional[str], List[str], None] | NotGiven = NOT_GIVEN,
store: Optional[bool] | NotGiven = NOT_GIVEN,
stream: Optional[Literal[False]] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -498,7 +498,7 @@ async def create(
response_format: Optional[completion_create_params.ResponseFormat] | NotGiven = NOT_GIVEN,
search_settings: Optional[completion_create_params.SearchSettings] | NotGiven = NOT_GIVEN,
seed: Optional[int] | NotGiven = NOT_GIVEN,
service_tier: Optional[Literal["auto", "on_demand", "flex"]] | NotGiven = NOT_GIVEN,
service_tier: Optional[Literal["auto", "on_demand", "flex", "performance"]] | NotGiven = NOT_GIVEN,
stop: Union[Optional[str], List[str], None] | NotGiven = NOT_GIVEN,
store: Optional[bool] | NotGiven = NOT_GIVEN,
stream: Literal[True],
Expand Down Expand Up @@ -541,7 +541,7 @@ async def create(
response_format: Optional[completion_create_params.ResponseFormat] | NotGiven = NOT_GIVEN,
search_settings: Optional[completion_create_params.SearchSettings] | NotGiven = NOT_GIVEN,
seed: Optional[int] | NotGiven = NOT_GIVEN,
service_tier: Optional[Literal["auto", "on_demand", "flex"]] | NotGiven = NOT_GIVEN,
service_tier: Optional[Literal["auto", "on_demand", "flex", "performance"]] | NotGiven = NOT_GIVEN,
stop: Union[Optional[str], List[str], None] | NotGiven = NOT_GIVEN,
store: Optional[bool] | NotGiven = NOT_GIVEN,
stream: bool,
Expand Down Expand Up @@ -593,7 +593,7 @@ async def create(
response_format: Optional[completion_create_params.ResponseFormat] | NotGiven = NOT_GIVEN,
search_settings: Optional[completion_create_params.SearchSettings] | NotGiven = NOT_GIVEN,
seed: Optional[int] | NotGiven = NOT_GIVEN,
service_tier: Optional[Literal["auto", "on_demand", "flex"]] | NotGiven = NOT_GIVEN,
service_tier: Optional[Literal["auto", "on_demand", "flex", "performance"]] | NotGiven = NOT_GIVEN,
stop: Union[Optional[str], List[str], None] | NotGiven = NOT_GIVEN,
store: Optional[bool] | NotGiven = NOT_GIVEN,
stream: Optional[Literal[False]] | Literal[True] | NotGiven = NOT_GIVEN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

from __future__ import annotations

from typing import Iterable, Optional
from typing import Union, Iterable, Optional
from typing_extensions import Literal, Required, TypedDict

from .chat_completion_content_part_text_param import ChatCompletionContentPartTextParam
from .chat_completion_message_tool_call_param import ChatCompletionMessageToolCallParam

__all__ = ["ChatCompletionAssistantMessageParam", "FunctionCall"]
Expand All @@ -27,7 +28,7 @@ class ChatCompletionAssistantMessageParam(TypedDict, total=False):
role: Required[Literal["assistant"]]
"""The role of the messages author, in this case `assistant`."""

content: Optional[str]
content: Union[str, Iterable[ChatCompletionContentPartTextParam], None]
"""The contents of the assistant message.

Required unless `tool_calls` or `function_call` is specified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

from __future__ import annotations

from typing import Union, Iterable
from typing_extensions import Literal, Required, TypedDict

from .chat_completion_content_part_text_param import ChatCompletionContentPartTextParam

__all__ = ["ChatCompletionSystemMessageParam"]


class ChatCompletionSystemMessageParam(TypedDict, total=False):
content: Required[str]
content: Required[Union[str, Iterable[ChatCompletionContentPartTextParam]]]
"""The contents of the system message."""

role: Required[Literal["system"]]
Expand Down
5 changes: 4 additions & 1 deletion src/groq/types/chat/chat_completion_tool_message_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

from __future__ import annotations

from typing import Union, Iterable
from typing_extensions import Literal, Required, TypedDict

from .chat_completion_content_part_param import ChatCompletionContentPartParam

__all__ = ["ChatCompletionToolMessageParam"]


class ChatCompletionToolMessageParam(TypedDict, total=False):
content: Required[str]
content: Required[Union[str, Iterable[ChatCompletionContentPartParam]]]
"""The contents of the tool message."""

role: Required[Literal["tool"]]
Expand Down
2 changes: 1 addition & 1 deletion src/groq/types/chat/completion_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class CompletionCreateParams(TypedDict, total=False):
`system_fingerprint` response parameter to monitor changes in the backend.
"""

service_tier: Optional[Literal["auto", "on_demand", "flex"]]
service_tier: Optional[Literal["auto", "on_demand", "flex", "performance"]]
"""The service tier to use for the request. Defaults to `on_demand`.

- `auto` will automatically select the highest tier available within the rate
Expand Down
Loading