Blog

A more reliable AI chat: 99% valid diagrams on the first try

With 0.8.1 and 0.8.2, the AI chat goes from 88% to 99% valid diagrams, the diagram always reaches the preview, and provider errors finally explain themselves.

Asking an AI for a diagram only helps if what comes back actually renders. If you have to fix the syntax by hand or copy code out of the chat into the editor, the shortcut isn't one anymore. In 0.8.1 and 0.8.2 we went after exactly that: measure why the chat failed, then fix every cause.

From 88% to 99% valid diagrams

We built a benchmark with 160 cases across 4 models. The chat produced a valid diagram on the first try 88% of the time; with 0.8.1 it reaches 99%. What we fixed:

  • The streaming chat — the one the app uses — sent a minimal prompt, without the expected format or any syntax rules.
  • Replies were getting cut off at the token limit, because reasoning models spend part of it thinking. A code request now gets 8,192 tokens.
  • "Create a flow… (does it need surgery?)" was treated as a question because of the question mark.
  • Syntax rules were checked against the real renderers: ASCII identifiers in DBML, valid D2 shapes, PlantUML activity syntax…

The API's /ai/generate-diagram endpoint improves as well: from 72% to 98% valid diagrams.

The diagram always reaches the preview

0.8.2 fixes a really annoying one. The chat guessed from keywords whether your message asked for a diagram or asked a question, and only looked for code in the first case. Requests like "Can you make…?", "I need…" or "Add to it…" were taken as questions: the model did answer with the diagram, but it showed up as text broken into fragments, with no preview and no accept button.

Now the model's reply decides: if it carries a diagram, it's shown with a preview, validated, and you can accept or reject it. Measured with real Gemini calls, 7 out of 7 requests of that kind used to leave the code in the chat; now it's 0 out of 7, across the 4 diagram types. Questions are still answered with text.

flowchart TD
    A[Model reply] --> B{Cut at the limit?}
    B -->|Yes| C[Notice, not applied]
    B -->|No| D{Carries a diagram?}
    D -->|No| E[Text answer]
    D -->|Yes| F{Does it render?}
    F -->|Yes| G[Preview: accept or reject]
    F -->|"No (Mermaid or D2)"| H[Automatic fix, once]
    H --> G

Cut replies and automatic fixes

Every chat reply now gets the 8,192-token cap, and a cut reply is never applied: you see a notice instead of a broken fragment.

There's also an optional automatic fix (Settings → AI, on by default): if generated Mermaid or D2 code doesn't render, the model is asked to fix it, once. It never runs for PlantUML or DBML.

Clear errors and current models

Any provider failure used to look like a "rate limit". DiagramaHub now tells apart invalid key, no credits, model unavailable and rate limit, and "Test connection" makes a real call with the model you picked.

The model catalog is up to date, checked against each provider's docs and with live calls: Claude Sonnet 5.5 / Opus 5.5 / Fable 5.1, OpenAI gpt-6-luna / gpt-6.1-sol / gpt-6-astra, DeepSeek deepseek-flash, Gemini 3.8-flash and MiniMax M3. If you had saved a model that's no longer listed, it keeps working and is marked "retired".

The whole chat in your language

The backend now receives the real interface language (it was always Spanish before). With 0.8.2 the chat is fully available in English — messages, preview card, session selector, phases and errors — and chat and provider errors arrive in the user's language.

Security

0.8.1 also ships security fixes:

  • A user could file diagrams under someone else's folder, where they showed up in that folder's explorer tree and export. The folder must now belong to the same project. If you self-host, run scripts.fix_misfiled_diagrams once (it only reports; --apply repairs, without deleting anything).
  • Duplicating a diagram respects the plan limit.
  • axios 1.20 fixes 12 security advisories (7 high), and the production audit is back to zero.
  • Import limits apply to the whole request, not per ZIP.

Try it

Open the chat on any diagram in DiagramaHub Cloud with your own key, or upgrade your instance from the repository. The full details are in the changelog.