It seems the API endpoint fails to process the host
header correctly.
Start an HTTPS request using the following command:
openssl s_client -connect generativelanguage.googleapis.com:443
Working Request:
Paste the following as input:
POST /v1beta/openai/chat/completions HTTP/1.1
Host: generativelanguage.googleapis.com
Authorization: Bearer API_KEY
Content-Type: application/json
Content-Length: 75
{"messages":[{"content":"Hello","role":"user"}],"model":"gemini-2.0-flash"}
Non-Working Request:
Paste the following as input:
POST /v1beta/openai/chat/completions HTTP/1.1
host: generativelanguage.googleapis.com
Authorization: Bearer API_KEY
Content-Type: application/json
Content-Length: 75
{"messages":[{"content":"Hello","role":"user"}],"model":"gemini-2.0-flash"}
It appears that the API endpoint is case-sensitive when processing the Host
header, rejecting lowercase variants.