@squidcloud/client
    Preparing search index...

    Class AiClient

    AiClient class serves as a facade for interacting with different AI services. It provides simplified access to AI chatbot and assistant functionalities through its methods.

    Index

    Methods

    • Executes an AI-powered API call using a specific integration. The AI will select appropriate endpoints, generate request bodies, and analyze responses to answer the provided prompt.

      Parameters

      • integrationId: string

        The API integration to use

      • prompt: string

        Natural language description of what to accomplish

      • Optionaloptions: AiAgentApiIntegrationOptions

        Optional configuration including allowed endpoints and verbose updates

      • OptionalsessionContext: AiSessionContext

        Optional session context for audit trails and tracing

      Returns Promise<ExecuteAiApiResponse>

      Promise resolving to the API call result with answer and execution details

    • Executes an AI query using a specific DB integration, sending a prompt to the AI and returning its response. This function allows for direct interaction with the AI's capabilities by sending text prompts and receiving the AI's responses, which can be used for various applications such as automating tasks, generating content, or obtaining information.

      Parameters

      • integrationId: string

        The identifier for the DB integration which is used to direct the query to the appropriate DB.

      • prompt: string

        The text prompt to send to the AI. This should be formulated in a way that the AI can understand and respond to, taking into account the nature of the task or the information sought.

      • Optionaloptions: AiQueryOptions

        Additional options to customize the query execution.

      Returns Promise<AiQueryResponse>

      A promise that resolves to an ExecuteAiQueryResponse. This response includes the AI's reply to the provided prompt, along with any other relevant information that is part of the AI's response. The promise can be awaited to handle the response asynchronously.

      const response = await squid.ai().executeAiQuery(myDbIntegrationId, "How many transactions ran yesterday?");
      console.log(response);

      Can be used with an API key or using a security rule with @secureAiQuery() decorator.

      For more details on the usage and capabilities of the AI Assistant, refer to the documentation provided at https://docs.squid.cloud/docs/ai.

    • Creates a client to manage files for a specific AI provider.

      Parameters

      Returns AiFilesClient

      An AiFilesClient bound to the specified provider.

      const openaiFiles = squid.ai().files('openai');
      const fileId = await openaiFiles.uploadFile({ file });
      await openaiFiles.deleteFile(fileId);
    • Returns name of the secret that stores API key for the given AI provider type. This API key is used for all requests to the AI provider done from the application.

      Returns Promise<ApplicationAiSettings>

    • Lists all available AI agents.

      Returns Promise<AiAgent<undefined>[]>

    • Sets the name of the secret that stores API key for the given AI provider type. This API key is used for all requests to the AI provider done from the application. To delete the existing secret key use 'undefined' for the name of the secret. Returns the updated state of the AI application settings.

      Parameters

      • providerType:
            | "anthropic"
            | "flux"
            | "gemini"
            | "openai"
            | "grok"
            | "stability"
            | "voyage"
            | "external"
      • secretKey: string | undefined

      Returns Promise<ApplicationAiSettings>