Gradio Agents & MCP Hackathon
WinnersGradio Agents & MCP Hackathon
Winners →Getting Started
QuickstartBuilding Interfaces
The Interface ClassMore On ExamplesFlaggingInterface StateReactive InterfacesFour Kinds Of InterfacesBuilding With Blocks
Blocks And Event ListenersControlling LayoutState In BlocksDynamic Apps With Render DecoratorMore Blocks FeaturesCustom CSS And JSUsing Blocks Like FunctionsAdditional Features
QueuingStreaming OutputsStreaming InputsAlertsProgress BarsBatch FunctionsSharing Your AppFile AccessMultipage AppsEnvironment VariablesResource CleanupThemesClient Side FunctionsView Api PageInternationalizationChatbots
Creating A Chatbot FastChatinterface ExamplesAgents And Tool UsageCreating A Custom Chatbot With BlocksChatbot Specific EventsCreating A Discord Bot From A Gradio AppCreating A Slack Bot From A Gradio AppCreating A Website Widget From A Gradio ChatbotData Science And Plots
Creating PlotsTime PlotsFilters Tables And StatsConnecting To A DatabaseStreaming
Streaming Ai Generated AudioObject Detection From Webcam With WebrtcObject Detection From VideoConversational ChatbotReal Time Speech RecognitionAutomatic Voice DetectionCustom Components
Custom Components In Five MinutesKey Component ConceptsConfigurationBackendFrontendFrequently Asked QuestionsPdf Component ExampleMultimodal Chatbot Part1Documenting Custom ComponentsGradio Clients And Lite
Getting Started With The Python ClientGetting Started With The Js ClientQuerying Gradio Apps With CurlGradio And Llm AgentsGradio LiteGradio Lite And Transformers JsFastapi App With The Gradio ClientMcp
Building Mcp Server With GradioFile Upload McpBuilding An Mcp Client With GradioUsing Docs McpOther Tutorials
Using Hugging Face IntegrationsGradio And CometGradio And ONNX On Hugging FaceGradio And Wandb IntegrationCreate Your Own Friends With A GanCreating A Dashboard From Bigquery DataCreating A Dashboard From Supabase DataCreating A Realtime Dashboard From Google SheetsDeploying Gradio With DiscoDeploying Gradio With DockerDeveloping Faster With Reload ModeFrom Openapi SpecHow To Use 3D Model ComponentImage Classification In PytorchImage Classification With Vision TransformersInstalling Gradio In A Virtual EnvironmentNamed Entity RecognitionPlot Component For MapsRunning Background TasksRunning Gradio On Your Web Server With NginxSetting Up A Demo For Maximum PerformanceStyling The Gradio DataframeTheming GuideUnderstanding Gradio Share LinksUsing FlaggingUsing Gradio For Tabular WorkflowsUsing Gradio In Other Programming LanguagesWrapping LayoutsEnvironment variables in Gradio provide a way to customize your applications and launch settings without changing the codebase. In this guide, we'll explore the key environment variables supported in Gradio and how to set them.
GRADIO_SERVER_PORT
7860
export GRADIO_SERVER_PORT=8000
GRADIO_SERVER_NAME
"0.0.0.0"
"127.0.0.1"
export GRADIO_SERVER_NAME="0.0.0.0"
GRADIO_NUM_PORTS
100
export GRADIO_NUM_PORTS=200
GRADIO_ANALYTICS_ENABLED
"True"
"True"
, "False"
export GRADIO_ANALYTICS_ENABLED="True"
GRADIO_DEBUG
0
export GRADIO_DEBUG=1
GRADIO_FLAGGING_MODE
"manual"
"never"
, "manual"
, "auto"
export GRADIO_FLAGGING_MODE="never"
GRADIO_TEMP_DIR
export GRADIO_TEMP_DIR="/path/to/temp"
GRADIO_ROOT_PATH
""
export GRADIO_ROOT_PATH="/myapp"
GRADIO_SHARE
"False"
"True"
, "False"
export GRADIO_SHARE="True"
GRADIO_ALLOWED_PATHS
""
export GRADIO_ALLOWED_PATHS="/mnt/sda1,/mnt/sda2"
GRADIO_BLOCKED_PATHS
allowed_paths
and all other directories exposed by Gradio by default. Multiple items can be specified by separating items with commas.""
export GRADIO_BLOCKED_PATHS="/users/x/gradio_app/admin,/users/x/gradio_app/keys"
FORWARDED_ALLOW_IPS
uvicorn
which is used by Gradio internally. This environment variable is useful when deploying applications behind a reverse proxy. It defines a list of IP addresses that are trusted to forward traffic to your application. When set, the application will trust the X-Forwarded-For
header from these IP addresses to determine the original IP address of the user making the request. This means that if you use the gr.Request
object's client.host
property, it will correctly get the user's IP address instead of the IP address of the reverse proxy server. Note that only trusted IP addresses (i.e. the IP addresses of your reverse proxy servers) should be added, as any server with these IP addresses can modify the X-Forwarded-For
header and spoof the client's IP address."127.0.0.1"
export FORWARDED_ALLOW_IPS="127.0.0.1,192.168.1.100"
GRADIO_CACHE_EXAMPLES
gr.Interface()
, gr.ChatInterface()
or in gr.Examples()
when no explicit argument is passed for the cache_examples
parameter. You can set this environment variable to either the string "true" or "false"."false"
export GRADIO_CACHE_EXAMPLES="true"
GRADIO_CACHE_MODE
Description: How to cache examples. Only applies if cache_examples
is set to True
either via enviornment variable or by an explicit parameter, AND no no explicit argument is passed for the cache_mode
parameter in gr.Interface()
, gr.ChatInterface()
or in gr.Examples()
. Can be set to either the strings "lazy" or "eager." If "lazy", examples are cached after their first use for all users of the app. If "eager", all examples are cached at app launch.
Default: "eager"
Example:
export GRADIO_CACHE_MODE="lazy"
GRADIO_EXAMPLES_CACHE
cache_examples=True
in gr.Interface()
, gr.ChatInterface()
or in gr.Examples()
, Gradio will run your prediction function and save the results to disk. By default, this is in the .gradio/cached_examples//
subdirectory within your app's working directory. You can customize the location of cached example files created by Gradio by setting the environment variable GRADIO_EXAMPLES_CACHE
to an absolute path or a path relative to your working directory.".gradio/cached_examples/"
export GRADIO_EXAMPLES_CACHE="custom_cached_examples/"
GRADIO_SSR_MODE
Description: Controls whether server-side rendering (SSR) is enabled. When enabled, the initial HTML is rendered on the server rather than the client, which can improve initial page load performance and SEO.
Default: "False"
(except on Hugging Face Spaces, where this environment variable sets it to True
)
Options: "True"
, "False"
Example:
export GRADIO_SSR_MODE="True"
GRADIO_NODE_SERVER_NAME
ssr_mode
is set to True
.)GRADIO_SERVER_NAME
if it is set, otherwise "127.0.0.1"
export GRADIO_NODE_SERVER_NAME="0.0.0.0"
GRADIO_NODE_NUM_PORTS
ssr_mode
is set to True
.)100
export GRADIO_NODE_NUM_PORTS=200
GRADIO_RESET_EXAMPLES_CACHE
"False"
"True"
, "False"
export GRADIO_RESET_EXAMPLES_CACHE="True"
GRADIO_CHAT_FLAGGING_MODE
gr.ChatInterface
applications. Similar to GRADIO_FLAGGING_MODE
but specifically for chat interfaces."never"
"never"
, "manual"
export GRADIO_CHAT_FLAGGING_MODE="manual"
To set environment variables in your terminal, use the export
command followed by the variable name and its value. For example:
export GRADIO_SERVER_PORT=8000
If you're using a .env
file to manage your environment variables, you can add them like this:
GRADIO_SERVER_PORT=8000
GRADIO_SERVER_NAME="localhost"
Then, use a tool like dotenv
to load these variables when running your application.