Skip to content

import replicate expects REPLICATE_API_TOKEN to already be set in env #4

Description

@zeke

This doesn't work:

import replicate
from dotenv import load_dotenv

load_dotenv()

Because import replicate must be expecting the env var to already exist:

requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.replicate.com/v1/models/yuanxunlu/livespeechportraits/versions

This works:

from dotenv import load_dotenv
load_dotenv()
import replicate

In order to support .env-file based development workflows, we should update the client to read the token when the client is being exercised, instead of at load time, so the order of import statements won't matter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions