Member Junction
    Preparing search index...

    The real OpenRouterDecision with only its network call replaced by OPENROUTER_GUARD.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    DEFAULT_ENDPOINT: "https://openrouter.ai/api/alpha/decisions"

    The OpenRouter Decisions API endpoint.

    DEFAULT_MODEL: "~typesafe/jev-latest"

    The model used when DecisionParams.Model is empty.

    Accessors

    • get apiKey(): string

      Only sub-classes can access the API key

      Returns string

    • get DefaultModel(): string

      The model used when DecisionParams.Model is empty.

      Returns string

    • get EndpointURL(): string

      The configured Decisions API endpoint URL.

      Returns string

    • get SecretsToRedact(): string[]

      The secrets an error message must never show, each removed with RedactSecret. Defaults to the credential's API key; a driver that sends only part of it (Cloudflare's token) adds that part.

      Returns string[]

    • get ServiceName(): string

      The API's name in error messages, such as 'OpenRouter Decisions API'.

      Returns string

    Methods

    • Executes a typed decision request across one or more questions about a given state. This method wraps driver execution with input validation, output verification, execution timing, and structured error handling. It never throws.

      Parameters

      • params: DecisionParams

        Decision request parameters including state, questions, and model.

      Returns Promise<DecisionResult>

      A Promise resolving to a DecisionResult.

    • The message of the error thrown for a non-2xx response. Defaults to the status and the first 500 characters of the body.

      Parameters

      • status: number

        The HTTP status.

      • bodyText: string

        The response body as text, possibly empty, with the API key already redacted (RedactSecret).

      Returns string

    • Marks the result failed because the response could not be mapped. Another model may still answer, so the failure allows failover (and is not 'Fatal', which would stop the failover loop).

      Parameters

      Returns DecisionResult

    • The one endpoint, whatever the model: the model travels in the body.

      Parameters

      • _model: string

      Returns string

    • The error type for a non-2xx status whose ErrorAnalyzer reading is wrong for this API, or undefined (the default) to leave it to ErrorAnalyzer, which reads the message and the status. A type returned here is attached to the thrown error as a Retriable error that allows failover: another candidate may answer what this API refused.

      Parameters

      • _status: number

        The HTTP status.

      Returns AIErrorType | undefined

    • The request headers. Defaults to the credential's API key as a bearer token and a JSON content type.

      Parameters

      • _model: string

        The model being asked.

      Returns Record<string, string>

    • The request body's model field. Defaults to the model unchanged.

      Parameters

      • model: string

        The model being asked.

      Returns string

    • Returns the System One response ({ model, answers, usage }) from a parsed 2xx body. Defaults to the body itself. A vendor that wraps the response in an envelope unwraps it here, and throws (with CreateSystemOneHTTPError) when the envelope reports a failure.

      Parameters

      • body: unknown

        The parsed JSON body.

      • _status: number

        The HTTP status, for an error thrown from here.

      Returns unknown

    • Validates input DecisionParams against the decision contract.

      Parameters

      Returns string[]

      An array of error descriptions, empty if valid.