All templates
AI Models

Foundry

Own your model instead of renting one

foundry.cloud.nexlayer.ai
Foundry app screen

Capture your production AI traffic, label it, run evals and turn it into fine-tuning data, so your own model can match the frontier API on your task. One dashboard shows pass rate, latency and cost per model.

Who uses it: AI engineers and the domain experts who label examples.

Screens

Traffic

Captured requests and responses, searchable, with sampling rules.

Label

Label queue: grade a response, correct it, tag the failure.

Evals

Eval suites, runs per model, pass rate and p95 latency over time.

Compare

Your model against the frontier API on the same eval set.

Datasets

Build and export fine-tune datasets from labeled traffic.

How it runs

Live on Nexlayer · foundry.cloud.nexlayer.ai
Browser
your users
/↓
web
React · Vite
/api↓
api
Go · OpenAPI
postgres.pod↓
postgres
pgvector · volume
Nexlayer Inference
AI models · API key

Data model

  • projects
    id, name, created_at
  • requests
    id, project_id, model, input, output, latency_ms, cost_micros, at, embedding vector(1024)
  • labels
    id, request_id, grade (good | bad), corrected_output, failure_tag, labeler_id
  • eval_suites
    id, project_id, name, cases_count
  • eval_cases
    id, suite_id, input, expected, checker (exact | contains | model_graded)
  • eval_runs
    id, suite_id, model, pass_rate, p95_ms, status, started_at
  • datasets
    id, project_id, filters jsonb, examples, format, storage_key

API

  • POST/api/ingest
    Capture a request/response (API key auth, batched)
  • GET/api/requests
    Search traffic (text and semantic)
  • POST/api/labels
    Label a request
  • POST/api/suites/{id}/runs
    Start an eval run against a model
  • GET/api/runs/{id}
    Run results, streamed while running
  • POST/api/datasets
    Build a dataset from labeled traffic
  • GET/api/metrics
    Pass rate, latency and cost per model over time

Build it with your agent

Copy the prompt into Claude Code, Codex, Cursor or any coding agent connected to Nexlayer. It works from a spec: contracts first, then each phase with checks that must pass, then it ships to Nexlayer and verifies the live app.

Build graph · one agent, phase by phase
  1. 1Spec + contract
  2. 2API
  3. 3Web
  4. 4AI
  5. 5End-to-end test
  6. 6Ship + verify
Build Foundry: own your model instead of renting one. A production full-stack web application, deployed live on Nexlayer.

Work spec-first. Before writing app code, write SPEC.md (from the spec below, plus your decisions), api/openapi.yaml and the first migration, and show me a short plan. Then build in phases and don't move on until each phase's checks pass.

## Product
Capture your production AI traffic, label it, run evals and turn it into fine-tuning data, so your own model can match the frontier API on your task. One dashboard shows pass rate, latency and cost per model.
Users: AI engineers and the domain experts who label examples.

## Screens
- Traffic: Captured requests and responses, searchable, with sampling rules.
- Label: Label queue: grade a response, correct it, tag the failure.
- Evals: Eval suites, runs per model, pass rate and p95 latency over time.
- Compare: Your model against the frontier API on the same eval set.
- Datasets: Build and export fine-tune datasets from labeled traffic.

## Data model (Postgres + pgvector)
- projects(id, name, created_at)
- requests(id, project_id, model, input, output, latency_ms, cost_micros, at, embedding vector(1024))
- labels(id, request_id, grade (good | bad), corrected_output, failure_tag, labeler_id)
- eval_suites(id, project_id, name, cases_count)
- eval_cases(id, suite_id, input, expected, checker (exact | contains | model_graded))
- eval_runs(id, suite_id, model, pass_rate, p95_ms, status, started_at)
- datasets(id, project_id, filters jsonb, examples, format, storage_key)

## API
- POST /api/ingest — Capture a request/response (API key auth, batched)
- GET /api/requests — Search traffic (text and semantic)
- POST /api/labels — Label a request
- POST /api/suites/{id}/runs — Start an eval run against a model
- GET /api/runs/{id} — Run results, streamed while running
- POST /api/datasets — Build a dataset from labeled traffic
- GET /api/metrics — Pass rate, latency and cost per model over time

## AI
- Eval runs call the model under test through Nexlayer Inference; model-graded checks use a separate grader prompt with a fixed rubric.
- Embed captured traffic in pgvector to find clusters of similar failures.

## Seed data
One project with 5,000 captured requests, 800 labels, 2 eval suites and 8 weeks of runs for two models.

## Core flow (must work end to end)
Ingest traffic, label five requests, run an eval suite, compare two models, and export a dataset.

## Stack (fixed)
- web/: React 19 + TypeScript (strict) + Vite, React Router, TanStack Query, Tailwind CSS. A typed API client generated from the OpenAPI spec. Served as static files by a small web server in its own container.
- api/: Go (latest stable), net/http with Go 1.22+ routing patterns or chi, pgx v5, sqlc for queries, golang-migrate for migrations, log/slog JSON logs, OpenAPI 3.1 spec in api/openapi.yaml as the contract.
- Postgres 16 with the pgvector extension (HNSW indexes on embedding columns), on a persistent volume.
- AI: Nexlayer Inference. Read the endpoint, model and key from environment variables NEXLAYER_INFERENCE_URL, NEXLAYER_INFERENCE_MODEL and NEXLAYER_INFERENCE_API_KEY. The key comes from https://inference.nexlayer.com/app/#/models: ask me to add it as a secret in Nexlayer. Never ask me to paste it into this chat and never write it into the repo.

## Engineering bar
- Contract first: api/openapi.yaml is the source of truth; the Go handlers and the web client are generated from or checked against it.
- Errors as RFC 9457 problem+json. Validate every input at the edge. Cursor pagination on every list.
- Auth: email magic link or password with argon2id; HTTP-only, SameSite session cookies; role checks in the API, never only in the UI.
- Idempotency keys on every POST that creates or submits something. Request timeouts via context. Graceful shutdown.
- GET /api/healthz (process up) and GET /api/readyz (database reachable, migrations applied).
- Migrations run on start, forward only. Seed data behind a SEED=true flag.
- AI calls: timeouts, retries with backoff, streamed responses over SSE, prompts kept in files, structured JSON output validated before use, and a clear UI state when NEXLAYER_INFERENCE_API_KEY is missing (the rest of the app still works).
- Web: loading, empty and error states on every screen; keyboard accessible; no layout shift.
- Tests: Go table-driven tests, integration tests against a real Postgres (testcontainers), and one Playwright test for the core flow. Lint and typecheck clean.

## Phases
1. Contract: SPEC.md, openapi.yaml, schema and migrations, seed data. Check: migrations apply cleanly to an empty database.
2. API: every endpoint in the spec, with auth and role checks. Check: Go tests and integration tests pass.
3. Web: every screen, wired to the API through the generated client. Check: typecheck and lint pass; every screen has loading, empty and error states.
4. AI: retrieval, model calls and streaming as described. Check: works with a key, degrades clearly without one.
5. End to end: the Playwright test for the core flow passes locally.
6. Ship on Nexlayer (below).

## Ship it on Nexlayer
- Load the Nexlayer skill first: call nexlayer_get_skill_content with skillName "ship-it-nexlayer" and follow it.
- Dockerfiles: multi-stage, small runtime images, built for linux/amd64.
- nexlayer.yaml: three parts. web with path "/", api with path "/api", postgres with no path (private) and a volume. Set PGDATA to a subdirectory of the volume mount. The api reaches the database at postgres.pod; the browser reaches the api at <% URL %>/api. Secrets are ${NAME} references, never values.
- Deploy with `nexlayer ship --check /api/readyz` if the Nexlayer CLI is installed, otherwise through the Nexlayer MCP (validate, deploy, check status).
- Don't stop at "deployed": open the live URL, run the core flow against it, and send me the URL with what you verified.

New to Nexlayer? Connect your agent first