cd /news/large-language-models/show-hn-compile-time-model-id-valida… · home topics large-language-models article
[ARTICLE · art-14528] src=github.com pub= topic=large-language-models verified=true sentiment=↑ positive

Show HN: Compile-time model-id validation with declared capability

A new Rust crate, `openrouter_toolkit`, introduces a compile-time macro `model_supports!` that validates OpenRouter model IDs and their declared capabilities against a vendored index. The macro catches unknown or unsupported capabilities—such as `param::toolz` or `input::image` on incompatible models—as compiler errors, preventing runtime failures. This tool enables developers to enforce model capability requirements at build time, reducing debugging time and ensuring only valid model configurations are deployed.

read1 min publishedMay 26, 2026

Compile-time checked OpenRouter model ids.

model_supports!

validates a model id and its required capabilities against a vendored OpenRouter index, then expands to the model id string.

use openrouter_toolkit::model_supports;

const MODEL: &str = model_supports!(
    "openai/gpt-5.4",
    param::tools,
    input::image,
    output::text,
);

Dynamic variants work too:

const MODEL: &str = model_supports!("moonshotai/kimi-k2-0905:exacto", param::tools);

param::*

— request parameters (e.g.param::tools

)input::*

— input modalities (e.g.input::image

)output::*

— output modalities (e.g.output::text

)

Unknown capability:

const MODEL: &str = model_supports!("qwen/qwen3.7-max", param::toolz);
error: unknown OpenRouter capability `param::toolz`; did you mean `param::tools`?

Capability not supported by the model:

const MODEL: &str = model_supports!("qwen/qwen3.7-max", input::image);
error: OpenRouter model `qwen/qwen3.7-max` does not support required capability(s): input::image
── more in #large-language-models 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/show-hn-compile-time…] indexed:0 read:1min 2026-05-26 ·