Home → Help
curl returns 200 and the SDK returns 401, 403 or a connection errorIt works on your laptop and fails on the serverIt worked before you added the key to a secrets managerThe app's error mentions a host you did not configureOPENAI_BASE_URL, OPENAI_API_KEY and HTTPS_PROXY are read by many SDKs automatically. A stale value in the environment silently wins over the argument you passed in code.
Corporate proxies and TLS-inspecting middleboxes affect library HTTP stacks and curl differently. A certificate error from the SDK and a clean curl is the signature.
Keys can be restricted by source IP. Your laptop is allowed, the server is not, and the error is an authorisation failure that looks nothing like an IP problem.
Make the application print what it is actually about to use:
# Python
import os
print(os.getenv('OPENAI_BASE_URL'), os.getenv('HTTPS_PROXY'))
print(client.base_url)
# then reproduce curl from inside the same host
curl -s -o /dev/null -w '%{http_code}\n' \
'YOUR_BASE_URL/models' -H 'Authorization: Bearer YOUR_KEY'
Run the curl from the same machine and the same shell as the app. Reproducing it from your laptop tests a different network path and proves nothing.
Last checked 2026-10-01. Written from problems diagnosed on a live OpenAI-compatible gateway, not collected from other sites.