feat: add an endpoint that checks params before you call a model - #171
Open
brunobuddy wants to merge 2 commits into
Open
feat: add an endpoint that checks params before you call a model#171brunobuddy wants to merge 2 commits into
brunobuddy wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Second of four, on top of the applicability engine. POST /api/v1/validate takes a model and a params object and reports unknown parameters, values outside their range, and combinations the provider rejects. It also returns safeParams, a corrected payload that always passes validation, so a caller that doesn't want to reason about the rules can spread it and move on. Every issue carries a machine-readable code (unknown_parameter, invalid_value, not_applicable) so callers can branch on the failure kind instead of parsing prose. not_applicable also names the parameters that caused the conflict. No backend. The catalog compiles into the function bundle from the committed generated data, so there is no database, no filesystem read and no self-fetch. GET returns the endpoint contract rather than a bare 405, because that request is usually a person or an agent exploring the URL. The no-store header rule has to follow the general /api/(.*) rule in vercel.json: those rules layer, and the shared s-maxage would otherwise cache one caller's verdict and serve it to another.
brunobuddy
force-pushed
the
feat/validate-endpoint
branch
from
July 30, 2026 13:16
a0bc817 to
3d08d2e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second of four. Stacked on #170, so review that first. The diff here is only the endpoint.
💭 Why
The engine in #170 is only reachable from TypeScript. Most of this ecosystem is Python, and agents reach for
curlbefore they reach for a package.✨ What changed
POST /api/v1/validatetakes a model and params, returns issues plussafeParams.unknown_parameter,invalid_value,not_applicable(withconflictsWith).GETon the same path returns the endpoint contract instead of a bare 405./api/v1/index.json,llms.txt, and the/apidocs page.npm run typechecknow coversapi/too, viatsconfig.api.json.👤 For users
safeParamsis always a payload that passes validation, so a caller who doesn't want to reason about the rules can spread it and proceed. Accepts a bare model slug when only one provider publishes it.🔧 For operators
No backend. The catalog compiles into the function bundle from the committed generated data. No database, no filesystem read, no self-fetch.
The
no-storeheader rule has to stay after the general/api/(.*)rule invercel.json. Those rules layer, and the shareds-maxage=3600would otherwise cache one caller's verdict and serve it to another.📝 Notes
vercel build: the function is produced atfunctions/api/v1/validate.func, static/api/v1/*.jsonis untouched, and I ran the compiled artifact directly to confirm the verdict. Routing does not collide because static files are served in the filesystem phase andvalidateis not a path the static build emits.Requestobjects, no server needed.