The request to the Artificial Intelligence API failed, please try again!

Hello everyone,

I think the title says it all about my request…
every request ends with the same answer:
« The request to the Artificial Intelligence API failed, please try again! »

Do you have Gladys Plus active?

When I log in via Gladys Assistant the page displays… so I want to tell you yes!

Are you using a specific model?

I have the same error :eyes:

For the first requests, I had left it as auto, then I tried several specifically, but I always got the same response…

@pierre-gilles We’re getting 502s from the gateway on /openai/ask

Likely causes:

  • a heavy payload (84 KB) combined with tool_choice=required;
  • a tool schema rejected by the provider;
  • temporary unavailability.

I just tried again a moment ago, same thing…

Hi Benoit,

Thanks for the screenshot, I saw your request. This isn’t an API outage: requests work fine on my end. The issue therefore seems specific to your setup or this particular request.

To help me reproduce and understand what’s blocking, could you send me two files?

  1. Your Gladys logs: in Settings → System, click on « Download logs ». Do this right after reproducing the error, so it appears in the logs.
  2. The AI debug file: in Integrations → Artificial Intelligence, at the bottom of the page, in the « AI Debug » section, click on « Download JSON context for debugging ». This file contains exactly what Gladys sends to the AI (prompt, last conversation messages, and available tools).

These files may contain information about your home (device names, room names, scene names…). If you prefer not to post them publicly, send them to me in a private message here on the forum.

Thanks!

I tried again with other queries and it seems the word ‹ scène › is what’s making the AI go haywire…

It’s weird sometimes:


@pierre-gilles logs sent in DM

Thanks Benoit for the files!

This is a bug on Gladys’ side. Whenever a request involves scenes, Gladys sends the scene creation tool description to the AI. A recent update added an element that our AI provider can’t interpret, causing it to reject the entire request. This affects everyone, not just your installation. Thanks also to Cyril who had the same error!

I’m preparing a fix. In the meantime, requests that don’t mention scenes should work normally.

Also note: today the AI can create and launch scenes, but it can’t yet read the content of your existing scenes. Even once this bug is fixed, it still won’t be able to analyze your heating scenes. Don’t hesitate to create a feature request :slight_smile:

In the meantime, requests that don’t mention scenes (« what is the temperature of the living room? », « turn off the kitchen light »…) should work.

PS: your logs also show many SmartThings errors in HTTP 401 (refrigerator, washing machine). You probably need to reconnect your SmartThings account in the integration.

Hi everyone!

This topic is now under development.

A PR has been opened to restore AI-related scene requests:

Feel free to follow the PR, test (optional, especially for small requests) and give your feedback here if needed.

No problem, and thanks for looking beyond this AI bug!

I’ve accumulated quite a few scenes and fake devices to manage presence modes, simulate different heating modes (Eco, Off, Comfort…), take into account the calendar, etc. In short, a logic that has become a bit complex, to the point where I sometimes get lost myself! :sweat_smile: But it at least has the merit of working.

The idea was therefore to be able to summarize all this quickly to explain my current usage and identify what the new Thermostat feature could simplify or replace.

I’ll create a feature request in this direction. I think it would be a real plus to be able to factor in some scenes and simplify existing installations as Gladys evolves.

And I take this opportunity to thank the entire team and contributors once again: things are moving fast these days, and it’s really appreciated!

@pierre-gilles since you’re planning this AI engine evolution for the next version, could this point perhaps accompany it: Scènes « Demander à l'IA » : ajouter une option « Autoriser l'IA à lire et contrôler les appareils » pour des messages dynamiques rapides et sans effet de bord

(I’m flagging this because I see that this feature request doesn’t have the usual ‹ to be processed › tag, and I’m thinking it might be flying under the radar…)

@StephaneB No worries, your request isn’t lost! The « to-be-processed » tag no longer exists :slight_smile: Its absence doesn’t mean the topic has gone unnoticed.

The AI change we’re talking about here is a bug fix, not an engine update. This bug was blocking Gladys for everyone, so I treated it as a priority. It’s actually the only type of issue I handle outside of my plan.

For new AI features, nothing is planned before my paternity leave. I’m focusing on the plan I presented here: Gladys d'ici fin 2026 : une grande nouvelle et un plan ambitieux 🚀

There’s a small chance I’ll look into it if the baby arrives late and I’ve finished the entire plan before… But with 8 to 16 days left, I highly doubt it :smiley:

And during my leave?

Good news: Gladys keeps moving forward! Everything is ready for the project to run without me:

  • External integrations: anything that can become an external integration should be one. These integrations don’t depend on me, so you can work on them freely during my absence :rocket: Almost everything is possible without me: dashboard, scenes, compatibility, etc…
  • Bugs and fixes: I’m no longer the only one in charge! @cicoub13 and @bertrandda have exactly the same rights as me. They can review, merge, and publish fixes. You’re in very good hands :folded_hands:
  • New features: don’t hesitate to open topics in Demande de fonctionnalités. Nothing is lost, you can even develop the features, and we’ll review all requests upon my return :light_bulb:

OK, got it :+1: