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 .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 20
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/mixedbread%2Fmixedbread-3f27546e184f5e59dc9cd5d81108c5e19ea3a81d628db9da2b3613123afdd3ac.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/mixedbread%2Fmixedbread-c170defce134806965283050e465f10a479c7910a05f17f638f3a0080e47b4c9.yml
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,13 @@ from mixedbread import Mixedbread
client = Mixedbread(
# defaults to "production".
environment="local",
api_key="My API Key",
)

vector_store = client.vector_stores.create()
print(vector_store.id)
```

While you can provide an `api_key` keyword argument,
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
to add `MXBAI_API_KEY="My API Key"` to your `.env` file
so that your API Key is not stored in source control.

## Async usage

Simply import `AsyncMixedbread` instead of `Mixedbread` and use `await` with each API call:
Expand All @@ -54,6 +50,7 @@ from mixedbread import AsyncMixedbread
client = AsyncMixedbread(
# defaults to "production".
environment="local",
api_key="My API Key",
)


Expand Down Expand Up @@ -85,7 +82,9 @@ This library provides auto-paginating iterators with each list response, so you
```python
from mixedbread import Mixedbread

client = Mixedbread()
client = Mixedbread(
api_key="My API Key",
)

all_vector_stores = []
# Automatically fetches more pages as needed.
Expand All @@ -101,7 +100,9 @@ Or, asynchronously:
import asyncio
from mixedbread import AsyncMixedbread

client = AsyncMixedbread()
client = AsyncMixedbread(
api_key="My API Key",
)


async def main() -> None:
Expand Down Expand Up @@ -154,7 +155,9 @@ All errors inherit from `mixedbread.APIError`.
import mixedbread
from mixedbread import Mixedbread

client = Mixedbread()
client = Mixedbread(
api_key="My API Key",
)

try:
client.vector_stores.create()
Expand Down Expand Up @@ -197,6 +200,7 @@ from mixedbread import Mixedbread
client = Mixedbread(
# default is 2
max_retries=0,
api_key="My API Key",
)

# Or, configure per-request:
Expand All @@ -215,11 +219,13 @@ from mixedbread import Mixedbread
client = Mixedbread(
# 20 seconds (default is 1 minute)
timeout=20.0,
api_key="My API Key",
)

# More granular control:
client = Mixedbread(
timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),
api_key="My API Key",
)

# Override per-request:
Expand Down Expand Up @@ -263,7 +269,9 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
```py
from mixedbread import Mixedbread

client = Mixedbread()
client = Mixedbread(
api_key="My API Key",
)
response = client.vector_stores.with_raw_response.create()
print(response.headers.get('X-My-Header'))

Expand Down Expand Up @@ -345,6 +353,7 @@ client = Mixedbread(
proxy="http://my.test.proxy.example.com",
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
),
api_key="My API Key",
)
```

Expand All @@ -361,7 +370,9 @@ By default the library closes underlying HTTP connections whenever the client is
```py
from mixedbread import Mixedbread

with Mixedbread() as client:
with Mixedbread(
api_key="My API Key",
) as client:
# make requests here
...

Expand Down
12 changes: 0 additions & 12 deletions src/mixedbread/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,6 @@ def __init__(
def qs(self) -> Querystring:
return Querystring(array_format="comma")

@property
@override
def auth_headers(self) -> dict[str, str]:
api_key = self.api_key
return {"Authorization": api_key}

@property
@override
def default_headers(self) -> dict[str, str | Omit]:
Expand Down Expand Up @@ -389,12 +383,6 @@ def __init__(
def qs(self) -> Querystring:
return Querystring(array_format="comma")

@property
@override
def auth_headers(self) -> dict[str, str]:
api_key = self.api_key
return {"Authorization": api_key}

@property
@override
def default_headers(self) -> dict[str, str | Omit]:
Expand Down