Skip to content

Gemini models require OpenRouter reasoning details to be preserved in each request. #120

@zayr0-9

Description

@zayr0-9

I am sending the following payload to the chat.send() function, but in gemini 3 models I end up getting 400 error where it has some issue with how the reasoning details are being included. Does anyone have any idea on how my inclusion of reasoningDetails incorrect?
I am on openrouter/sdk: 0.3.10

Full messages payload:

  {
    "role": "system",
    "content": "test"
  },
  {
    "role": "user",
    "content": "search online for new bleach news"
  },
  {
    "role": "assistant",
    "content": null,
    "toolCalls": [
      {
        "id": "tool_brave_search_U2ZJEE46KT9PuS0ZAsbt",
        "type": "function",
        "function": {
          "name": "brave_search",
          "arguments": "{\"offset\":0,\"extra_snippets\":true,\"search_lang\":\"en\",\"country\":\"us\",\"count\":10,\"summary\":true,\"query\":\"latest bleach anime manga news May 2024 Thousand-Year Blood War Part 3 release date\",\"safesearch\":\"moderate\"}"
        }
      }
    ],
    "reasoningDetails": [
      {
        "type": "reasoning.encrypted",
        "data": "CiIBjz1rX6JFJeOzncCWE77fuzv4qy/VO75KdXfoG0hh4qiiCnIBjz1rX6JbdjtlPWt4oJU6vFQWk8TNE42Iol0da9Naig/1h/h7iXA7DzMYL59nbrxvWR722/xHs9O1r4e9EO9VA3W1Pkx+WPGNVYfuTZq8bo9o0Bxo2YXU7A4qXDNa8+uvTWSIurOO1IDF1tR6LnS2IO4KPgGPPWtfkF9GxkkL/RNhhpOrbeO6wODyCHDFphyEWGcVhaGeWT608zUSW6Ez8dwQR14e/wA5OebLxsAijvKaCqQBAY89a1+86+3SKhPYeK0X6/z+RsTPRpmXZq77gvqKF3b5G1fXb3vsGTM3Pyx7jnX/mGYjAZmRQgFhEIjKzU3l+9785D9TpuigsgWe/uRJQ9oFSEKa5Urok/Aqrc/x7rE1Labd7x/IccbKA241uYxZ+2EnqG9T+Tguh74ohEhZbQa8X/jmBfrbwY5ph6r4rnmnsGTb3rrjKLD+2UoT5uDgmASPcQYKtgEBjz1rXxaDfZ3kTgiwJbsI0dGl+pZXZSwJiPvFwpz3hXpjYEoavcblxlT92Kp/+ScmiJiqlAtzqxH6ZfylVFJeu9OwOC7onDDTnPLs9hP13gxJCmrObJMmIaptp3XA4iXS4I0FIpS8//zs8z6LxZVALLRAOmpXIXJOi4Msqp7nqlHfCBXtagEfc0ZB/INR2ge0juusVtz9lY2Q/rkk9EEvKfi4mgMudhj/RWVs1hXne8aWyNZ9WQomAY89a1/ZHntvFYssi2BP2NzZtQcvnY69zt6CRlKP7yTOc9W8iqY=",
        "id": "tool_brave_search_U2ZJEE46KT9PuS0ZAsbt",
        "format": "google-gemini-v1",
        "index": 0
      }
    ]
  },
  {
    "role": "tool",
    "content": "{\"success\":true,\"results\":[{\"title\":\"Bleach: Thousand-Year Blood War Part 3 Release Window: Everything We Know About the Anime's Return\",\"url\":\"https://screenrant.com/bleach-thousand-year-blood-war-part-3-announced-release/\",\"description\":\"While this one didn&#x27;t feature much in the way of new information, it did allay any fears that the international debut would be delayed by emphasizing the <strong>October 5, 2024</strong>, release date.\",\"age\":\"September 25, 2024\",\"language\":\"en\"},{\"title\":\"Bleach: Thousand-Year Blood War part 3 release date, story recap, trailer, and everything we know about The Conflict | GamesRadar+\",\"url\":\"https://www.gamesradar.com/entertainment/anime-shows/bleach-thousand-year-blood-war-part-3-release-date-trailer-cast-story-the-conflict/\",\"description\":\"For more from the wide world of anime, check out our guides to Jujutsu Kaisen season 3, Demon Slayer Infinity Castle, and One-Punch Man season 3. ... Bleach: Thousand-Year Blood War part 3 premiered on <strong>October 5, 2024</strong>.\",\"age\":\"October 16, 2024\",\"language\":\"en\"},{\"title\":\"Bleach: Thousand-Year Blood War Part 3 release date, cast, plot and everything you need to know\",\"url\":\"https://www.digitalspy.com/tv/a45335209/bleach-thousand-year-blood-war-part-3/\",\"description\":\"Bleach: Thousand-Year Blood War ended its second cour in <strong>September 2023</strong> - here&#x27;s what we know about part 3&#x27;s release date, plot and manga spoilers.\",\"age\":\"July 8, 2024\",\"language\":\"en\"},{\"title\":\"Bleach: Thousand-Year Blood War Part 3 - The Conflict's Promo Video Reveals 2024 Release - News - Anime News Network\",\"url\":\"https://www.animenewsnetwork.com/news/2023-09-30/bleach-thousand-year-blood-war-part-3-the-conflict-promo-video-reveals-2024-release/.203015\",\"description\":\"Part 2 of anime aired in July // Viz Media unveiled a promotional video, a new key visual, and the 2024 release date for Bleach: Thousand-Year Blood War Part...\",\"language\":\"en\"},{\"title\":\"Bleach: Thousand-Year Blood War - Wikipedia\",\"url\":\"https://en.wikipedia.org/wiki/Bleach:_Thousand-Year_Blood_War\",\"description\":\"The second cours, subtitled The ... The Conflict (相剋譚, Sōkoku-tan), consisting of 14 episodes, aired from <strong>October to December 2024</strong>....\",\"age\":\"1 week ago\",\"language\":\"en\"},{\"title\":\"Bleach: Thousand Year Blood War season 3 release schedule | When are new episodes out? | Radio Times\",\"url\":\"https://www.radiotimes.com/tv/fantasy/anime/bleach-thousand-year-blood-war-season-3-release-schedule/\",\"description\":\"Bleach: Thousand Year Blood War Part 3 episode 4 - The Betrayer - <strong>Saturday 26th October 2024</strong>\",\"age\":\"November 15, 2024\",\"language\":\"en\"},{\"title\":\"Bleach: Thousand-Year Blood War Part 3 - The Conflict Reveals New Promo Video; Bleach Manga Gets New Rock Musical Adaptation in 2024 - News - Anime News Network\",\"url\":\"https://www.animenewsnetwork.com/news/2023-12-16/bleach-thousand-year-blood-war-part-3-the-conflict-reveals-new-promo-video-bleach-manga-gets-new-/.205597\",\"description\":\"The event also announced a new ... years after its last rock musical adaptation. ... <strong>The Bleach: Thousand-Ye
provider error ChatError: Provider returned error
    at Object.transform (file:///home/karn/webbdrasil/Webdrasil/ygg-chat/server/node_modules/@openrouter/sdk/esm/models/errors/chaterror.js:26:12)
    at Object.inst._zod.parse (file:///home/karn/webbdrasil/Webdrasil/ygg-chat/node_modules/zod/v4/classic/schemas.js:760:28)
    at handlePipeResult (file:///home/karn/webbdrasil/Webdrasil/ygg-chat/node_modules/zod/v4/core/schemas.js:1601:25)
    at Object.inst._zod.parse (file:///home/karn/webbdrasil/Webdrasil/ygg-chat/node_modules/zod/v4/core/schemas.js:1594:16)
    at Module.<anonymous> (file:///home/karn/webbdrasil/Webdrasil/ygg-chat/node_modules/zod/v4/core/parse.js:6:32)
    at _.inst.parse (file:///home/karn/webbdrasil/Webdrasil/ygg-chat/node_modules/zod/v4/classic/schemas.js:29:42)
    at safeParseResponse.request.request (file:///home/karn/webbdrasil/Webdrasil/ygg-chat/server/node_modules/@openrouter/sdk/esm/lib/matchers.js:168:74)
    at safeParseResponse (file:///home/karn/webbdrasil/Webdrasil/ygg-chat/server/node_modules/@openrouter/sdk/esm/lib/matchers.js:193:19)
    at matchFunc (file:///home/karn/webbdrasil/Webdrasil/ygg-chat/server/node_modules/@openrouter/sdk/esm/lib/matchers.js:168:28)
    at processTicksAndRejections (node:internal/process/task_queues:105:5) {
  statusCode: 400,
  body: '{"error":{"message":"Provider returned error","code":400,"metadata":{"raw":"Gemini models require OpenRouter reasoning details to be preserved in each request. Please refer to our docs: https://openrouter.ai/docs/guides/best-practices/reasoning-tokens#preserving-reasoning-blocks. Upstream error: {\\n  \\"error\\": {\\n    \\"code\\": 400,\\n    \\"message\\": \\"Function call is missing a thought_signature in functionCall parts. This is required for tools to work correctly, and missing thought_signature may lead to degraded model performance. Additional data, function call `default_api:brave_search` , position 2. Please refer to https://ai.google.dev/gemini-api/docs/thought-signatures for more details.\\",\\n    \\"status\\": \\"INVALID_ARGUMENT\\"\\n  }\\n}\\n","provider_name":"Google AI Studio"}},"user_id":"org_361BMylN1K3ZlyQ4cA7DbzQP0yg"}',```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions