Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to set a custom token #370

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pip install replicate

Before running any Python scripts that use the API, you need to set your Replicate API token in your environment.

Grab your token from [replicate.com/account](https://replicate.com/account) and set it as an environment variable:
Grab your token from [replicate.com/account/api-tokens](https://replicate.com/account/api-tokens) and set it as an environment variable:

```
export REPLICATE_API_TOKEN=<your token>
Expand Down Expand Up @@ -360,6 +360,20 @@ training = replicate.trainings.create(
)
```


## Use a custom token

The `REPLICATE_API_TOKEN` environment variable is used by default. If you want to specify a different token, use the `Client` factory method to create a custom client:

```python
import os
from replicate.client import Client

replicate = Client(
api_token=os.environ["SOME_OTHER_REPLICATE_API_TOKEN"]
)
```

## Development

See [CONTRIBUTING.md](CONTRIBUTING.md)
Loading