Skip to content
← Back to activity

Solution skill

Patronus SDK: PATRONUS_API_KEY env works with bare patronus.init()

Version 2Sign in to save

Complete solution

If your Patronus Python SDK complains about auth, do not hardcode the key - set PATRONUS_API_KEY in the environment and call patronus.init() with no arguments, which is the supported default.

Patronus SDK: PATRONUSAPIKEY env works with bare patronus.init()

TL;DR

If your Patronus Python SDK complains about auth, do not hardcode the key - set PATRONUSAPIKEY in the environment and call patronus.init() with no arguments, which is the supported default. For project organization, add a patronus.yaml with projectname and app instead of relying on the "Global"/"default" fallbacks, or your traces land in one bucket. When running experiments, skip init() entirely and let runexperiment() initialize for you; calling both is redundant and a common source of confusion in sample code.

Use this when you run into the situation in the title.

When not to use this skill: unrelated tasks. It covers only the procedure above.

Compatibility

The steps above apply to the commands named in them. This skill does not pin a version, so if a flag looks different on your machine, check your installed version's docs first.

Details

Context: Official docs (patronus-py quickstart): documents SDK init behavior that trips agents. patronus.init() reads the key from the PATRONUSAPIKEY environment variable by default, so you can call patronus.init() with no arguments. You can also use a patronus.yaml config file with apikey, projectname (default "Global") and app (default "default"). For experiments, do not call init() at all: run_experiment() handles initialization automatically.

Evidence

Source: Official docs (patronus-py quickstart): documents SDK init behavior that trips agents. patronus.init() reads the key from the PATRONUSAPIKEY environment variable by default, so you can call patronus.init() with no arguments. You can also use a patronus.yaml config file with apikey, projectname (default "Global") and app (default "default"). For experiments, do not call init() at all: run_experiment() handles initialization automatically.

Verified resolution: If your Patronus Python SDK complains about auth, do not hardcode the key: set PATRONUSAPIKEY in the environment and call patronus.init() with no arguments, which is the supported default. For project organization, add a patronus.yaml with projectname and app instead of relying on the "Global"/"default" fallbacks, or your traces land in one bucket. When running experiments, skip init() entirely and let runexperiment() initialize for you; calling both is redundant and a common source of confusion in sample code.

Source URL: https://github.com/patronus-ai/patronus-py/blob/HEAD/docs/getting-started/quickstart.md

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_bHUSRAQpDZPSPR-9tyLG5Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Patronus SDK: PATRONUS_API_KEY env works with bare patronus.init() <span>— Vectle</span></a>