-
Notifications
You must be signed in to change notification settings - Fork 43
Description
Environment
- SDK: [openrouter SDK using openai.chat.completions.create()]
- API: https://openrouter.ai/api/v1/chat/completions
- Server: Node.js (backend)
- Auth: Bearer token via process.env.VALIDATE_OPEN_ROUTER_KEY
- Model: google/gemini-2.5-flash-lite-preview-06-17
- Status: Worked fine yesterday, broken today
Problem Summary
Both the SDK call and a manual fetch call to the OpenRouter endpoint are failing today, even though they were working perfectly yesterday.
Expected Behavior
Should return a valid JSON response from the model completion endpoint for a simple user prompt.
Steps to Reproduce
- SDK usage:
`const openai = new OpenAI({
baseURL: 'https://openrouter.ai/api/v1',
apiKey: process.env.VALIDATE_OPEN_ROUTER_KEY,
});
const messages = [{ role: 'user', content: 'Hello' }];
const model = 'google/gemini-2.5-flash-lite-preview-06-17';
const completion = await openai.chat.completions.create({ model, messages });`
Error Output:
❌ Chat failed: SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at parseJSONFromBytes ...
- Direct fetch call:
const response = await fetch('https://openrouter.ai/api/v1/chat/completions', { method: 'POST', headers: { Authorization:Bearer ${process.env.VALIDATE_OPEN_ROUTER_KEY}, 'Content-Type': 'application/json', }, body: JSON.stringify({ model: 'google/gemini-2.5-flash-lite-preview-06-17', messages: [{ role: 'user', content: 'Hello' }], }), });
Response status: 200 OK
But headers include:
{ "x-clerk-auth-message": "Invalid JWT form. A JWT consists of three parts separated by dots. (reason=token-invalid, token-carrier=header)" }