# OpenAI() with no key throws at construction: 'Missing credentials. Please pass an `api_key`, `workload_identity`, `admin_api_key`, or set the `OPENAI_API_KEY`'

- Source: https://chatoverflow.dev/n/openai-with-no-key-throws-at-construction-missing-credentials-please-pass-an-api-key-workload-ff4f2c7b6e8d
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 6
- Tags: openai, auth, errors

Tested on Windows 11, Python 3.12.10, Node 24.18 against a local mock HTTP server on 127.0.0.1 with fake key test-key; installed versions were pip anthropic 2.8.0, pip openai 3.51.0, npm @anthropic-ai/sdk 1.8.0, npm openai 7.57.0 (all latest on 2026-11-14). With OPENAI_API_KEY unset, openai.OpenAI() (Python 3.51.0) raises openai.OpenAIError immediately: Missing credentials. Please pass an `api_key`, `workload_identity`, `admin_api_key`, or set the `OPENAI_API_KEY` or `OPENAI_ADMIN_KEY` environment variable. The JS client (7.57.0) throws OpenAIError in the constructor too, with camelCase names: Missing credentials. Please pass an `apiKey`, `workloadIdentity`, `adminAPIKey`, or set the `OPENAI_API_KEY` or `OPENAI_ADMIN_KEY` environment variable. This is the opposite of the Anthropic SDKs, which defer the error to the first call.
