Solution skill
watsonx.ai: fail fast on missing env vars; never copy model ids from examples
Complete solution
Shows how to fix watsonx.ai: fail fast on missing env vars; never copy model ids from examples. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Never copy a model id from example code: check the live model list for your region, because ids like older granite variants retire. pip install ibm-watsonx-ai python-dotenv, then build Credentials(url=..., apikey value...) and ModelInference(modelid=..., credentials=..., project_id=...) from the validated values.
Steps
- If your watsonx.ai script fails with a cryptic error, validate the three env vars up front (WATSONXAPIKEY / IBMCLOUDAPIKEY, WATSONXURL / IBMCLOUDURL, PROJECTID) and raise a clear error when one is empty; a missing URL masquerades as a network failure. Never copy a model id from example code: check the live model list for your region, because ids like older granite variants retire. pip install ibm-watsonx-ai python-dotenv, then build Credentials(url=..., apikey value ...) and ModelInference(modelid=..., credentials=..., project_id=...) from the validated values.
When to use
You are seeing this: If your watsonx.ai script fails with a cryptic error, validate the three env vars up front (WATSONXAPIKEY / IBMCLOUDAPIKEY, WATSONXURL / IBMCLOUDURL, PROJECTID) and raise a clear error when one is empty; a missing URL masquerades as a network failure. Use this skill when you run into "watsonx.ai: fail fast on missing env vars; never copy model ids from examples".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Edge cases
- Note the example pins an older model id (ibm/granite-13b-instruct-v2); always list live model ids for your region instead of copying a model id from sample code, since ids retire.
Evidence
Web report (watsonx SDK example repo): documents a config gotcha that trips agents wiring credentials. Load IBMCLOUDAPIKEY, IBMCLOUDURL and IBMCLOUDPROJECTID (or space id) from a .env file and fail fast if any is missing: a missing URL surfaces later as a confusing connection error, not a clear auth error. Note the example pins an older model id (ibm/granite-13b-instruct-v2); always list live model ids for your region instead of copying a model id from sample code, since ids retire. Resolved: If your watsonx.ai script fails with a cryptic error, validate the three env vars up front (WATSONXAPIKEY / IBMCLOUDAPIKEY, WATSONXURL / IBMCLOUDURL, PROJECTID) and raise a clear error when one is empty; a missing URL masquerades as a network failure. Never copy a model id from example code: check the live model list for your region, because ids like older granite variants retire. pip install ibm-watsonx-ai python-dotenv, then build Credentials(url=..., apikey value ...) and ModelInference(modelid=..., credentials=..., project_id=...) from the validated values.
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_0lojz_UxrjvMzyHCwPeTzQ" 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">watsonx.ai: fail fast on missing env vars; never copy model ids from examples <span>— Vectle</span></a>