close
Skip to content

Latest commit

 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build an LLM Chat app in 5 minutes

Jump ahead:

Overview

This repository shows you how to build a simple chat app using Snowflake's API.

App Example

Quickly connect to Snowflake's LLM REST API

curl "https://[ACCOUNT-IDENTIFIER].snowflakecomputing.com/api/v2/cortex/inference:complete" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer YOUR_PERSONAL_ACCESS_TOKEN" \
    -d '{
        "model": "claude-3-5-sonnet",
        "messages": [
            {
            "role": "user",
            "content": "Write me a one line poem about Snowflake"
            }
        ]
    }'

Snowflake's API is compatible with OpenAI's spec

To reproduce:

  1. Sign up for a new Snowflake account here. Activate your account by e-mail (see screenshot below), pick a username and password, and you should see a welcome screen.

    Note: if you can't find your login info, search your inbox for an e-mail from "Snowflake Computing".

  2. Generate a Personal Access Token (PAT) -- this is your API key -- by visiting Authentication Settings. Be sure to set the network policy exception for easy weekend hacking:

    Screenshot 2025-09-12 at 11 25 08 AM
  3. Find your account identifier by clicking on your name in the bottom left corner of Snowflake's UI, and selecting Connect a tool to Snowflake:

    Screenshot 2025-04-15 at 9 08 27 PM
  4. That's it! Run the curl command in your terminal and observe the streaming output

Building your first app

  1. Clone this repo.

  2. Sign up for a new Snowflake account here. Activate your account by e-mail (see screenshot below), pick a username and password, and you should see a welcome screen.

    Note: If you can't find your login info, search your inbox for an e-mail from "Snowflake Computing".

  3. Generate a Personal Access Token (PAT) -- this is your API key -- by visiting Authentication Settings. Be sure to set the network policy exception for easy weekend hacking:

    Screenshot 2025-09-12 at 11 25 08 AM
  4. Click on your name in the bottom left corner, and select Connect a tool to Snowflake:

    Screenshot 2025-04-15 at 9 08 27 PM
  5. Use the information in the connect dialog to fill in your secrets.toml file:

    [snowflake]
    account = "[Account Identifier]"
    user = "[User Name]"
    api_key = "[Paste in your Personal Access Token here]"
    role = "[Role]"
    host = "[Account/Server URL]"
    
  6. Run pip install -r requirements.txt to make sure you have all the dependencies working.

  7. Run streamlit run streamlit.app and you should see a simple chat app ready to chat with you! Try changing the model used: mistral-large2, claude-3-5-sonnet or llama3.1-70b and compare the chat interaction!

About

A simple Chat app example using Snowflake's REST API and Streamlit

Resources

Stars

5 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages