SIGN IN SIGN UP

[ENH] Auto-set tenant, scoped database in python CloudClient (#5026)

## Description of changes

This PR updates the python CloudClient to auto-set tenant based on the
API key.

to use the cloud client now with an api key scoped to a single db
```
client = chromadb.CloudClient(
    api_key="ck-xxxxxxxxx"
)
```

and with an api key scoped to multiple dbs
```
client = chromadb.CloudClient(
    database="right-db",
    api_key="ck-xxxxxxxxx"
)
```

edge cases:
scoped api key to 1 db:

```
# this works
client = chromadb.CloudClient(
    api_key="xxxxx"
)

# this works
client = chromadb.CloudClient(
    tenant="right-tenant",
    api_key="xxxxx"
)

# error returns: chromadb.errors.ChromaAuthError: Tenant wrong-tenant does not match e9de4745-55e2-4281-ac7c-5672498abff6 from the server. Are you sure the tenant is correct?
client = chromadb.CloudClient(
    tenant="wrong-tenant",
    api_key="xxxxx"
)


# error returns: chromadb.errors.ChromaAuthError: Database wrong-db does not match right-db from the server. Are you sure the database is correct?
client = chromadb.CloudClient(
    database="wrong-db",
    api_key="xxxxx"
)

# error returns: chromadb.errors.ChromaError: Permission denied.
client = chromadb.CloudClient(
    database="right-db",
    api_key="wrong-api-key"
)

```

scoped api key to multiple dbs
```
# error returns: chromadb.errors.ChromaAuthError: Tenant wrong-tenant does not match e9de4745-55e2-4281-ac7c-5672498abff6 from the server. Are you sure the tenant is correct?
client = chromadb.CloudClient(
    tenant="wrong-tenant",
    database="right-db",
    api_key="xxxxx"
)

# this works
client = chromadb.CloudClient(
    tenant="right-tenant",
    database="right-db",
    api_key="xxxxx"
)

# error returns: chromadb.errors.NotFoundError: Database [wrong-db] not found. Are you sure it exists?
client = chromadb.CloudClient(
    database="wrong-db",
    api_key="xxxxx"
)

# error returns: chromadb.errors.ChromaAuthError: Could not determine a database name from the current authentication method. Please provide a database name.
client = chromadb.CloudClient(
    api_key="xxxxx"
)
```

## Test plan

_How are these changes tested?_

Manually tested both clients, and all corresponding APIs for both
CloudClient (collection apis, add/delete records), and AdminClient
(get_tenant & list/get_database, confirm create_tenant and
create_database are disabled)

- [ ] Tests pass locally with `pytest` for python, `yarn test` for js,
`cargo test` for rust

## Documentation Changes

_Are all docstrings for user-facing APIs updated if required? Do we need
to make documentation changes in the [docs
section](https://github.com/chroma-core/chroma/tree/main/docs/docs.trychroma.com)?_

---------

Co-authored-by: Hammad Bashir <HammadB@users.noreply.github.com>
Co-authored-by: propel-code-bot[bot] <203372662+propel-code-bot[bot]@users.noreply.github.com>
J
Jai Radhakrishnan committed
bbfdc1629e0ad7885e5dd4f1627c8d9a00edb33a
Parent: 6f95f37
Committed by GitHub <noreply@github.com> on 8/13/2025, 6:42:54 PM