Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add Replicate api key?

i´m trying to use Replicate to run some neural networks in the cloud but it yields this error message:

ReplicateError: No API token provided. You need to set the REPLICATE_API_TOKEN environment variable or create a client with `replicate.Client(api_token=...)`.

You can find your API key on https://replicate.com

and python also can´t find it with the command

print(os.environ.get("REPLICATE_API_TOKEN"))

i already tried passing it using sysdm.cpl and it still doesnt work. How do I set it as an environmental variable?

like image 499
Omar Morales Rivera Avatar asked Apr 13 '26 21:04

Omar Morales Rivera


2 Answers

I was facing the same issue when trying to run Llama. Here is my solution:

os.environ["REPLICATE_API_TOKEN"] = "TOKEN"
api = replicate.Client(api_token=os.environ["REPLICATE_API_TOKEN"])
output = api.run(
    "meta/llama-2-70b-chat:02e509c789964a7ea8736978a43525956ef40397be9033abf9fd2badfe68c9e3",
        input={"prompt": prompt}
    )
for item in output:
    print(item, end="")
like image 166
Stephen Avatar answered Apr 16 '26 09:04

Stephen


Was also getting an auth issue. This is what worked - replicate = replicate.Client(api_token='')

like image 38
Neel Shah Avatar answered Apr 16 '26 10:04

Neel Shah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!