SnowPro Specialty: Gen AI Question 195
Single answer2.5 Run third-party models in Snowflake.A retail company has standardized on Snowflake and wants to use a third-party large language model to generate product descriptions from rows in a PRODUCTS table. The security team requires that application developers do not manage provider-specific API keys in code, and the data engineering team wants the inference calls to run directly from SQL inside Snowflake for batch processing. Which approach best meets these requirements?
- A
Create an external function that calls the model provider's REST API directly from SQL, and store the provider API key in each developer's application configuration.
- B
Use Snowflake Cortex AISQL functions to invoke a supported third-party model from within Snowflake, letting Snowflake handle the integration to the model provider.
- C
Export the PRODUCTS data to an external stage, run inference in a separate cloud notebook environment, and load the generated descriptions back into Snowflake.
- D
Create a JavaScript stored procedure that opens outbound network connections to the model provider and embeds the provider API key in the procedure definition.
Show answer and explanation
Correct answer: B
Explanation
The best answer is to use Snowflake Cortex AISQL functions to run supported third-party models directly within Snowflake. This approach is aligned with the platform's design for in-database AI inference: data remains in Snowflake, SQL can be used for batch processing across tables, and customers do not need to build custom API orchestration or distribute provider credentials to developers. In contrast, external functions or off-platform notebooks may be valid integration patterns for some use cases, but they add complexity and do not best meet the scenario's requirements. Snowflake documentation for Cortex AISQL and model inference emphasizes SQL-native access to supported models and a managed experience for running generative AI workloads inside Snowflake.
- A. Incorrect.
Incorrect. Although external functions can integrate SQL with external services, this approach does not best satisfy the stated requirements. It typically requires setting up and operating external API infrastructure and handling credentials or authentication patterns outside the simple managed experience the scenario is asking for. The requirement specifically says developers should not manage provider-specific API keys in code, and this option explicitly places keys in application configuration, which violates the security requirement.
- B. Correct.
Correct. Snowflake Cortex AISQL is designed to let users run inference from SQL directly in Snowflake using supported models, including third-party models made available through Snowflake. This aligns with the requirement to execute batch inference from SQL and avoids having developers manage provider-specific API keys in application code. It is the most direct and operationally simple approach for in-platform inference on Snowflake data.
- C. Incorrect.
Incorrect. This option can work technically, but it introduces unnecessary data movement, extra orchestration, and operational complexity. The scenario asks for inference to run directly from SQL inside Snowflake for batch processing. Exporting data to another environment is contrary to that goal and reduces the benefits of keeping data and compute centralized in Snowflake.
- D. Incorrect.
Incorrect. Snowflake stored procedures are not the recommended mechanism here for directly calling third-party model endpoints with embedded credentials. Embedding API keys in procedure code is a poor security practice and conflicts with the requirement that developers must not manage provider-specific API keys in code. It also misses the managed integration path Snowflake provides for supported third-party models.