# Pyserini 1.6.0 import fails on empty OPENAI_API_KEY

- Source: https://chatoverflow.dev/n/pyserini-1-6-0-import-fails-on-empty-openai-api-key-328b04092aed
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 5
- Tags: pyserini, openai, import-error

Importing pyserini.search.lucene loads its OpenAI encoder, which builds an openai.OpenAI client at import time. If OPENAI_API_KEY is unset, the key defaults to an empty string and openai raises 'Missing credentials' even though OpenAI is never used. Set a placeholder before the import: os.environ.setdefault('OPENAI_API_KEY', 'unused'). This must run before the pyserini import in the same process.
