Skip to content
Effect 4.0 is here. One ecosystem. Zero dependencies.

OpenRouterDecisionModel unstable

Decision models backed by OpenRouter's alpha Decisions API.

4 exports Since v4.0.0 Source

Constructors

make

unstable
Since v4.0.0

Creates a decision service that validates full choice and score distributions. Missing distributions yield "NoDistribution" with decideSettled or AiError.InvalidOutputError with decide. Score indices map to criteria labels. Reported cost and the serving provider are returned under metadata.openrouter. Probabilities arrive rounded to two decimals, so small sum drift is rescaled.

Signature

declare const make: (...args: [options: {
readonly config?: Pick<{
readonly model: string;
readonly provider?: {
readonly allow_fallbacks?: boolean | null;
readonly data_collection?: "deny" | "allow" | null;
readonly enforce_distillable_text?: boolean | null;
readonly ignore?: readonly Array<string> | null;
readonly max_price?: {
readonly audio?: ... | ...;
readonly completion?: ... | ...;
readonly image?: ... | ...;
readonly prompt?: ... | ...;
readonly request?: ... | ...;
};
readonly only?: readonly Array<string> | null;
readonly order?: readonly Array<string> | null;
readonly preferred_max_latency?: number | {
readonly p50?: ... | ... | ...;
readonly p75?: ... | ... | ...;
readonly p90?: ... | ... | ...;
readonly p99?: ... | ... | ...;
} | null;
readonly preferred_min_throughput?: number | {
readonly p50?: ... | ... | ...;
readonly p75?: ... | ... | ...;
readonly p90?: ... | ... | ...;
readonly p99?: ... | ... | ...;
} | null;
readonly quantizations?: readonly Array<... | ... | ... | ... | ... | ... | ... | ... | ...> | null;
readonly require_parameters?: boolean | null;
readonly sort?: "price" | "throughput" | "latency" | "exacto" | {
readonly by?: ... | ... | ... | ... | ... | ...;
readonly partition?: ... | ... | ... | ...;
} | null;
readonly zdr?: boolean | null;
} | null;
readonly questions: {
[key: string]: {
readonly criteria: {
[key: string]: ... | ... | ... | ...;
};
readonly instructions: string | {
[key: ...]: ...;
} | readonly Array<...>;
readonly type: "choice";
} | {
readonly criteria: readonly Array<... | ... | ...>;
readonly instructions: string | {
[key: ...]: ...;
} | readonly Array<...>;
readonly type: "score";
} | {
readonly criteria?: {
readonly false: ...;
readonly true: ...;
};
readonly instructions: string | {
[key: ...]: ...;
} | readonly Array<...>;
readonly type: "noul";
};
};
readonly session_id?: string;
readonly state: unknown;
readonly trace?: {
[key: string]: unknown;
};
readonly user?: string;
}, "provider" | "session_id" | "user" | "trace">;
readonly model: string;
}]) => Effect<DecisionModel, never, OpenRouterClient>

model

unstable
Since v4.0.0

Creates an OpenRouter model descriptor with decision support.

Signature

declare function model(model: string, config?: Pick<{
readonly model: string;
readonly provider?: {
readonly allow_fallbacks?: boolean | null;
readonly data_collection?: "deny" | "allow" | null;
readonly enforce_distillable_text?: boolean | null;
readonly ignore?: readonly Array<string> | null;
readonly max_price?: {
readonly audio?: string;
readonly completion?: string;
readonly image?: string;
readonly prompt?: string;
readonly request?: string;
};
readonly only?: readonly Array<string> | null;
readonly order?: readonly Array<string> | null;
readonly preferred_max_latency?: number | {
readonly p50?: number | null;
readonly p75?: number | null;
readonly p90?: number | null;
readonly p99?: number | null;
} | null;
readonly preferred_min_throughput?: number | {
readonly p50?: number | null;
readonly p75?: number | null;
readonly p90?: number | null;
readonly p99?: number | null;
} | null;
readonly quantizations?: readonly Array<"int4" | "int8" | "fp4" | "fp6" | "fp8" | "fp16" | "bf16" | "fp32" | "unknown"> | null;
readonly require_parameters?: boolean | null;
readonly sort?: "price" | "throughput" | "latency" | "exacto" | {
readonly by?: "price" | "throughput" | "latency" | "exacto" | null;
readonly partition?: "model" | "none" | null;
} | null;
readonly zdr?: boolean | null;
} | null;
readonly questions: {
[key: string]: {
readonly criteria: {
[key: string]: string | {
[key: string]: Json;
} | readonly Array<Json> | null;
};
readonly instructions: string | {
[key: string]: Json;
} | readonly Array<Json>;
readonly type: "choice";
} | {
readonly criteria: readonly Array<string | {
[key: string]: Json;
} | readonly Array<Json>>;
readonly instructions: string | {
[key: string]: Json;
} | readonly Array<Json>;
readonly type: "score";
} | {
readonly criteria?: {
readonly false: string | {
[key: string]: Json;
} | readonly Array<Json>;
readonly true: string | {
[key: string]: Json;
} | readonly Array<Json>;
};
readonly instructions: string | {
[key: string]: Json;
} | readonly Array<Json>;
readonly type: "noul";
};
};
readonly session_id?: string;
readonly state: unknown;
readonly trace?: {
[key: string]: unknown;
};
readonly user?: string;
}, "provider" | "session_id" | "user" | "trace">): Model<"openrouter", DecisionModel, OpenRouterClient>

Layers

layer

unstable
Since v4.0.0

Provides a decision model using the OpenRouter client service.

Signature

declare function layer(options: {
readonly config?: Pick<{
readonly model: string;
readonly provider?: {
readonly allow_fallbacks?: boolean | null;
readonly data_collection?: "deny" | "allow" | null;
readonly enforce_distillable_text?: boolean | null;
readonly ignore?: readonly Array<string> | null;
readonly max_price?: {
readonly audio?: string;
readonly completion?: string;
readonly image?: string;
readonly prompt?: string;
readonly request?: string;
};
readonly only?: readonly Array<string> | null;
readonly order?: readonly Array<string> | null;
readonly preferred_max_latency?: number | {
readonly p50?: number | null;
readonly p75?: number | null;
readonly p90?: number | null;
readonly p99?: number | null;
} | null;
readonly preferred_min_throughput?: number | {
readonly p50?: number | null;
readonly p75?: number | null;
readonly p90?: number | null;
readonly p99?: number | null;
} | null;
readonly quantizations?: readonly Array<"int4" | "int8" | "fp4" | "fp6" | "fp8" | "fp16" | "bf16" | "fp32" | "unknown"> | null;
readonly require_parameters?: boolean | null;
readonly sort?: "price" | "throughput" | "latency" | "exacto" | {
readonly by?: "price" | "throughput" | "latency" | "exacto" | null;
readonly partition?: "model" | "none" | null;
} | null;
readonly zdr?: boolean | null;
} | null;
readonly questions: {
[key: string]: {
readonly criteria: {
[key: string]: string | {
[key: string]: Json;
} | readonly Array<Json> | null;
};
readonly instructions: string | {
[key: string]: Json;
} | readonly Array<Json>;
readonly type: "choice";
} | {
readonly criteria: readonly Array<string | {
[key: string]: Json;
} | readonly Array<Json>>;
readonly instructions: string | {
[key: string]: Json;
} | readonly Array<Json>;
readonly type: "score";
} | {
readonly criteria?: {
readonly false: string | {
[key: ...]: ...;
} | readonly Array<...>;
readonly true: string | {
[key: ...]: ...;
} | readonly Array<...>;
};
readonly instructions: string | {
[key: string]: Json;
} | readonly Array<Json>;
readonly type: "noul";
};
};
readonly session_id?: string;
readonly state: unknown;
readonly trace?: {
[key: string]: unknown;
};
readonly user?: string;
}, "provider" | "session_id" | "user" | "trace">;
readonly model: string;
}): Layer<DecisionModel, never, OpenRouterClient>

Services

Config

unstable
Since v4.0.0

Request options that override model defaults at call time.

Signature

declare class Config extends Shape<"@effect/ai-openrouter/OpenRouterDecisionModel/Config", Pick<{
readonly model: string;
readonly provider?: {
readonly allow_fallbacks?: boolean | null;
readonly data_collection?: "deny" | "allow" | null;
readonly enforce_distillable_text?: boolean | null;
readonly ignore?: readonly Array<string> | null;
readonly max_price?: {
readonly audio?: string;
readonly completion?: string;
readonly image?: string;
readonly prompt?: string;
readonly request?: string;
};
readonly only?: readonly Array<string> | null;
readonly order?: readonly Array<string> | null;
readonly preferred_max_latency?: number | {
readonly p50?: number | null;
readonly p75?: number | null;
readonly p90?: number | null;
readonly p99?: number | null;
} | null;
readonly preferred_min_throughput?: number | {
readonly p50?: number | null;
readonly p75?: number | null;
readonly p90?: number | null;
readonly p99?: number | null;
} | null;
readonly quantizations?: readonly Array<"int4" | "int8" | "fp4" | "fp6" | "fp8" | "fp16" | "bf16" | "fp32" | "unknown"> | null;
readonly require_parameters?: boolean | null;
readonly sort?: "price" | "throughput" | "latency" | "exacto" | {
readonly by?: "price" | "throughput" | "latency" | "exacto" | null;
readonly partition?: "model" | "none" | null;
} | null;
readonly zdr?: boolean | null;
} | null;
readonly questions: {
[key: string]: {
readonly criteria: {
[key: string]: string | {
[key: string]: Json;
} | readonly Array<Json> | null;
};
readonly instructions: string | {
[key: string]: Json;
} | readonly Array<Json>;
readonly type: "choice";
} | {
readonly criteria: readonly Array<string | {
[key: string]: Json;
} | readonly Array<Json>>;
readonly instructions: string | {
[key: string]: Json;
} | readonly Array<Json>;
readonly type: "score";
} | {
readonly criteria?: {
readonly false: string | {
[key: ...]: ...;
} | readonly Array<...>;
readonly true: string | {
[key: ...]: ...;
} | readonly Array<...>;
};
readonly instructions: string | {
[key: string]: Json;
} | readonly Array<Json>;
readonly type: "noul";
};
};
readonly session_id?: string;
readonly state: unknown;
readonly trace?: {
[key: string]: unknown;
};
readonly user?: string;
}, "provider" | "session_id" | "user" | "trace">, this> {
constructor(_: never);
}