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
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.19.0"
".": "0.20.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: 49
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/mixedbread%2Fmixedbread-d45a3a3119fa9a3db2a6cae3c6d376f99fb874ed359c369d9b9531fdea55dcec.yml
openapi_spec_hash: aedb38c67ac4c4b9ee79d130ddeb583a
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/mixedbread%2Fmixedbread-e8f008047e9aa7f8824bbf5c8b3f338ce1f79b4c81f2637a5e4be1530ff45c9f.yml
openapi_spec_hash: 27f45c14fedc15710f730e037f0694cf
config_hash: 810d9712d3d0d6a1f50d71a25511d8a7
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

## 0.20.0 (2025-07-22)

Full Changelog: [v0.19.0...v0.20.0](https://github.com/mixedbread-ai/mixedbread-python/compare/v0.19.0...v0.20.0)

### Features

* **api:** api update ([b49a79c](https://github.com/mixedbread-ai/mixedbread-python/commit/b49a79cf86930dae1e2f5b2732f7c78fb23d6248))
* clean up environment call outs ([d0c1c5e](https://github.com/mixedbread-ai/mixedbread-python/commit/d0c1c5e3a871ec7f89a4ec1d0d29e4b4ba97f6e8))


### Bug Fixes

* **parsing:** ignore empty metadata ([697e64e](https://github.com/mixedbread-ai/mixedbread-python/commit/697e64e4276c78d19075393ce2d605c401c9026a))


### Chores

* **internal:** codegen related update ([b14dd64](https://github.com/mixedbread-ai/mixedbread-python/commit/b14dd6477262cb4611eca7d5a67aaad8f3694088))
* **types:** rebuild Pydantic models after all types are defined ([1a5b6a5](https://github.com/mixedbread-ai/mixedbread-python/commit/1a5b6a5fd8b9aada359878cdffbb71e6bd888a5d))

## 0.19.0 (2025-07-17)

Full Changelog: [v0.18.0...v0.19.0](https://github.com/mixedbread-ai/mixedbread-python/compare/v0.18.0...v0.19.0)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Mixedbread API Python SDK API library

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

The Mixedbread API Python SDK library provides convenient access to the Mixedbread REST API from any Python 3.8+
application. The library includes type definitions for all request params and response fields,
Expand Down Expand Up @@ -82,15 +83,14 @@ pip install mixedbread[aiohttp]
Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:

```python
import os
import asyncio
from mixedbread import DefaultAioHttpClient
from mixedbread import AsyncMixedbread


async def main() -> None:
async with AsyncMixedbread(
api_key=os.environ.get("MXBAI_API_KEY"), # This is the default and can be omitted
api_key="My API Key",
http_client=DefaultAioHttpClient(),
) as client:
vector_store = await client.vector_stores.create()
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "mixedbread"
version = "0.19.0"
version = "0.20.0"
description = "The official Python library for the Mixedbread 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 All @@ -38,7 +39,7 @@ Homepage = "https://github.com/mixedbread-ai/mixedbread-python"
Repository = "https://github.com/mixedbread-ai/mixedbread-python"

[project.optional-dependencies]
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.6"]
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.8"]

[tool.rye]
managed = true
Expand Down
4 changes: 2 additions & 2 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ 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 httpx-aiohttp
Expand Down
4 changes: 2 additions & 2 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ 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 httpx-aiohttp
Expand Down
11 changes: 9 additions & 2 deletions src/mixedbread/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,15 @@ def _build_request(
# work around https://github.com/encode/httpx/discussions/2880
kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")}

is_body_allowed = options.method.lower() != "get"

if is_body_allowed:
kwargs["json"] = json_data if is_given(json_data) else None
kwargs["files"] = files
else:
headers.pop("Content-Type", None)
kwargs.pop("data", None)

# TODO: report this error to httpx
return self._client.build_request( # pyright: ignore[reportUnknownMemberType]
headers=headers,
Expand All @@ -540,8 +549,6 @@ def _build_request(
# so that passing a `TypedDict` doesn't cause an error.
# https://github.com/microsoft/pyright/issues/3526#event-6715453066
params=self.qs.stringify(cast(Mapping[str, Any], params)) if params else None,
json=json_data if is_given(json_data) else None,
files=files,
**kwargs,
)

Expand Down
13 changes: 8 additions & 5 deletions src/mixedbread/_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 and len(metadata) > 0:
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/mixedbread/_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__ = "mixedbread"
__version__ = "0.19.0" # x-release-please-version
__version__ = "0.20.0" # x-release-please-version
35 changes: 14 additions & 21 deletions src/mixedbread/resources/data_sources/data_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@
from __future__ import annotations

from typing import Optional
from typing_extensions import overload
from typing_extensions import Literal, overload

import httpx

from ...types import (
Oauth2Params,
DataSourceType,
data_source_list_params,
data_source_create_params,
data_source_update_params,
)
from ...types import Oauth2Params, data_source_list_params, data_source_create_params, data_source_update_params
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ..._utils import required_args, maybe_transform, async_maybe_transform
from ..._compat import cached_property
Expand All @@ -36,7 +30,6 @@
from ..._base_client import AsyncPaginator, make_request_options
from ...types.data_source import DataSource
from ...types.oauth2_params import Oauth2Params
from ...types.data_source_type import DataSourceType
from ...types.data_source_delete_response import DataSourceDeleteResponse

__all__ = ["DataSourcesResource", "AsyncDataSourcesResource"]
Expand Down Expand Up @@ -70,7 +63,7 @@ def with_streaming_response(self) -> DataSourcesResourceWithStreamingResponse:
def create(
self,
*,
type: DataSourceType | NotGiven = NOT_GIVEN,
type: Literal["notion"] | NotGiven = NOT_GIVEN,
name: str,
metadata: object | NotGiven = NOT_GIVEN,
auth_params: Optional[data_source_create_params.NotionDataSourceAuthParams] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -112,7 +105,7 @@ def create(
def create(
self,
*,
type: DataSourceType | NotGiven = NOT_GIVEN,
type: Literal["linear"] | NotGiven = NOT_GIVEN,
name: str,
metadata: object | NotGiven = NOT_GIVEN,
auth_params: Optional[Oauth2Params] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -153,7 +146,7 @@ def create(
def create(
self,
*,
type: DataSourceType | NotGiven = NOT_GIVEN,
type: Literal["notion"] | Literal["linear"] | NotGiven = NOT_GIVEN,
name: str,
metadata: object | NotGiven = NOT_GIVEN,
auth_params: Optional[data_source_create_params.NotionDataSourceAuthParams]
Expand Down Expand Up @@ -227,7 +220,7 @@ def update(
self,
data_source_id: str,
*,
type: DataSourceType | NotGiven = NOT_GIVEN,
type: Literal["notion"] | NotGiven = NOT_GIVEN,
name: str,
metadata: object | NotGiven = NOT_GIVEN,
auth_params: Optional[data_source_update_params.NotionDataSourceAuthParams] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -274,7 +267,7 @@ def update(
self,
data_source_id: str,
*,
type: DataSourceType | NotGiven = NOT_GIVEN,
type: Literal["linear"] | NotGiven = NOT_GIVEN,
name: str,
metadata: object | NotGiven = NOT_GIVEN,
auth_params: Optional[Oauth2Params] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -320,7 +313,7 @@ def update(
self,
data_source_id: str,
*,
type: DataSourceType | NotGiven = NOT_GIVEN,
type: Literal["notion"] | Literal["linear"] | NotGiven = NOT_GIVEN,
name: str,
metadata: object | NotGiven = NOT_GIVEN,
auth_params: Optional[data_source_update_params.NotionDataSourceAuthParams]
Expand Down Expand Up @@ -477,7 +470,7 @@ def with_streaming_response(self) -> AsyncDataSourcesResourceWithStreamingRespon
async def create(
self,
*,
type: DataSourceType | NotGiven = NOT_GIVEN,
type: Literal["notion"] | NotGiven = NOT_GIVEN,
name: str,
metadata: object | NotGiven = NOT_GIVEN,
auth_params: Optional[data_source_create_params.NotionDataSourceAuthParams] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -519,7 +512,7 @@ async def create(
async def create(
self,
*,
type: DataSourceType | NotGiven = NOT_GIVEN,
type: Literal["linear"] | NotGiven = NOT_GIVEN,
name: str,
metadata: object | NotGiven = NOT_GIVEN,
auth_params: Optional[Oauth2Params] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -560,7 +553,7 @@ async def create(
async def create(
self,
*,
type: DataSourceType | NotGiven = NOT_GIVEN,
type: Literal["notion"] | Literal["linear"] | NotGiven = NOT_GIVEN,
name: str,
metadata: object | NotGiven = NOT_GIVEN,
auth_params: Optional[data_source_create_params.NotionDataSourceAuthParams]
Expand Down Expand Up @@ -634,7 +627,7 @@ async def update(
self,
data_source_id: str,
*,
type: DataSourceType | NotGiven = NOT_GIVEN,
type: Literal["notion"] | NotGiven = NOT_GIVEN,
name: str,
metadata: object | NotGiven = NOT_GIVEN,
auth_params: Optional[data_source_update_params.NotionDataSourceAuthParams] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -681,7 +674,7 @@ async def update(
self,
data_source_id: str,
*,
type: DataSourceType | NotGiven = NOT_GIVEN,
type: Literal["linear"] | NotGiven = NOT_GIVEN,
name: str,
metadata: object | NotGiven = NOT_GIVEN,
auth_params: Optional[Oauth2Params] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -727,7 +720,7 @@ async def update(
self,
data_source_id: str,
*,
type: DataSourceType | NotGiven = NOT_GIVEN,
type: Literal["notion"] | Literal["linear"] | NotGiven = NOT_GIVEN,
name: str,
metadata: object | NotGiven = NOT_GIVEN,
auth_params: Optional[data_source_update_params.NotionDataSourceAuthParams]
Expand Down
11 changes: 11 additions & 0 deletions src/mixedbread/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from __future__ import annotations

from . import shared
from .. import _compat
from .shared import Usage as Usage, SearchFilter as SearchFilter, SearchFilterCondition as SearchFilterCondition
from .api_key import APIKey as APIKey
from .embedding import Embedding as Embedding
Expand Down Expand Up @@ -56,3 +58,12 @@
from .vector_store_question_answering_response import (
VectorStoreQuestionAnsweringResponse as VectorStoreQuestionAnsweringResponse,
)

# Rebuild cyclical models only after all modules are imported.
# This ensures that, when building the deferred (due to cyclical references) model schema,
# Pydantic can resolve the necessary references.
# See: https://github.com/pydantic/pydantic/issues/11250 for more context.
if _compat.PYDANTIC_V2:
shared.search_filter.SearchFilter.model_rebuild(_parent_namespace_depth=0)
else:
shared.search_filter.SearchFilter.update_forward_refs() # type: ignore
5 changes: 2 additions & 3 deletions src/mixedbread/types/data_source_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from typing_extensions import Literal, Required, TypeAlias, TypedDict

from .oauth2_params import Oauth2Params
from .data_source_type import DataSourceType

__all__ = [
"DataSourceCreateParams",
Expand All @@ -18,7 +17,7 @@


class NotionDataSource(TypedDict, total=False):
type: DataSourceType
type: Literal["notion"]
"""The type of data source to create"""

name: Required[str]
Expand All @@ -45,7 +44,7 @@ class NotionDataSourceAuthParamsAPIKeyCreateOrUpdateParams(TypedDict, total=Fals


class LinearDataSource(TypedDict, total=False):
type: DataSourceType
type: Literal["linear"]
"""The type of data source to create"""

name: Required[str]
Expand Down
5 changes: 2 additions & 3 deletions src/mixedbread/types/data_source_update_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from typing_extensions import Literal, Required, TypeAlias, TypedDict

from .oauth2_params import Oauth2Params
from .data_source_type import DataSourceType

__all__ = [
"DataSourceUpdateParams",
Expand All @@ -18,7 +17,7 @@


class NotionDataSource(TypedDict, total=False):
type: DataSourceType
type: Literal["notion"]
"""The type of data source to create"""

name: Required[str]
Expand All @@ -45,7 +44,7 @@ class NotionDataSourceAuthParamsAPIKeyCreateOrUpdateParams(TypedDict, total=Fals


class LinearDataSource(TypedDict, total=False):
type: DataSourceType
type: Literal["linear"]
"""The type of data source to create"""

name: Required[str]
Expand Down
Loading