@squidcloud/backend
    Preparing search index...

    Class SquidLlmServiceAbstract

    Abstract class representing a service for interacting with LLMs (Large Language Models).

    Hierarchy (View Summary)

    Index
    • get apiKeys(): Record<SecretKey, string>

      The list of your application's api keys.

      Returns Record<SecretKey, string>

    • get assetsDirectory(): string

      Returns the assets directory for your application.

      Returns string

      the assets directory for your application.

    • get context(): RunContext

      The context object for the current request. This object contains information about the current request, such as the current user, the IP address, the user agent used, the request headers, and more.

      Returns RunContext

    • get squid(): Squid

      Returns the Squid client instance for your application.

      Returns Squid

      the Squid client instance for your application.

    • get workspace(): WorkspaceClient

      Experimental. Backend-only API for a scratch directory ("workspace") synced across pod replicas via the shared workspace server — not the tenant's shared storage. See WorkspaceClient.

      Returns WorkspaceClient

    • Asserts that the current method call includes an API key in the context. Throws an error if called without an API key.

      Returns void

    • Asserts that the method is called within a valid request scope. Throws an error if no request context can be found.

      Returns void

    • Asserts that the current request is authenticated (using a user token or an API key).

      Returns void

      UNAUTHORIZED if the current request is not authenticated.

    • Converts a file to a SquidFile object. This function is useful when you want to return a file using OpenAPI (tsoa decorators).

      Parameters

      • file: File

      Returns Promise<SquidFile>

    • Constructs a response for an OpenAPI operation. This function is typically used within an OpenAPI handler.

      Parameters

      • Optionalbody: unknown

        The payload of the response. If not provided, defaults to an empty string.

      • OptionalstatusCode: number

        The HTTP status code for the response. Defaults to 200 if a body is present, otherwise 204.

      • Optionalheaders: Record<string, unknown>

        An object containing response headers. Defaults to an empty object if not provided.

      Returns any

      The openapi response.

    • A helper method to create a webhook response. This method should be used inside a webhook handler (function decorated with @webhook).

      Parameters

      • Optionalbody: unknown

        The body of the response.

      • OptionalstatusCode: number

        The status code of the response.

      • Optionalheaders: Record<string, unknown>

        The headers of the response.

      Returns any

      The webhook response.

    • Returns the API key used by the backend for your application.

      Returns string

    • Returns the auth object for the current request or undefined if unauthenticated or if using a user token.

      Returns AuthWithApiKey | undefined

      The auth object for the current request or undefined if unauthenticated or if using a user token.

    • Returns the auth object for the current request or undefined if unauthenticated or if using an API key.

      Returns AuthWithBearer | undefined

      The auth object for the current request or undefined if unauthenticated or if using an API key.

    • Whether this service is holding in-memory state that would be lost if the worker running it were recycled. Override it to return true while such state exists — an idle worker is normally torn down after a few minutes, which is invisible for a stateless service and destructive for one keeping a live session, a warm cache or a child process alive between calls.

      The runtime asks often and expects a cheap, synchronous answer. Returning true indefinitely pins the worker for as long as the pod lives, so it should track the state's own lifetime.

      Returns boolean

    • Returns true if the current request is authenticated (using a user token or an API key).

      Returns boolean

      true if the current request is authenticated (using a user token or an API key).

    • Publishes an AI status update to a specific client. Can be used to notify the client about the status of an AI operation, such as a chat or an aiFunction.

      Parameters

      Returns Promise<void>

    • Releases whatever hasLiveState was reporting. Called by the runtime when the worker is being terminated. Override it together with hasLiveState whenever the state owns something the worker's own shutdown does not reclaim — a child process outlives the thread that spawned it.

      Returns Promise<void>

    • Throws an OpenAPI response. This function is useful when you want to interrupt normal execution and immediately return a response from an OpenAPI handler.

      Parameters

      • content: ProtocolResponseContent

        The response content including optional body, status code, and headers.

      Returns never

      An object marked as an OpenAPI response.

    • Throws a webhook response. This function is useful when you want to interrupt normal execution and immediately return a response from a webhook handler.

      Parameters

      • content: ProtocolResponseContent

        The response content including optional body, status code, and headers.

      Returns never

      An object marked as a webhook response.

    backendBaseUrl: string
    region: "us-east-1.aws" | "ap-south-1.aws" | "us-central1.gcp" = ...

    Your application's region. When developing locally, the region will be set to local.