Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
de6e4e4
refactor(types): use `extra_items` from PEP 728
stainless-app[bot] Mar 5, 2026
e3ed836
chore(ci): skip uploading artifacts on stainless-internal branches
stainless-app[bot] Mar 7, 2026
3a623d4
chore: update placeholder string
stainless-app[bot] Mar 7, 2026
b098b05
fix(pydantic): do not pass `by_alias` unless set
stainless-app[bot] Mar 16, 2026
23ea212
fix(deps): bump minimum typing-extensions version
stainless-app[bot] Mar 16, 2026
1fc1ee4
chore(internal): tweak CI branches
stainless-app[bot] Mar 16, 2026
e385e21
fix: sanitize endpoint path params
stainless-app[bot] Mar 19, 2026
97672af
chore(internal): update gitignore
stainless-app[bot] Mar 23, 2026
e11e58f
chore(ci): skip lint on metadata-only changes
stainless-app[bot] Mar 24, 2026
04ba964
feat(internal): implement indices array format for query and form ser…
stainless-app[bot] Mar 26, 2026
80f3981
fix(client): preserve hardcoded query params when merging with user p…
stainless-app[bot] Apr 7, 2026
721e574
fix: ensure file data are only sent as 1 parameter
stainless-app[bot] Apr 10, 2026
5207295
docs: improve examples
stainless-app[bot] Apr 10, 2026
62a7347
docs: update examples
stainless-app[bot] Apr 10, 2026
5903593
chore(ci): remove release-doctor workflow
stainless-app[bot] Apr 14, 2026
43970d6
perf(client): optimize file structure copying in multipart requests
stainless-app[bot] Apr 17, 2026
a84687b
chore(internal): more robust bootstrap script
stainless-app[bot] Apr 22, 2026
2d8e8c2
codegen metadata
stainless-app[bot] Apr 22, 2026
a6664c3
fix: use correct field name format for multipart file arrays
stainless-app[bot] Apr 27, 2026
e773bb2
feat: support setting headers via env
stainless-app[bot] Apr 27, 2026
1504106
codegen metadata
stainless-app[bot] Apr 29, 2026
7da3852
codegen metadata
stainless-app[bot] Apr 30, 2026
84db3a8
chore(internal): reformat pyproject.toml
stainless-app[bot] Apr 30, 2026
8bf218c
release: 0.4.0
stainless-app[bot] Apr 30, 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
26 changes: 16 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: CI
on:
push:
branches-ignore:
- 'generated'
- 'codegen/**'
- 'integrated/**'
- 'stl-preview-head/**'
- 'stl-preview-base/**'
branches:
- '**'
- '!integrated/**'
- '!stl-preview-head/**'
- '!stl-preview-base/**'
- '!generated'
- '!codegen/**'
- 'codegen/stl/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
Expand All @@ -17,7 +19,7 @@ jobs:
timeout-minutes: 10
name: lint
runs-on: ${{ github.repository == 'stainless-sdks/dedalus-sdk-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
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

Expand All @@ -33,7 +35,7 @@ jobs:
run: ./scripts/lint

build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
timeout-minutes: 10
name: build
permissions:
Expand All @@ -55,14 +57,18 @@ jobs:
run: uv build

- name: Get GitHub OIDC Token
if: github.repository == 'stainless-sdks/dedalus-sdk-python'
if: |-
github.repository == 'stainless-sdks/dedalus-sdk-python' &&
!startsWith(github.ref, 'refs/heads/stl/')
id: github-oidc
uses: actions/github-script@v8
with:
script: core.setOutput('github_token', await core.getIDToken());

- name: Upload tarball
if: github.repository == 'stainless-sdks/dedalus-sdk-python'
if: |-
github.repository == 'stainless-sdks/dedalus-sdk-python' &&
!startsWith(github.ref, 'refs/heads/stl/')
env:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
Expand Down
22 changes: 0 additions & 22 deletions .github/workflows/release-doctor.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.prism.log
.stdy.log
_dev

__pycache__
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.3.0"
".": "0.4.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: 12
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/dedalus-labs%2Fdedalus-sdk-78928123e88f6699e87022537ef23c34c0a802c5b78ac0c5259b30b59371492e.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/dedalus-labs/dedalus-sdk-c82d44d0a47f030d4de74379ae24619a50ace0d8740ccbd92b2a1a98db054e94.yml
openapi_spec_hash: 50b6107b70d1a6367726f78a04af5493
config_hash: b57dddec045c6790044b72c73f0d1891
config_hash: bd51a8c451379aa0f2d3030a24074a3f
47 changes: 47 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,52 @@
# Changelog

## 0.4.0 (2026-04-30)

Full Changelog: [v0.3.0...v0.4.0](https://github.com/dedalus-labs/dedalus-sdk-python/compare/v0.3.0...v0.4.0)

### Features

* **internal:** implement indices array format for query and form serialization ([04ba964](https://github.com/dedalus-labs/dedalus-sdk-python/commit/04ba9644e8c73b3eff7b8ad01211d90e354a889d))
* support setting headers via env ([e773bb2](https://github.com/dedalus-labs/dedalus-sdk-python/commit/e773bb29d5221a76cdc2b8a38f430920dd821b13))


### Bug Fixes

* **client:** preserve hardcoded query params when merging with user params ([80f3981](https://github.com/dedalus-labs/dedalus-sdk-python/commit/80f3981cb6e10bd7a9dbe39412abbd6277b0ab64))
* **deps:** bump minimum typing-extensions version ([23ea212](https://github.com/dedalus-labs/dedalus-sdk-python/commit/23ea21291b2cf443c594661acfc6e19e95077162))
* ensure file data are only sent as 1 parameter ([721e574](https://github.com/dedalus-labs/dedalus-sdk-python/commit/721e5748d4843fe0f6dbf07c34766550d09ab05e))
* **pydantic:** do not pass `by_alias` unless set ([b098b05](https://github.com/dedalus-labs/dedalus-sdk-python/commit/b098b05e30ec6487a6467bd928ce3c725d3f2aa0))
* sanitize endpoint path params ([e385e21](https://github.com/dedalus-labs/dedalus-sdk-python/commit/e385e215a38c3141ff675a58799511a306d2c879))
* use correct field name format for multipart file arrays ([a6664c3](https://github.com/dedalus-labs/dedalus-sdk-python/commit/a6664c3564abb8c0e50bd11b36477875f328a88b))


### Performance Improvements

* **client:** optimize file structure copying in multipart requests ([43970d6](https://github.com/dedalus-labs/dedalus-sdk-python/commit/43970d6a440ff547be0c90130b75b7483ad7711e))


### Chores

* **ci:** remove release-doctor workflow ([5903593](https://github.com/dedalus-labs/dedalus-sdk-python/commit/5903593748f7cf140310fb0fe057879323e12d67))
* **ci:** skip lint on metadata-only changes ([e11e58f](https://github.com/dedalus-labs/dedalus-sdk-python/commit/e11e58faac2c22be4f6e642b7313d09286b4a651))
* **ci:** skip uploading artifacts on stainless-internal branches ([e3ed836](https://github.com/dedalus-labs/dedalus-sdk-python/commit/e3ed83614aa445a6af6d48fbab67edd96d651123))
* **internal:** more robust bootstrap script ([a84687b](https://github.com/dedalus-labs/dedalus-sdk-python/commit/a84687b42b2b794198e05bb48f61d163fa3ed2c2))
* **internal:** reformat pyproject.toml ([84db3a8](https://github.com/dedalus-labs/dedalus-sdk-python/commit/84db3a8481a68a4e26b7694578e5c77f76d21972))
* **internal:** tweak CI branches ([1fc1ee4](https://github.com/dedalus-labs/dedalus-sdk-python/commit/1fc1ee460877941fb648448a415b37f868093058))
* **internal:** update gitignore ([97672af](https://github.com/dedalus-labs/dedalus-sdk-python/commit/97672afab610a2fa4dcc7224dbad013b10553089))
* update placeholder string ([3a623d4](https://github.com/dedalus-labs/dedalus-sdk-python/commit/3a623d4779430378efe9ceb6540ba6fddbc70041))


### Documentation

* improve examples ([5207295](https://github.com/dedalus-labs/dedalus-sdk-python/commit/5207295286986023ba1afbf6219a88dab046b439))
* update examples ([62a7347](https://github.com/dedalus-labs/dedalus-sdk-python/commit/62a7347483733a1cdf57454a38af1f521f13ef4d))


### Refactors

* **types:** use `extra_items` from PEP 728 ([de6e4e4](https://github.com/dedalus-labs/dedalus-sdk-python/commit/de6e4e466ad9e9f40be8d8d4f7ea6208c076267e))

## 0.3.0 (2026-02-28)

Full Changelog: [v0.2.0...v0.3.0](https://github.com/dedalus-labs/dedalus-sdk-python/compare/v0.2.0...v0.3.0)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ client = Dedalus()
chat_completion = client.chat.completions.create(
model="openai/gpt-5",
audio={
"format": "wav",
"voice": "string",
"format": "mp3",
"voice": "alloy",
},
)
print(chat_completion.audio)
Expand Down
21 changes: 0 additions & 21 deletions bin/check-release-environment

This file was deleted.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "dedalus_labs"
version = "0.3.0"
version = "0.4.0"
description = "The official Python library for the Dedalus API"
dynamic = ["readme"]
license = "MIT"
Expand All @@ -11,7 +11,7 @@ authors = [
dependencies = [
"httpx>=0.23.0, <1",
"pydantic>=1.9.0, <3",
"typing-extensions>=4.10, <5",
"typing-extensions>=4.14, <5",
"anyio>=3.5.0, <5",
"distro>=1.7.0, <2",
"sniffio",
Expand Down Expand Up @@ -156,7 +156,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/dedalus_labs/_files.py', '_dev/.*.py', 'tests/.*']
exclude = ["src/dedalus_labs/_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
4 changes: 4 additions & 0 deletions src/dedalus_labs/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,10 @@ def _build_request(
files = cast(HttpxRequestFiles, ForceMultipartDict())

prepared_url = self._prepare_url(options.url)
# preserve hard-coded query params from the url
if params and prepared_url.query:
params = {**dict(prepared_url.params.items()), **params}
prepared_url = prepared_url.copy_with(raw_path=prepared_url.raw_path.split(b"?", 1)[0])
if "_" in prepared_url.host:
# work around https://github.com/encode/httpx/discussions/2880
kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")}
Expand Down
24 changes: 23 additions & 1 deletion src/dedalus_labs/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,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 ._models import FinalRequestOptions
from ._version import __version__
Expand Down Expand Up @@ -168,6 +172,15 @@ def __init__(
except KeyError as exc:
raise ValueError(f"Unknown environment: {environment}") from exc

custom_headers_env = os.environ.get("DEDALUS_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 @@ -495,6 +508,15 @@ def __init__(
except KeyError as exc:
raise ValueError(f"Unknown environment: {environment}") from exc

custom_headers_env = os.environ.get("DEDALUS_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
11 changes: 9 additions & 2 deletions src/dedalus_labs/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import TYPE_CHECKING, Any, Union, Generic, TypeVar, Callable, cast, overload
from datetime import date, datetime
from typing_extensions import Self, Literal
from typing_extensions import Self, Literal, TypedDict

import pydantic
from pydantic.fields import FieldInfo
Expand Down Expand Up @@ -131,6 +131,10 @@ def model_json(model: pydantic.BaseModel, *, indent: int | None = None) -> str:
return model.model_dump_json(indent=indent)


class _ModelDumpKwargs(TypedDict, total=False):
by_alias: bool


def model_dump(
model: pydantic.BaseModel,
*,
Expand All @@ -142,14 +146,17 @@ def model_dump(
by_alias: bool | None = None,
) -> dict[str, Any]:
if (not PYDANTIC_V1) or hasattr(model, "model_dump"):
kwargs: _ModelDumpKwargs = {}
if by_alias is not None:
kwargs["by_alias"] = by_alias
return model.model_dump(
mode=mode,
exclude=exclude,
exclude_unset=exclude_unset,
exclude_defaults=exclude_defaults,
# warnings are not supported in Pydantic v1
warnings=True if PYDANTIC_V1 else warnings,
by_alias=by_alias,
**kwargs,
)
return cast(
"dict[str, Any]",
Expand Down
56 changes: 53 additions & 3 deletions src/dedalus_labs/_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import io
import os
import pathlib
from typing import overload
from typing_extensions import TypeGuard
from typing import Sequence, cast, overload
from typing_extensions import TypeVar, TypeGuard

import anyio

Expand All @@ -17,7 +17,9 @@
HttpxFileContent,
HttpxRequestFiles,
)
from ._utils import is_tuple_t, is_mapping_t, is_sequence_t
from ._utils import is_list, is_mapping, is_tuple_t, is_mapping_t, is_sequence_t

_T = TypeVar("_T")


def is_base64_file_input(obj: object) -> TypeGuard[Base64FileInput]:
Expand Down Expand Up @@ -121,3 +123,51 @@ async def async_read_file_content(file: FileContent) -> HttpxFileContent:
return await anyio.Path(file).read_bytes()

return file


def deepcopy_with_paths(item: _T, paths: Sequence[Sequence[str]]) -> _T:
"""Copy only the containers along the given paths.

Used to guard against mutation by extract_files without copying the entire structure.
Only dicts and lists that lie on a path are copied; everything else
is returned by reference.

For example, given paths=[["foo", "files", "file"]] and the structure:
{
"foo": {
"bar": {"baz": {}},
"files": {"file": <content>}
}
}
The root dict, "foo", and "files" are copied (they lie on the path).
"bar" and "baz" are returned by reference (off the path).
"""
return _deepcopy_with_paths(item, paths, 0)


def _deepcopy_with_paths(item: _T, paths: Sequence[Sequence[str]], index: int) -> _T:
if not paths:
return item
if is_mapping(item):
key_to_paths: dict[str, list[Sequence[str]]] = {}
for path in paths:
if index < len(path):
key_to_paths.setdefault(path[index], []).append(path)

# if no path continues through this mapping, it won't be mutated and copying it is redundant
if not key_to_paths:
return item

result = dict(item)
for key, subpaths in key_to_paths.items():
if key in result:
result[key] = _deepcopy_with_paths(result[key], subpaths, index + 1)
return cast(_T, result)
if is_list(item):
array_paths = [path for path in paths if index < len(path) and path[index] == "<array>"]

# if no path expects a list here, nothing will be mutated inside it - return by reference
if not array_paths:
return cast(_T, item)
return cast(_T, [_deepcopy_with_paths(entry, array_paths, index + 1) for entry in item])
return item
Loading
Loading