Skip to content

Commit 8cebafd

Browse files
Updated docs to include authentication features
1 parent 77c3a95 commit 8cebafd

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

README.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ composer require codewithkyrian/chromadb-php
136136
```php
137137
use Codewithkyrian\ChromaDB\ChromaDB;
138138

139-
$chromaDB = ChromaDB::client();
139+
$chroma = ChromaDB::client();
140140

141141
```
142142

@@ -147,7 +147,7 @@ factory method:
147147
```php
148148
use Codewithkyrian\ChromaDB\ChromaDB;
149149

150-
$chromaDB = ChromaDB::factory()
150+
$chroma = ChromaDB::factory()
151151
->withHost('http://localhost')
152152
->withPort(8000)
153153
->withDatabase('new_database')
@@ -157,6 +157,47 @@ $chromaDB = ChromaDB::factory()
157157

158158
If the tenant or database doesn't exist, the package will automatically create them for you.
159159

160+
### Authentication
161+
162+
ChromaDB supports static token-based authentication. To use it, you need to start the Chroma server passing the required
163+
environment variables as stated in the documentation. If you're using the docker image, you can pass in the environment
164+
variables using the `--env` flag or by using a `.env` file and for the docker-compose file, you can use the `env_file`
165+
option, or pass in the environment variables directly like so:
166+
167+
```yaml
168+
version: '3.9'
169+
170+
services:
171+
chroma:
172+
image: 'chromadb/chroma'
173+
ports:
174+
- '8000:8000'
175+
environment:
176+
- CHROMA_SERVER_AUTH_CREDENTIALS=test-token
177+
- CHROMA_SERVER_AUTH_CREDENTIALS_PROVIDER=chromadb.auth.token.TokenConfigServerAuthCredentialsProvider
178+
- CHROMA_SERVER_AUTH_PROVIDER=chromadb.auth.token.TokenAuthServerProvider
179+
180+
...
181+
```
182+
183+
You can then connect to ChromaDB using the factory method:
184+
185+
```php
186+
use Codewithkyrian\ChromaDB\ChromaDB;
187+
188+
$chroma = ChromaDB::factory()
189+
->withAuthToken('test-token')
190+
->connect();
191+
```
192+
193+
### Getting the version
194+
195+
```php
196+
197+
echo $chroma->version(); // 0.4.0
198+
199+
```
200+
160201
### Creating a Collection
161202

162203
Creating a collection is as simple as calling the `createCollection` method on the client and passing in the name of

0 commit comments

Comments
 (0)