Closed zeke closed 12 months ago
I agree that the latter makes for better-looking sample code. But the implicit auth behavior in the Python client is among the most frequent points of confusion / friction from users. I think the Python koan of "Explicit is better than implicit" applies.
Not to say that we can't do better here!
What do you think about something like what we did in the Go client? Do you know of any good examples / conventions for JS client constructors that read from env like that?
the implicit auth behavior in the Python client is among the most frequent points of confusion / friction from users.
What makes it a point of friction? Is it because the client blows up weirdly if the token is missing? Or because you're forced to do auth that way?
I think what's different about what I'm proposing here is that you have the option: set the auth
option explicitly, or implicitly fall back to the env var.
What do you think about something like what we did in the Go client?
client := replicate.NewClient(replicate.WithTokenFromEnv())
That could work, but might feel a bit unfamiliar. I can't recall ever seeing a pattern like that in JS land for loading from env.
@zeke You know, I'm starting to come around to this. Opened https://github.com/replicate/replicate-javascript/pull/127 with the change.
To use the client today, you have to do this:
What if you could just do:
..and have it default to
process.env.REPLICATE_API_TOKEN
, if present?This is similar to how the Python client works, and I kinda like it. Also makes code examples a lot cleaner.