Skip to main content
This section documents how the gateway codebase is organized. It is written to help you find the right folder quickly and understand what each file does.

apps/api/src layout

FolderPurposeKey files
apps/api/src/routesHTTP routing and endpoint registration.root.ts, v1/index.ts, v1/control/health.ts, v1/control/models.ts
apps/api/src/lib/gatewayRequest pipeline, adapters, pricing, and telemetry.pipeline.ts, execute/, before/, after/
apps/api/src/irIntermediate representation (IR) for normalized requests/responses.types.ts, streaming.ts
apps/api/src/protocolsProtocol-specific parsing and emitters.openai/, anthropic/
apps/api/src/routerSurface selection and strictness handling.surfaces.ts, strictness.ts, param_classifier.ts
apps/api/src/runtimeRuntime env bindings and helpers.env.ts
apps/api/src/libShared schemas, error handler, and utilities.schemas.ts, types.ts, error-handler.ts

How requests flow

  1. Routes register protocol-accurate endpoints under apps/api/src/routes.
  2. Protocol parsers map request bodies into the IR (apps/api/src/ir).
  3. The gateway pipeline selects providers and executes upstream calls.
  4. Responses are normalized back into IR and emitted in the original protocol shape.
Last modified on February 11, 2026