Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8a7b06e
perf(core): reduce conversation send hot-path reads
stainless-app[bot] Apr 18, 2026
074fe85
chore(internal): more robust bootstrap script
stainless-app[bot] Apr 22, 2026
aa75f2a
refactor: stop creating new isolated conversation blocks
stainless-app[bot] Apr 23, 2026
ed0a3d4
refactor: hard-deprecate isolated conversation blocks
stainless-app[bot] Apr 23, 2026
783c4a4
codegen metadata
stainless-app[bot] Apr 23, 2026
0b0940b
feat(core): add moonshot and kimi code BYOK providers
stainless-app[bot] Apr 24, 2026
d9ca27e
codegen metadata
stainless-app[bot] Apr 25, 2026
1039e5a
fix: use correct field name format for multipart file arrays
stainless-app[bot] Apr 27, 2026
f0c2ba8
feat: support setting headers via env
stainless-app[bot] Apr 27, 2026
ad914c6
codegen metadata
stainless-app[bot] Apr 28, 2026
17e3ec8
codegen metadata
stainless-app[bot] Apr 28, 2026
44207b4
codegen metadata
stainless-app[bot] Apr 28, 2026
802d477
codegen metadata
stainless-app[bot] Apr 28, 2026
bc6fce1
codegen metadata
stainless-app[bot] Apr 29, 2026
d01c5f7
codegen metadata
stainless-app[bot] Apr 30, 2026
d9a6109
chore(internal): reformat pyproject.toml
stainless-app[bot] Apr 30, 2026
eeab6b9
codegen metadata
stainless-app[bot] May 6, 2026
fe0c9ee
codegen metadata
stainless-app[bot] May 6, 2026
cbf36eb
fix(client): add missing f-string prefix in file type error message
stainless-app[bot] May 8, 2026
8d289a9
feat(internal/types): support eagerly validating pydantic iterators
stainless-app[bot] May 11, 2026
b5edad1
feat: cap v1 limit query params
stainless-app[bot] May 12, 2026
6813297
ci: pin GitHub Actions to commit SHAs
stainless-app[bot] May 12, 2026
afc9207
codegen metadata
stainless-app[bot] May 13, 2026
41b4796
codegen metadata
stainless-app[bot] May 14, 2026
7ba3b3d
release: 1.11.0
stainless-app[bot] May 14, 2026
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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
runs-on: ${{ github.repository == 'stainless-sdks/letta-sdk-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install Rye
run: |
Expand All @@ -46,7 +46,7 @@ jobs:
id-token: write
runs-on: ${{ github.repository == 'stainless-sdks/letta-sdk-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install Rye
run: |
Expand All @@ -67,7 +67,7 @@ jobs:
github.repository == 'stainless-sdks/letta-sdk-python' &&
!startsWith(github.ref, 'refs/heads/stl/')
id: github-oidc
uses: actions/github-script@v8
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: core.setOutput('github_token', await core.getIDToken());

Expand All @@ -87,7 +87,7 @@ jobs:
runs-on: ${{ github.repository == 'stainless-sdks/letta-sdk-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install Rye
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install Rye
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
if: github.repository == 'letta-ai/letta-python' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Check release environment
run: |
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 @@
{
".": "1.10.3"
".": "1.11.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: 126
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/letta-ai%2Fletta-sdk-873f657578988b58f8920addcacee62440377571f56a48c44b3505342a4cdc96.yml
openapi_spec_hash: 6c5174fa1eddd3c0b8b072320d1d32b0
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/letta-ai/letta-sdk-3bf3ab3365d6881961c545ff1cde437e4060d17a0d46d02116f3be0b79158f5d.yml
openapi_spec_hash: 6c229aac939ec0b917ed2dcd5547deeb
config_hash: f2ff70633d052a11601ad82a5afcfaec
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
# Changelog

## 1.11.0 (2026-05-14)

Full Changelog: [v1.10.3...v1.11.0](https://github.com/letta-ai/letta-python/compare/v1.10.3...v1.11.0)

### Features

* cap v1 limit query params ([b5edad1](https://github.com/letta-ai/letta-python/commit/b5edad120811911e5f095dd280ba98c0da956acb))
* **core:** add moonshot and kimi code BYOK providers ([0b0940b](https://github.com/letta-ai/letta-python/commit/0b0940b2ae070319c6a0f2cc4114a4d2b09d2b5a))
* **internal/types:** support eagerly validating pydantic iterators ([8d289a9](https://github.com/letta-ai/letta-python/commit/8d289a9daa714a4f54d4d0483df35c5236b46797))
* support setting headers via env ([f0c2ba8](https://github.com/letta-ai/letta-python/commit/f0c2ba89ef56ee33ff8137eee8c3a78c3b3ec689))


### Bug Fixes

* **client:** add missing f-string prefix in file type error message ([cbf36eb](https://github.com/letta-ai/letta-python/commit/cbf36ebe5738e46ecdd278db55d8dba1fd8fa373))
* use correct field name format for multipart file arrays ([1039e5a](https://github.com/letta-ai/letta-python/commit/1039e5a7bb425f445ec815d15fcead06e2801a36))


### Performance Improvements

* **core:** reduce conversation send hot-path reads ([8a7b06e](https://github.com/letta-ai/letta-python/commit/8a7b06eee9b4d0ad28fe1016de5237797dfb01eb))


### Chores

* **internal:** more robust bootstrap script ([074fe85](https://github.com/letta-ai/letta-python/commit/074fe8585483c25a8c2cee48e3324db034901b47))
* **internal:** reformat pyproject.toml ([d9a6109](https://github.com/letta-ai/letta-python/commit/d9a6109c3a68c5ad4bb2980ea5b53e3fc7a0e96b))


### Refactors

* hard-deprecate isolated conversation blocks ([ed0a3d4](https://github.com/letta-ai/letta-python/commit/ed0a3d42fcbc0b9b4af4a3fe63e2dff5bb0161f0))
* stop creating new isolated conversation blocks ([aa75f2a](https://github.com/letta-ai/letta-python/commit/aa75f2af909e91d5a30e81ec2ac6cde27193a074))

## 1.10.3 (2026-04-17)

Full Changelog: [v1.10.2...v1.10.3](https://github.com/letta-ai/letta-python/compare/v1.10.2...v1.10.3)
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "letta-client"
version = "1.10.3"
version = "1.11.0"
description = "The official Python library for the letta API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down Expand Up @@ -168,7 +168,7 @@ show_error_codes = true
#
# We also exclude our `tests` as mypy doesn't always infer
# types correctly and Pyright will still catch any type errors.
exclude = ['src/letta_client/_files.py', '_dev/.*.py', 'tests/.*']
exclude = ["src/letta_client/_files.py", "_dev/.*.py", "tests/.*"]

strict_equality = true
implicit_reexport = true
Expand Down
2 changes: 1 addition & 1 deletion scripts/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

cd "$(dirname "$0")/.."

if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then
if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "${SKIP_BREW:-}" != "1" ] && [ -t 0 ]; then
brew bundle check >/dev/null 2>&1 || {
echo -n "==> Install Homebrew dependencies? (y/N): "
read -r response
Expand Down
24 changes: 23 additions & 1 deletion src/letta_client/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
RequestOptions,
not_given,
)
from ._utils import is_given, get_async_library
from ._utils import (
is_given,
is_mapping_t,
get_async_library,
)
from ._compat import cached_property
from ._version import __version__
from ._response import (
Expand Down Expand Up @@ -165,6 +169,15 @@ def __init__(
except KeyError as exc:
raise ValueError(f"Unknown environment: {environment}") from exc

custom_headers_env = os.environ.get("LETTA_CUSTOM_HEADERS")
if custom_headers_env is not None:
parsed: dict[str, str] = {}
for line in custom_headers_env.split("\n"):
colon = line.find(":")
if colon >= 0:
parsed[line[:colon].strip()] = line[colon + 1 :].strip()
default_headers = {**parsed, **(default_headers if is_mapping_t(default_headers) else {})}

super().__init__(
version=__version__,
base_url=base_url,
Expand Down Expand Up @@ -482,6 +495,15 @@ def __init__(
except KeyError as exc:
raise ValueError(f"Unknown environment: {environment}") from exc

custom_headers_env = os.environ.get("LETTA_CUSTOM_HEADERS")
if custom_headers_env is not None:
parsed: dict[str, str] = {}
for line in custom_headers_env.split("\n"):
colon = line.find(":")
if colon >= 0:
parsed[line[:colon].strip()] = line[colon + 1 :].strip()
default_headers = {**parsed, **(default_headers if is_mapping_t(default_headers) else {})}

super().__init__(
version=__version__,
base_url=base_url,
Expand Down
2 changes: 1 addition & 1 deletion src/letta_client/_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ async def async_to_httpx_files(files: RequestFiles | None) -> HttpxRequestFiles
elif is_sequence_t(files):
files = [(key, await _async_transform_file(file)) for key, file in files]
else:
raise TypeError("Unexpected file type input {type(files)}, expected mapping or sequence")
raise TypeError(f"Unexpected file type input {type(files)}, expected mapping or sequence")

return files

Expand Down
80 changes: 80 additions & 0 deletions src/letta_client/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
ClassVar,
Protocol,
Required,
Annotated,
ParamSpec,
TypeAlias,
TypedDict,
TypeGuard,
final,
Expand Down Expand Up @@ -79,7 +81,15 @@
from ._constants import RAW_RESPONSE_HEADER

if TYPE_CHECKING:
from pydantic import GetCoreSchemaHandler, ValidatorFunctionWrapHandler
from pydantic_core import CoreSchema, core_schema
from pydantic_core.core_schema import ModelField, ModelSchema, LiteralSchema, ModelFieldsSchema
else:
try:
from pydantic_core import CoreSchema, core_schema
except ImportError:
CoreSchema = None
core_schema = None

__all__ = ["BaseModel", "GenericModel"]

Expand Down Expand Up @@ -396,6 +406,76 @@ def model_dump_json(
)


class _EagerIterable(list[_T], Generic[_T]):
"""
Accepts any Iterable[T] input (including generators), consumes it
eagerly, and validates all items upfront.

Validation preserves the original container type where possible
(e.g. a set[T] stays a set[T]). Serialization (model_dump / JSON)
always emits a list — round-tripping through model_dump() will not
restore the original container type.
"""

@classmethod
def __get_pydantic_core_schema__(
cls,
source_type: Any,
handler: GetCoreSchemaHandler,
) -> CoreSchema:
(item_type,) = get_args(source_type) or (Any,)
item_schema: CoreSchema = handler.generate_schema(item_type)
list_of_items_schema: CoreSchema = core_schema.list_schema(item_schema)

return core_schema.no_info_wrap_validator_function(
cls._validate,
list_of_items_schema,
serialization=core_schema.plain_serializer_function_ser_schema(
cls._serialize,
info_arg=False,
),
)

@staticmethod
def _validate(v: Iterable[_T], handler: "ValidatorFunctionWrapHandler") -> Any:
original_type: type[Any] = type(v)

# Normalize to list so list_schema can validate each item
if isinstance(v, list):
items: list[_T] = v
else:
try:
items = list(v)
except TypeError as e:
raise TypeError("Value is not iterable") from e

# Validate items against the inner schema
validated: list[_T] = handler(items)

# Reconstruct original container type
if original_type is list:
return validated
# str(list) produces the list's repr, not a string built from items,
# so skip reconstruction for str and its subclasses.
if issubclass(original_type, str):
return validated
try:
return original_type(validated)
except (TypeError, ValueError):
# If the type cannot be reconstructed, just return the validated list
return validated

@staticmethod
def _serialize(v: Iterable[_T]) -> list[_T]:
"""Always serialize as a list so Pydantic's JSON encoder is happy."""
if isinstance(v, list):
return v
return list(v)


EagerIterable: TypeAlias = Annotated[Iterable[_T], _EagerIterable]


def _construct_field(value: object, field: FieldInfo, key: str) -> object:
if value is None:
return field_get_default(field)
Expand Down
8 changes: 2 additions & 6 deletions src/letta_client/_qs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

from typing import Any, List, Tuple, Union, Mapping, TypeVar
from urllib.parse import parse_qs, urlencode
from typing_extensions import Literal, get_args
from typing_extensions import get_args

from ._types import NotGiven, not_given
from ._types import NotGiven, ArrayFormat, NestedFormat, not_given
from ._utils import flatten

_T = TypeVar("_T")


ArrayFormat = Literal["comma", "repeat", "indices", "brackets"]
NestedFormat = Literal["dots", "brackets"]

PrimitiveData = Union[str, int, float, bool, None]
# this should be Data = Union[PrimitiveData, "List[Data]", "Tuple[Data]", "Mapping[str, Data]"]
# https://github.com/microsoft/pyright/issues/3555
Expand Down
3 changes: 3 additions & 0 deletions src/letta_client/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
ModelT = TypeVar("ModelT", bound=pydantic.BaseModel)
_T = TypeVar("_T")

ArrayFormat = Literal["comma", "repeat", "indices", "brackets"]
NestedFormat = Literal["dots", "brackets"]


# Approximates httpx internal ProxiesTypes and RequestFiles types
# while adding support for `PathLike` instances
Expand Down
Loading