# Databricks Apps Cookbook > Ready-to-use code snippets for building data and AI applications using Databricks Apps This file contains links to documentation sections following the llmstxt.org standard. ## Table of Contents - [Dash: Connect an MCP server](https://apps-cookbook.dev/docs/dash/aiml/mcp_connect.md): This recipe connects to an [MCP](https://modelcontextprotocol.io/overview) server for AI applications using GitHub as an example and the Unity Catalog [HTTP connection](https://docs.databricks.com/aws/en/query-federation/http) for secure and governed access. - [Dash: Invoke a model](https://apps-cookbook.dev/docs/dash/aiml/ml_serving_invoke.md): This recipe invokes a model hosted on [Mosaic AI Model Serving](https://docs.databricks.com/aws/en/machine-learning/model-serving/) using the [Databricks SDK for Python](https://databricks-sdk-py.readthedocs.io/en/latest/) and returns the result. Choose either a traditional ML model or a large language model (LLM). - [Dash: Run vector search](https://apps-cookbook.dev/docs/dash/aiml/ml_vector_search.md): This recipe performs a vector search query on a [Mosaic AI Vector Search](https://docs.databricks.com/aws/en/generative-ai/vector-search) index using the [Databricks SDK for Python](https://databricks-sdk-py.readthedocs.io/en/latest/). - [Dash: Get current user](https://apps-cookbook.dev/docs/dash/authentication/users_get_current.md): This recipe gets information about the user accessing this Databricks App from their [HTTP headers](https://docs.databricks.com/en/dev-tools/databricks-apps/app-development.html#what-http-headers-are-passed-to-databricks-apps). - [Dash: Embed a dashboard](https://apps-cookbook.dev/docs/dash/bi/embed_dashboard.md): This recipe embeds a [Databricks AI/BI dashboard](https://docs.databricks.com/aws/en/dashboards/) into a Databricks App. - [Dash: Chat with a Genie Space](https://apps-cookbook.dev/docs/dash/bi/genie_api.md): This app uses the [AI/BI Genie](https://www.databricks.com/product/ai-bi) [Conversations API](https://docs.databricks.com/api/workspace/genie) to let users ask questions about your data for instant insights (answers and table-like output). Visualizations aren't yet supported in the API. - [Dash: Connect to a cluster](https://apps-cookbook.dev/docs/dash/compute/compute_connect.md): This recipe uses [Databricks Connect](https://docs.databricks.com/en/dev-tools/databricks-connect/python/index.html) to execute pre-defined Python or SQL code on a **shared** cluster with UI inputs. - [Dash: External connections](https://apps-cookbook.dev/docs/dash/external_services/external_connections.md): This recipe demonstrates how to use Unity Catalog-managed external [HTTP connections](https://docs.databricks.com/aws/en/query-federation/http) for secure and governed access to MCP and non-MCP servers, for example, to GitHub, or Jira, and Slack. - [Dash: Retrieve a secret](https://apps-cookbook.dev/docs/dash/external_services/secrets_retrieve.md): This recipe retrieves a [Databricks secret](https://docs.databricks.com/en/security/secrets/index.html). Use secrets to securely connect to external services and APIs. - [Dash: OLTP Database](https://apps-cookbook.dev/docs/dash/tables/oltp_database.md): This recipe connects to a [Databricks Lakebase](https://docs.databricks.com/aws/en/oltp/) OLTP database instance to read data from PostgreSQL tables. It uses OAuth token-based authentication with connection pooling for efficient database access. - [Dash: Edit a Delta table](https://apps-cookbook.dev/docs/dash/tables/tables_edit.md): Use this recipe to read, edit, and write back data in a [Unity Catalog table](https://docs.databricks.com/aws/en/tables/) using the [Databricks SQL Connector](https://docs.databricks.com/en/dev-tools/python-sql-connector.html). - [Dash: Read a Delta table](https://apps-cookbook.dev/docs/dash/tables/tables_read.md): This recipe reads a [Unity Catalog table](https://docs.databricks.com/aws/en/tables/) using the [Databricks SQL Connector](https://docs.databricks.com/en/dev-tools/python-sql-connector.html). - [Dash: Download a file](https://apps-cookbook.dev/docs/dash/volumes/volumes_download.md): This recipe downloads a file from a [Unity Catalog volume](https://docs.databricks.com/en/volumes/index.html) using the [Databricks SDK for Python](https://databricks-sdk-py.readthedocs.io/en/latest/). - [Dash: Upload a file](https://apps-cookbook.dev/docs/dash/volumes/volumes_upload.md): This recipe uploads a file to a [Unity Catalog volume](https://docs.databricks.com/en/volumes/index.html) using the [Databricks SDK for Python](https://databricks-sdk-py.readthedocs.io/en/latest/). - [Dash: Retrieve workflow results](https://apps-cookbook.dev/docs/dash/workflows/workflows_get_results.md): This recipe retreives the results of a [Databricks Workflows](https://docs.databricks.com/en/jobs/index.html) job task run using the [Databricks SDK for Python](https://databricks-sdk-py.readthedocs.io/en/latest/).. - [Dash: Run a workflow](https://apps-cookbook.dev/docs/dash/workflows/workflows_run.md): This recipe triggers a [Databricks Workflows](https://docs.databricks.com/en/jobs/index.html) job using the [Databricks SDK for Python](https://databricks-sdk-py.readthedocs.io/en/latest/). - [Deployment instructions](https://apps-cookbook.dev/docs/deploy.md): Follow these instructions to deploy the interactive examples to your Databricks workspace or to run them locally. - [FastAPI: Interact with Lakebase Tables](https://apps-cookbook.dev/docs/fastapi/building_endpoints/lakebase/lakebase_orders.md): This recipe demonstrates how to build a complete orders management API using Lakebase PostgreSQL database. These endpoints provide CRUD operations and various query patterns for handling orders data synchronized from Databricks Unity Catalog. - [FastAPI: Create Lakebase Resources](https://apps-cookbook.dev/docs/fastapi/building_endpoints/lakebase/lakebase_resources_create.md): This recipe demonstrates how to programmatically create Lakebase PostgreSQL resources in your Databricks workspace using FastAPI. This endpoint sets up a complete Lakebase environment including a database instance, catalog, and synced table pipeline. - [FastAPI: Delete Lakebase Resources](https://apps-cookbook.dev/docs/fastapi/building_endpoints/lakebase/lakebase_resources_delete.md): This recipe demonstrates how to programmatically delete Lakebase PostgreSQL resources from your Databricks workspace using FastAPI. This endpoint safely removes all created Lakebase resources to avoid ongoing costs. - [FastAPI: Connect an MCP server](https://apps-cookbook.dev/docs/fastapi/building_endpoints/mcp_connect.md): This recipe connects to an [MCP](https://modelcontextprotocol.io/overview) server for AI applications using GitHub as an example and the Unity Catalog [HTTP connection](https://docs.databricks.com/aws/en/query-federation/http) for secure and governed access. - [FastAPI: Insert data into a table](https://apps-cookbook.dev/docs/fastapi/building_endpoints/tables_insert.md): This recipe demonstrates how to insert data into a Databricks [Unity Catalog table](https://docs.databricks.com/aws/en/tables/) from a FastAPI application using the [Databricks SQL Connector](https://docs.databricks.com/en/dev-tools/python-sql-connector.html). - [FastAPI: Read a table](https://apps-cookbook.dev/docs/fastapi/building_endpoints/tables_read.md): This recipe demonstrates how to query Databricks [Unity Catalog tables](https://docs.databricks.com/aws/en/tables/) from a FastAPI application using the [Databricks SQL Connector](https://docs.databricks.com/en/dev-tools/python-sql-connector.html). - [FastAPI: Stream video from volumes](https://apps-cookbook.dev/docs/fastapi/building_endpoints/volumes_stream_video.md): This recipe demonstrates how to stream video files from [Unity Catalog volumes](https://docs.databricks.com/en/volumes/index.html) in a FastAPI application using the [Databricks Files API](https://docs.databricks.com/api/workspace/files) with OAuth authentication. - [FastAPI: Connect Databricks App to Databricks App](https://apps-cookbook.dev/docs/fastapi/getting_started/connections/connect_from_app.md): This recipe demonstrates how to connect from a Databricks App to an API hosted as another Databricks App. - [FastAPI: Connect external app to Databricks App](https://apps-cookbook.dev/docs/fastapi/getting_started/connections/connect_from_external.md): This recipe demonstrates how to connect from your externally hosted application to an API deployed as a Databricks App. - [FastAPI: Connect local machine to Databricks App](https://apps-cookbook.dev/docs/fastapi/getting_started/connections/connect_from_local.md): This recipe demonstrates how to connect from your local machine to an API deployed as a Databricks App. - [FastAPI: Connect to a FastAPI app](https://apps-cookbook.dev/docs/fastapi/getting_started/connections/index.md): There are several options to consider when connecting to a deployed Databricks App. - [FastAPI: Create a FastAPI app](https://apps-cookbook.dev/docs/fastapi/getting_started/create.md): This recipe demonstrates how to create a simple [FastAPI](https://fastapi.tiangolo.com/) application that can be deployed on Databricks Apps. - [FastAPI: Connect FastAPI to Lakebase](https://apps-cookbook.dev/docs/fastapi/getting_started/lakebase_connection.md): This guide demonstrates how to connect your FastAPI application to a Lakebase PostgreSQL database with automatic token refresh and connection pooling. Lakebase provides a managed PostgreSQL database instance within your Databricks workspace that seamlessly integrates with Unity Catalog. - [FastAPI: Test a FastAPI app](https://apps-cookbook.dev/docs/fastapi/getting_started/test.md): This recipe demonstrates how to test [FastAPI](https://fastapi.tiangolo.com/) applications using [Pytest](https://docs.pytest.org/en/stable/index.html). - [Introduction](https://apps-cookbook.dev/docs/intro.md): Welcome to the Databricks Apps Cookbook! - [Reflex: Connect an MCP server](https://apps-cookbook.dev/docs/reflex/aiml/mcp_connect.md): This recipe connects to an [MCP](https://modelcontextprotocol.io/overview) server for AI applications using GitHub as an example and Unity Catalog [HTTP connections](https://docs.databricks.com/aws/en/query-federation/http) for secure and governed access. - [Reflex: Invoke a model](https://apps-cookbook.dev/docs/reflex/aiml/ml_serving_invoke.md): This recipe invokes a model hosted on [Mosaic AI Model Serving](https://docs.databricks.com/aws/en/machine-learning/model-serving/) using the [Databricks SDK for Python](https://databricks-sdk-py.readthedocs.io/en/latest/) and returns the result. Choose either a traditional ML model or a large language model (LLM). - [Reflex: Run vector search](https://apps-cookbook.dev/docs/reflex/aiml/ml_vector_search.md): This recipe performs a vector search query on a [Mosaic AI Vector Search](https://docs.databricks.com/aws/en/generative-ai/vector-search) index using the [Databricks SDK for Python](https://databricks-sdk-py.readthedocs.io/en/latest/). - [Reflex: Retrieve a secret](https://apps-cookbook.dev/docs/reflex/authentication/secrets_retrieve.md): This recipe retrieves a [Databricks secret](https://docs.databricks.com/en/security/secrets/index.html). Use secrets to securely connect to external services and APIs. - [Reflex: Get current user](https://apps-cookbook.dev/docs/reflex/authentication/users_get_current.md): This recipe gets information about the user accessing this Databricks App from their [HTTP headers](https://docs.databricks.com/en/dev-tools/databricks-apps/app-development.html#what-http-headers-are-passed-to-databricks-apps). - [Reflex: On-behalf-of-user authentication](https://apps-cookbook.dev/docs/reflex/authentication/users_obo.md): This recipe demonstrates how to use Databricks Apps [on-behalf-of-user authentication](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/app-development#-using-the-databricks-apps-authorization-model) to run a SQL query using the user's credentials instead of the app's service principal. - [Reflex: Embed a dashboard](https://apps-cookbook.dev/docs/reflex/bi/embed_dashboard.md): This recipe embeds a [Databricks AI/BI dashboard](https://docs.databricks.com/aws/en/dashboards/) into a Databricks App. - [Reflex: Chat with a Genie Space](https://apps-cookbook.dev/docs/reflex/bi/genie_api.md): This app uses the [AI/BI Genie](https://www.databricks.com/product/ai-bi) [Conversations API](https://docs.databricks.com/api/workspace/genie) to let users ask questions about your data for instant insights. - [Reflex: Connect to a cluster](https://apps-cookbook.dev/docs/reflex/compute/compute_connect.md): This recipe uses [Databricks Connect](https://docs.databricks.com/en/dev-tools/databricks-connect/python/index.html) to execute pre-defined Python or SQL code on a **shared** cluster with UI inputs. - [Reflex: External connections](https://apps-cookbook.dev/docs/reflex/external_services/external_connections.md): This recipe demonstrates how to use Unity Catalog-managed external [HTTP connections](https://docs.databricks.com/aws/en/query-federation/http) for secure and governed access to MCP and non-MCP servers, for example, to GitHub, or Jira, and Slack. - [Reflex: Connect an OLTP database](https://apps-cookbook.dev/docs/reflex/tables/oltp_database_connect.md): This app connects to a [Databricks Lakebase](https://docs.databricks.com/aws/en/oltp/) OLTP database instance for reads and writes, e.g., of an App state. Provide the instance name, database, schema, and state table. - [Reflex: Edit a Delta table](https://apps-cookbook.dev/docs/reflex/tables/tables_edit.md): Use this recipe to read, edit, and write back data in a [Unity Catalog table](https://docs.databricks.com/aws/en/tables/) using the [Databricks SQL Connector](https://docs.databricks.com/en/dev-tools/python-sql-connector.html). - [Reflex: Read a Delta table](https://apps-cookbook.dev/docs/reflex/tables/tables_read.md): This recipe reads a [Unity Catalog table](https://docs.databricks.com/aws/en/tables/) using the [Databricks SQL Connector](https://docs.databricks.com/en/dev-tools/python-sql-connector.html). - [Reflex: Download a file](https://apps-cookbook.dev/docs/reflex/volumes/volumes_download.md): This recipe downloads a file from a [Unity Catalog volume](https://docs.databricks.com/en/volumes/index.html) using the [Databricks SDK for Python](https://databricks-sdk-py.readthedocs.io/en/latest/). - [Reflex: Upload a file](https://apps-cookbook.dev/docs/reflex/volumes/volumes_upload.md): This recipe uploads a file to a [Unity Catalog volume](https://docs.databricks.com/en/volumes/index.html) using the [Databricks SDK for Python](https://databricks-sdk-py.readthedocs.io/en/latest/). - [Reflex: Retrieve workflow results](https://apps-cookbook.dev/docs/reflex/workflows/workflows_get_results.md): This recipe retrieves the results of a [Databricks Workflows](https://docs.databricks.com/en/jobs/index.html) job run using the [Databricks SDK for Python](https://databricks-sdk-py.readthedocs.io/en/latest/). - [Reflex: Run a workflow](https://apps-cookbook.dev/docs/reflex/workflows/workflows_run.md): This recipe triggers a [Databricks Workflows](https://docs.databricks.com/en/jobs/index.html) job using the [Databricks SDK for Python](https://databricks-sdk-py.readthedocs.io/en/latest/). - [Streamlit: Connect an MCP server](https://apps-cookbook.dev/docs/streamlit/aiml/mcp_connect.md): This recipe connects to an [MCP](https://modelcontextprotocol.io/overview) server for AI applications using GitHub as an example and Unity Catalog [HTTP connections](https://docs.databricks.com/aws/en/query-federation/http) for secure and governed access. - [Streamlit: Invoke a model](https://apps-cookbook.dev/docs/streamlit/aiml/ml_serving_invoke.md): This recipe invokes a model hosted on [Mosaic AI Model Serving](https://docs.databricks.com/aws/en/machine-learning/model-serving/) using the [Databricks SDK for Python](https://databricks-sdk-py.readthedocs.io/en/latest/) and returns the result. Choose either a traditional ML model or a large language model (LLM). - [Streamlit: Run vector search](https://apps-cookbook.dev/docs/streamlit/aiml/ml_vector_search.md): This recipe performs a vector search query on a [Mosaic AI Vector Search](https://docs.databricks.com/aws/en/generative-ai/vector-search) index using the [Databricks SDK for Python](https://databricks-sdk-py.readthedocs.io/en/latest/). - [Streamlit: Retrieve a secret](https://apps-cookbook.dev/docs/streamlit/authentication/secrets_retrieve.md): This recipe retrieves a [Databricks secret](https://docs.databricks.com/en/security/secrets/index.html). Use secrets to securely connect to external services and APIs. - [Streamlit: Get current user](https://apps-cookbook.dev/docs/streamlit/authentication/users_get_current.md): This recipe gets information about the user accessing this Databricks App from their [HTTP headers](https://docs.databricks.com/en/dev-tools/databricks-apps/app-development.html#what-http-headers-are-passed-to-databricks-apps). - [Streamlit: On-behalf-of-user authentication](https://apps-cookbook.dev/docs/streamlit/authentication/users_obo.md): This recipe demonstrates how to use Databricks Apps [on-behalf-of-user authentication](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/app-development#-using-the-databricks-apps-authorization-model) to run a SQL query using the user's credentials instead of the app's service principal. - [Streamlit: Embed a dashboard](https://apps-cookbook.dev/docs/streamlit/bi/embed_dashboard.md): This recipe embeds a [Databricks AI/BI dashboard](https://docs.databricks.com/aws/en/dashboards/) into a Databricks App. - [Streamlit: Chat with a Genie Space](https://apps-cookbook.dev/docs/streamlit/bi/genie_api.md): This app uses the [AI/BI Genie](https://www.databricks.com/product/ai-bi) [Conversations API](https://docs.databricks.com/api/workspace/genie) to let users ask questions about your data for instant insights (answers and table-like output). You are also able to collect their feedback on the responses. Visualizations aren't yet supported in the API. - [Streamlit: Connect to a cluster](https://apps-cookbook.dev/docs/streamlit/compute/compute_connect.md): This recipe uses [Databricks Connect](https://docs.databricks.com/en/dev-tools/databricks-connect/python/index.html) to execute pre-defined Python or SQL code on a **shared** cluster with UI inputs. - [Streamlit: External connections](https://apps-cookbook.dev/docs/streamlit/external_services/external_connections.md): This recipe demonstrates how to use Unity Catalog-managed external [HTTP connections](https://docs.databricks.com/aws/en/query-federation/http) for secure and governed access to MCP and non-MCP servers, for example, to GitHub, or Jira, and Slack. - [Streamlit: Read a Lakebase table](https://apps-cookbook.dev/docs/streamlit/tables/lakebase_read.md): This app connects to a [Databricks Lakebase](https://docs.databricks.com/aws/en/oltp/) OLTP database instance and reads the first 100 rows from any table. Provide the instance name, database, schema, and table name. - [Streamlit: Edit a Delta table](https://apps-cookbook.dev/docs/streamlit/tables/tables_edit.md): Use this recipe to read, edit, and write back data in a [Unity Catalog table](https://docs.databricks.com/aws/en/tables/) using the [Databricks SQL Connector](https://docs.databricks.com/en/dev-tools/python-sql-connector.html). - [Streamlit: Read a Delta table](https://apps-cookbook.dev/docs/streamlit/tables/tables_read.md): This recipe reads a [Unity Catalog table](https://docs.databricks.com/aws/en/tables/) using the [Databricks SQL Connector](https://docs.databricks.com/en/dev-tools/python-sql-connector.html). - [Streamlit: Charts](https://apps-cookbook.dev/docs/streamlit/visualizations/visualizations_charts.md): Use this recipe to visualize data using Streamlit's built-in chart components: area charts, line charts, and bar charts. This example demonstrates loading data from a Unity Catalog table and creating various business insights through different chart visualizations. - [Streamlit: Map display and interaction](https://apps-cookbook.dev/docs/streamlit/visualizations/visualizations_map.md): This recipe enables you to display geographic data on a map and collect user geo input through interactive map drawing. You can load location data from Unity Catalog tables or use the drawing tools to capture points, polygons, and geofences from users. - [Streamlit: Download a file](https://apps-cookbook.dev/docs/streamlit/volumes/volumes_download.md): This recipe downloads a file from a [Unity Catalog volume](https://docs.databricks.com/en/volumes/index.html) using the [Databricks SDK for Python](https://databricks-sdk-py.readthedocs.io/en/latest/). - [Streamlit: Upload a file](https://apps-cookbook.dev/docs/streamlit/volumes/volumes_upload.md): This recipe uploads a file to a [Unity Catalog volume](https://docs.databricks.com/en/volumes/index.html) using the [Databricks SDK for Python](https://databricks-sdk-py.readthedocs.io/en/latest/). - [Streamlit: Retrieve workflow results](https://apps-cookbook.dev/docs/streamlit/workflows/workflows_get_results.md): This recipe retreives the results of a [Databricks Workflows](https://docs.databricks.com/en/jobs/index.html) job task run using the [Databricks SDK for Python](https://databricks-sdk-py.readthedocs.io/en/latest/).. - [Streamlit: Run a workflow](https://apps-cookbook.dev/docs/streamlit/workflows/workflows_run.md): This recipe triggers a [Databricks Workflows](https://docs.databricks.com/en/jobs/index.html) job using the [Databricks SDK for Python](https://databricks-sdk-py.readthedocs.io/en/latest/).