diff --git a/homeassistant/components/tts/__init__.py b/homeassistant/components/tts/__init__.py
index 2ec9a2ab801d6259b604adf9c53b9072575066a9..e5eef0e613519bcc154055b6d9c2e60be05591a2 100644
--- a/homeassistant/components/tts/__init__.py
+++ b/homeassistant/components/tts/__init__.py
@@ -43,6 +43,7 @@ CONF_CACHE = 'cache'
 CONF_CACHE_DIR = 'cache_dir'
 CONF_LANG = 'language'
 CONF_TIME_MEMORY = 'time_memory'
+CONF_BASE_URL = 'base_url'
 
 DEFAULT_CACHE = True
 DEFAULT_CACHE_DIR = 'tts'
@@ -65,6 +66,7 @@ PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({
     vol.Optional(CONF_CACHE_DIR, default=DEFAULT_CACHE_DIR): cv.string,
     vol.Optional(CONF_TIME_MEMORY, default=DEFAULT_TIME_MEMORY):
         vol.All(vol.Coerce(int), vol.Range(min=60, max=57600)),
+    vol.Optional(CONF_BASE_URL): cv.string,
 })
 
 SCHEMA_SERVICE_SAY = vol.Schema({
@@ -87,8 +89,9 @@ async def async_setup(hass, config):
         use_cache = conf.get(CONF_CACHE, DEFAULT_CACHE)
         cache_dir = conf.get(CONF_CACHE_DIR, DEFAULT_CACHE_DIR)
         time_memory = conf.get(CONF_TIME_MEMORY, DEFAULT_TIME_MEMORY)
+        base_url = conf.get(CONF_BASE_URL) or hass.config.api.base_url
 
-        await tts.async_init_cache(use_cache, cache_dir, time_memory)
+        await tts.async_init_cache(use_cache, cache_dir, time_memory, base_url)
     except (HomeAssistantError, KeyError) as err:
         _LOGGER.error("Error on cache init %s", err)
         return False
@@ -180,13 +183,16 @@ class SpeechManager:
         self.use_cache = DEFAULT_CACHE
         self.cache_dir = DEFAULT_CACHE_DIR
         self.time_memory = DEFAULT_TIME_MEMORY
+        self.base_url = None
         self.file_cache = {}
         self.mem_cache = {}
 
-    async def async_init_cache(self, use_cache, cache_dir, time_memory):
+    async def async_init_cache(self, use_cache, cache_dir, time_memory,
+                               base_url):
         """Init config folder and load file cache."""
         self.use_cache = use_cache
         self.time_memory = time_memory
+        self.base_url = base_url
 
         def init_tts_cache_dir(cache_dir):
             """Init cache folder."""
@@ -299,8 +305,7 @@ class SpeechManager:
             filename = await self.async_get_tts_audio(
                 engine, key, message, use_cache, language, options)
 
-        return "{}/api/tts_proxy/{}".format(
-            self.hass.config.api.base_url, filename)
+        return "{}/api/tts_proxy/{}".format(self.base_url, filename)
 
     async def async_get_tts_audio(
             self, engine, key, message, cache, language, options):
diff --git a/tests/components/tts/test_init.py b/tests/components/tts/test_init.py
index 719fe2716e774b9a1de26b27c7743d55af56c6ba..70cbbc15c91bfa423e1fc8c9447d980e123e3526 100644
--- a/tests/components/tts/test_init.py
+++ b/tests/components/tts/test_init.py
@@ -97,10 +97,9 @@ class TestTTS:
 
         assert len(calls) == 1
         assert calls[0].data[ATTR_MEDIA_CONTENT_TYPE] == MEDIA_TYPE_MUSIC
-        assert calls[0].data[ATTR_MEDIA_CONTENT_ID].find(
-            "/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd"
-            "_en_-_demo.mp3") \
-            != -1
+        assert calls[0].data[ATTR_MEDIA_CONTENT_ID] == \
+            "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" \
+            "_en_-_demo.mp3".format(self.hass.config.api.base_url)
         assert os.path.isfile(os.path.join(
             self.default_tts_cache,
             "265944c108cbb00b2a621be5930513e03a0bb2cd_en_-_demo.mp3"))
@@ -126,10 +125,9 @@ class TestTTS:
 
         assert len(calls) == 1
         assert calls[0].data[ATTR_MEDIA_CONTENT_TYPE] == MEDIA_TYPE_MUSIC
-        assert calls[0].data[ATTR_MEDIA_CONTENT_ID].find(
-            "/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd"
-            "_de_-_demo.mp3") \
-            != -1
+        assert calls[0].data[ATTR_MEDIA_CONTENT_ID] == \
+            "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" \
+            "_de_-_demo.mp3".format(self.hass.config.api.base_url)
         assert os.path.isfile(os.path.join(
             self.default_tts_cache,
             "265944c108cbb00b2a621be5930513e03a0bb2cd_de_-_demo.mp3"))
@@ -167,10 +165,9 @@ class TestTTS:
 
         assert len(calls) == 1
         assert calls[0].data[ATTR_MEDIA_CONTENT_TYPE] == MEDIA_TYPE_MUSIC
-        assert calls[0].data[ATTR_MEDIA_CONTENT_ID].find(
-            "/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd"
-            "_de_-_demo.mp3") \
-            != -1
+        assert calls[0].data[ATTR_MEDIA_CONTENT_ID] == \
+            "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" \
+            "_de_-_demo.mp3".format(self.hass.config.api.base_url)
         assert os.path.isfile(os.path.join(
             self.default_tts_cache,
             "265944c108cbb00b2a621be5930513e03a0bb2cd_de_-_demo.mp3"))
@@ -225,10 +222,9 @@ class TestTTS:
 
         assert len(calls) == 1
         assert calls[0].data[ATTR_MEDIA_CONTENT_TYPE] == MEDIA_TYPE_MUSIC
-        assert calls[0].data[ATTR_MEDIA_CONTENT_ID].find(
-            "/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd"
-            "_de_{0}_demo.mp3".format(opt_hash)) \
-            != -1
+        assert calls[0].data[ATTR_MEDIA_CONTENT_ID] == \
+            "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" \
+            "_de_{}_demo.mp3".format(self.hass.config.api.base_url, opt_hash)
         assert os.path.isfile(os.path.join(
             self.default_tts_cache,
             "265944c108cbb00b2a621be5930513e03a0bb2cd_de_{0}_demo.mp3".format(
@@ -259,10 +255,9 @@ class TestTTS:
 
         assert len(calls) == 1
         assert calls[0].data[ATTR_MEDIA_CONTENT_TYPE] == MEDIA_TYPE_MUSIC
-        assert calls[0].data[ATTR_MEDIA_CONTENT_ID].find(
-            "/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd"
-            "_de_{0}_demo.mp3".format(opt_hash)) \
-            != -1
+        assert calls[0].data[ATTR_MEDIA_CONTENT_ID] == \
+            "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" \
+            "_de_{}_demo.mp3".format(self.hass.config.api.base_url, opt_hash)
         assert os.path.isfile(os.path.join(
             self.default_tts_cache,
             "265944c108cbb00b2a621be5930513e03a0bb2cd_de_{0}_demo.mp3".format(
@@ -298,6 +293,32 @@ class TestTTS:
             "265944c108cbb00b2a621be5930513e03a0bb2cd_de_{0}_demo.mp3".format(
                 opt_hash)))
 
+    def test_setup_component_and_test_service_with_base_url_set(self):
+        """Set up the demo platform with ``base_url`` set and call service."""
+        calls = mock_service(self.hass, DOMAIN_MP, SERVICE_PLAY_MEDIA)
+
+        config = {
+            tts.DOMAIN: {
+                'platform': 'demo',
+                'base_url': 'http://fnord',
+            }
+        }
+
+        with assert_setup_component(1, tts.DOMAIN):
+            setup_component(self.hass, tts.DOMAIN, config)
+
+        self.hass.services.call(tts.DOMAIN, 'demo_say', {
+            tts.ATTR_MESSAGE: "I person is on front of your door.",
+        })
+        self.hass.block_till_done()
+
+        assert len(calls) == 1
+        assert calls[0].data[ATTR_MEDIA_CONTENT_TYPE] == MEDIA_TYPE_MUSIC
+        assert calls[0].data[ATTR_MEDIA_CONTENT_ID] == \
+            "http://fnord" \
+            "/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" \
+            "_en_-_demo.mp3"
+
     def test_setup_component_and_test_service_clear_cache(self):
         """Set up the demo platform and call service clear cache."""
         calls = mock_service(self.hass, DOMAIN_MP, SERVICE_PLAY_MEDIA)
@@ -507,10 +528,9 @@ class TestTTS:
         self.hass.block_till_done()
 
         assert len(calls) == 1
-        assert calls[0].data[ATTR_MEDIA_CONTENT_ID].find(
-            "/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd"
-            "_en_-_demo.mp3") \
-            != -1
+        assert calls[0].data[ATTR_MEDIA_CONTENT_ID] == \
+            "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" \
+            "_en_-_demo.mp3".format(self.hass.config.api.base_url)
 
     @patch('homeassistant.components.tts.demo.DemoProvider.get_tts_audio',
            return_value=(None, None))