Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ coverage/
.idea/
.gstack/
.fieldflow/
.wrangler/
.dev.vars*
9 changes: 7 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,13 @@ The website code lives under `src/`:

Everything the catalog ships beyond the static site:

- `api/` — Vercel Functions, currently `POST /api/v1/validate`. These serve paths the
static build doesn't emit; the rest of `/api/v1/*` stays static JSON from `dist/`.
- `api/` — the dynamic endpoints, `POST /api/v1/validate` and `/mcp`, as web-standard
`fetch` handlers. These serve paths the static build doesn't emit; the rest of
`/api/v1/*` stays static JSON from `dist/`.
- `worker/` — the Cloudflare Worker (`wrangler.jsonc`): routes to `api/`, serves `dist/`,
redirects modelparameters.dev and the www hosts, sets the API headers, and logs one
`api_request` line per API call. `npm run cf:dev` builds and runs it locally. The same
`api/` handlers still deploy as Vercel Functions through `vercel.json`.
- `packages/modelparams/` — the npm package: generated types plus the runtime
validation helpers. `src/generated/` is committed and CI checks it against the YAML,
so run `npm run codegen --workspace=modelparams` after changing the catalog.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ curl https://modelparams.dev/api/v1/models/openai/gpt-5.5.json

Schema at `https://modelparams.dev/api/v1/schema.json`, per the [Model Parameters convention](docs/model-parameters-schema.md).

API requests are counted at the edge and reported to Vercel Web Analytics as `api_request` custom events (endpoint, model, client type), so API usage lands in the same dashboard as page views. Off Vercel it's a no-op; see [`src/tracking/api-usage.ts`](src/tracking/api-usage.ts).
API requests are counted at the edge and reported to Vercel Web Analytics as `api_request` custom events (endpoint, model, client type), so API usage lands in the same dashboard as page views. On Cloudflare Workers the Worker logs the same event as a JSON line in Workers Logs instead; see [`src/tracking/api-usage.ts`](src/tracking/api-usage.ts).

### Validate a request

Expand Down
5 changes: 3 additions & 2 deletions api/mcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import { createServer } from "../packages/modelparams-mcp/src/server.js";

const MAX_BODY_BYTES = 256 * 1024;

// Vercel exposes the deployment sha; the catalog is whatever that build carried,
// The deployment sha (Vercel sets VERCEL_GIT_COMMIT_SHA; the Cloudflare deploy
// passes COMMIT_SHA as a Worker var). The catalog is whatever that build carried,
// so it is the honest answer to "which version am I talking to?".
const VERSION = process.env.VERCEL_GIT_COMMIT_SHA?.slice(0, 7) ?? "dev";
const VERSION = (process.env.VERCEL_GIT_COMMIT_SHA ?? process.env.COMMIT_SHA)?.slice(0, 7) || "dev";

const CORS = {
"Access-Control-Allow-Origin": "*",
Expand Down
Loading
Loading