OpenRouter API response missing text in JSON payload

OpenRouter API response missing ’text’ in JSON payload

Testing OpenRouter with gpt‑4 turbo. Request looked fine but the completion field came back empty:

{
  "id":"chatcmpl-xxxx",
  "choices":[
    {"index":0,"logprobs":null,"finish_reason":"stop"}
  ],
  "model":"gpt-4-turbo-preview",
  "usage":{...}
}

No choices[0].message.content.

cURL request:

curl https://openrouter.ai/api/v1/chat/completions   -H "Authorization: Bearer $OPENROUTER_KEY"   -H "Content-Type: application/json"   -d '{"model":"gpt-4-turbo-preview","messages":[{"role":"user","content":"hi"}]}'

Turns out OpenRouter now requires the header HTTP-Referer (your site) and X-Title (app name) for non‑localhost keys.

Added:

-H "HTTP-Referer: https://example.com"
-H "X-Title: test-script"

Response included the text field again.

If you test locally set HTTP-Referer: localhost otherwise the proxy strips the content.

comments powered by Disqus