@svatah/yam-gateway
Model gateway: local and frontier backends, caching, redaction, provenance
- Source:
packages/gateway· README:packages/gateway/README.md - Install:
npm install @svatah/yam-gateway - Version 0.1.0 · Apache-2.0
Exports
| Export | Kind | Signature | |
|---|---|---|---|
anthropicGateway | function | export function anthropicGateway(options: AnthropicGatewayOptions = {}): Gateway | |
AnthropicGatewayOptions | interface | export interface AnthropicGatewayOptions | |
assertNoSecret | function | export function assertNoSecret( | Throw if a secret survived. |
CacheEntry | interface | export interface CacheEntry | |
cacheKey | function | export function cacheKey(parts: CacheKeyParts): string | |
CacheKeyParts | interface | export interface CacheKeyParts | |
costOf | function | export function costOf(model: string, tokens: TokenCounts): number | Dollars for one call. |
credentialInEnvironment | function | export function credentialInEnvironment(env: NodeJS.ProcessEnv = process.env): boolean | Whether a credential is resolvable without asking for one. |
DEFAULT_MAX_TOKENS | variable | DEFAULT_MAX_TOKENS = 4_096 | The default ceiling. Grounding answers are small; thinking is not billed against it. |
DEFAULT_MODEL | variable | DEFAULT_MODEL = "claude-opus-5" | |
DiskCache | class | export class DiskCache implements GatewayCache | One JSON file per answer, under a directory the caller names. |
Effort | typealias | export type Effort = "low" | "medium" | "high" | "xhigh" | "max"; | How hard the model should think (output_config.effort). |
emptyUsage | function | export function emptyUsage(): GatewayUsage | |
fakeGateway | function | export function fakeGateway(options: FakeGatewayOptions): Gateway | |
FakeGatewayOptions | interface | export interface FakeGatewayOptions | |
formatUsd | function | export function formatUsd(amount: number): string | $0.0123, for a line a person reads. |
Gateway | interface | export interface Gateway | |
GatewayAnswer | interface | export interface GatewayAnswer<T> | An answer, with what it cost to get (REQ-AGT-3, REQ-NFR-2). |
GatewayCache | interface | export interface GatewayCache | |
GatewayImage | interface | export interface GatewayImage | An image, for the vision fallback only (REQ-REC-2). |
GatewayRefusal | class | export class GatewayRefusal extends Error | The model declined (LLD §10: "refusal stop reason handled as a tier failure"). |
GatewayRequest | interface | export interface GatewayRequest<T> | One question. |
GatewayShapeError | class | export class GatewayShapeError extends Error | The model answered, and the answer was not the shape that was asked for. |
GatewayUnavailable | class | export class GatewayUnavailable extends Error | A backend that was configured and could not be reached, or has no credential. |
GatewayUsage | interface | export interface GatewayUsage | Running totals, for the per-invocation cost line REQ-NFR-2 asks for. |
localGateway | function | export function localGateway(options: LocalGatewayOptions): Gateway | |
LocalGatewayOptions | interface | export interface LocalGatewayOptions | |
LocalProvider | typealias | export type LocalProvider = "ollama" | "llamacpp"; | |
LocalRequestBody | interface | export interface LocalRequestBody | The body sent to a local server, for the same reason render() exists. |
MemoryCache | class | export class MemoryCache implements GatewayCache | Answers in memory, for tests and for one process's repeated questions. |
NO_CACHE | variable | NO_CACHE: GatewayCache | A cache that keeps nothing. The default when no directory is configured. |
priced | function | export function priced(model: string): boolean | Whether the cost of this model is a measured number rather than a zero. |
Prices | interface | export interface Prices | What a call cost (REQ-NFR-2: "estimated and actual tokens and cost printed per |
PRICES | variable | PRICES: Readonly<Record<string, Prices>> | |
REDACTED | variable | REDACTED = "«redacted»" | The marker a redacted secret leaves behind. Matches the runtime's. |
redactText | function | export function redactText(text: string, secrets: ReadonlySet<string> | undefined): string | Replace every secret occurrence in a string. |
render | function | export function render<T>(request: GatewayRequest<T>, options: RenderOptions): RenderedRequest | |
RenderedRequest | interface | export interface RenderedRequest | The body client.messages.create is called with. |
renderLocal | function | export function renderLocal<T>( | |
RenderOptions | interface | export interface RenderOptions | |
resolveDigest | function | export async function resolveDigest( | The digest of the weights a server is actually serving (REQ-COMP-3). |
schemaOf | function | export function schemaOf<T>(request: GatewayRequest<T>): Record<string, unknown> | The JSON Schema the model is constrained to. |
SEED | variable | SEED = 7 | A fixed seed, so two compiles of one project agree (REQ-COMP-3, REQ-COMP-7). |
TokenCounts | interface | export interface TokenCounts |