Signing in with vilvik login
Use the device login flow to authenticate without managing API keys manually.
vilvik login is the quickest way to authenticate on your own machine. It opens a browser tab, walks you through approving access on Vilvik, and stores a key in ~/.config/vilvik/credentials. After that, vilvik.push(ga) and other SDK calls work with no api_key= argument and no VILVIK_API_KEY variable.
Run the login command¶
vilvik login
The CLI prints a short message and opens your default browser to a Vilvik approval page. Sign in to your Vilvik account if you are not already signed in, then press Approve. The browser tab closes (or you can close it yourself) and the CLI confirms:
Logged in. Credentials saved to ~/.config/vilvik/credentials.
The stored key is scoped to imports:write, which is everything vilvik.push(ga) needs.
Headless machines¶
On a server or container where there is no browser, pass --no-browser:
vilvik login --no-browser
The CLI prints a URL and a short code instead of opening a browser:
Open this URL in any browser:
https://vilvik.com/device/approve?user_code=ABCD-1234
Waiting for approval...
Go to that URL on any device, sign in, and approve. The CLI picks up the approval within a few seconds.
Using the credentials¶
Once login completes, the SDK reads the stored credentials automatically. You do not need to pass api_key= or set VILVIK_API_KEY:
import pygad
import vilvik
def fitness_func(ga_instance, solution, idx):
return -sum(s * s for s in solution)
ga = pygad.GA(
num_generations=100,
sol_per_pop=50,
num_genes=5,
num_parents_mating=4,
fitness_func=fitness_func,
)
ga.run()
record = vilvik.push(ga) # no api_key= needed
print(record.result_url)
If you have both stored credentials and VILVIK_API_KEY set, the environment variable wins.
Key management¶
The key saved by vilvik login appears in your API keys page like any other key. You can revoke it from there if you no longer need it, or if you want to force a fresh login. See Creating and managing API keys.
The manual alternative¶
If you prefer not to use the login flow, create a key in the dashboard and supply it as an environment variable:
export VILVIK_API_KEY=vlk_live_...
Or pass it directly:
record = vilvik.push(ga, api_key="vlk_live_...")
Both approaches give you the same result. The login flow is more convenient on a personal machine; the environment variable is better suited to automation and CI.