Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(vision): tell the OpenRouter reasoning lane not to think, so it returns an answer

nirholas566b6c5e78ff
diff --git a/api/_lib/vision.js b/api/_lib/vision.js
index 6c3c96995..f611aa5b5 100644
--- a/api/_lib/vision.js
+++ b/api/_lib/vision.js
@@ -80,10 +80,27 @@ const NVIDIA_VISION_MODELS = [
// routes were saturated (429) in the same probe and are kept behind it as spare
// capacity: a 429 falls through in ~150 ms and, unlike the 410 that retired the
// NIM model above, it recovers when the shared free pool drains.
+//
+// The nemotron route is a REASONING model, and OpenRouter's own model record
+// says `default_enabled: true`, so left alone it thinks before it answers. In a
+// bulk text run that is merely expensive; inside a vision lane's slice of a
+// shared deadline it is fatal, because the thinking consumes the budget and the
+// lane returns an EMPTY message.content. Probing /api/vision on production
+// (2026-09-10) caught it doing exactly that: provider openrouter, model
+// nemotron-omni, text ''. The same record says `mandatory: false`, which is
+// OpenRouter's way of saying this model accepts being told not to, so the lane
+// carries reasoning.effort:'none'.
+//
+// Note the parameter is host-specific and copying the wrong one ships a no-op:
+// NVIDIA's own host takes chat_template_kwargs.enable_thinking (see
+// scripts/i18n-translate.mjs), OpenRouter takes reasoning.effort. Check a
+// model's `reasoning` object at https://openrouter.ai/api/v1/models before
+// assuming either works; a model with `mandatory: true` rejects 'none' with a
+// 400.
const OPENROUTER_VISION_MODELS = [
- 'nvidia/nemotron-3-nano-omni-30b-a3b-reasoning:free',
- 'google/gemma-4-31b-it:free',
- 'google/gemma-4-26b-a4b-it:free',
+ { model: 'nvidia/nemotron-3-nano-omni-30b-a3b-reasoning:free', extraBody: { reasoning: { effort: 'none' } } },
+ { model: 'google/gemma-4-31b-it:free' },
+ { model: 'google/gemma-4-26b-a4b-it:free' },
];
// Paid last-resort tail. gpt-5.4-nano is vision-capable and already priced in
// llm-pricing.js, keeping the backstop cheap and the spend ledger truthful.
@@ -222,7 +239,7 @@ export class VisionUnavailableError extends Error {
// the only shape difference from llm.js's text providers. `getHeaders` (async)
// replaces the static key header for keyless lanes whose auth is minted per
// request (the Vertex Gemini credits anchor).
-function openaiCompatVisionProvider({ name, key, url, model, getHeaders = null }) {
+function openaiCompatVisionProvider({ name, key, url, model, getHeaders = null, extraBody = null }) {
return {
name,
model,
@@ -234,7 +251,7 @@ function openaiCompatVisionProvider({ name, key, url, model, getHeaders = null }
const messages = [];
if (system) messages.push({ role: 'system', content: system });
messages.push({ role: 'user', content: parts });
- return { model, max_tokens: maxTokens, temperature: 0, messages };
+ return { model, max_tokens: maxTokens, temperature: 0, messages, ...(extraBody || {}) };
},
extractText: (r) => r.choices?.[0]?.message?.content || '',
extractUsage: (r) => ({ input: r.usage?.prompt_tokens ?? 0, output: r.usage?.completion_tokens ?? 0 }),
@@ -263,12 +280,13 @@ export function visionChain() {
// them here leaves the Vertex anchor exactly where it was in the chain
// relative to the paid tail; nothing is evicted.
if (env.OPENROUTER_API_KEY) {
- for (const model of OPENROUTER_VISION_MODELS) {
+ for (const spec of OPENROUTER_VISION_MODELS) {
chain.push(openaiCompatVisionProvider({
name: 'openrouter',
key: env.OPENROUTER_API_KEY,
url: 'https://openrouter.ai/api/v1/chat/completions',
- model,
+ model: spec.model,
+ extraBody: spec.extraBody || null,
}));
}
}
diff --git a/tests/vision-json-lane-failover.test.js b/tests/vision-json-lane-failover.test.js
index d8a888163..c3f9e92f2 100644
--- a/tests/vision-json-lane-failover.test.js
+++ b/tests/vision-json-lane-failover.test.js
@@ -107,3 +107,30 @@ describe('describeImageJson lane acceptance', () => {
expect(fetchSpy.mock.calls.length).toBeGreaterThan(1);
});
});
+
+describe('reasoning lanes are told not to think', () => {
+ it('sends reasoning.effort none only on the lane that needs it', async () => {
+ // OpenRouter's model record for the nemotron route says default_enabled:
+ // true and mandatory: false, so it reasons unless told otherwise and it
+ // accepts being told. Left on, the thinking eats the lane's slice of the
+ // deadline and message.content comes back empty (observed live).
+ // Fail the first rung so the walk actually reaches the OpenRouter lanes;
+ // asserting on a chain that stopped at lane 1 would pass vacuously.
+ fetchSpy
+ .mockResolvedValueOnce(reply('not json'))
+ .mockResolvedValue(reply(JSON.stringify(VERDICT)));
+ await call();
+
+ const bodies = fetchSpy.mock.calls.map(([, init]) => JSON.parse(init.body));
+ const nim = bodies.find((b) => String(b.model).includes('llama-3.2'));
+ const nemotron = bodies.find((b) => String(b.model).includes('nemotron'));
+
+ expect(bodies.length).toBeGreaterThan(1);
+ expect(nemotron).toBeDefined();
+ // Only the reasoning route carries it. The parameter is host-specific, so
+ // putting it on NVIDIA's own lane would be a silent no-op there.
+ expect(nemotron.reasoning).toEqual({ effort: 'none' });
+ expect(nim).toBeDefined();
+ expect(nim.reasoning).toBeUndefined();
+ });
+});