Repository: tensorzero/tensorzero (language: rust)

Issue:
Include `host-gateway` in `docker-compose.yml`
```
extra_hosts:
      - "host.docker.internal:host-gateway"
```

https://medium.com/@TimvanBaarsen/how-to-connect-to-the-docker-host-from-inside-a-docker-container-112b4c71bc66
https://stackoverflow.com/questions/48546124/what-is-the-linux-equivalent-of-host-docker-internal



Discussion / hints:
We should consider adding that block to our files that involve Ollama etc.
Just like https://github.com/tensorzero/tensorzero/blob/main/examples/production-deployment/docker-compose.yml

Fix patch:
diff --git a/examples/babyai/docker-compose.yml b/examples/babyai/docker-compose.yml
index 6d04ee30b..188a7785a 100644
--- a/examples/babyai/docker-compose.yml
+++ b/examples/babyai/docker-compose.yml
@@ -23,6 +23,8 @@ services:
       - OPENAI_API_KEY=${OPENAI_API_KEY:?Environment variable OPENAI_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
     depends_on:
       clickhouse:
         condition: service_healthy
diff --git a/examples/chess-puzzles-best-of-n-sampling/docker-compose.yml b/examples/chess-puzzles-best-of-n-sampling/docker-compose.yml
index 9bd35ce4e..633803991 100644
--- a/examples/chess-puzzles-best-of-n-sampling/docker-compose.yml
+++ b/examples/chess-puzzles-best-of-n-sampling/docker-compose.yml
@@ -30,6 +30,8 @@ services:
       - ${ENV_FILE:-.env}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
     depends_on:
       clickhouse:
         condition: service_healthy
diff --git a/examples/chess-puzzles-mixture-of-n-sampling/docker-compose.yml b/examples/chess-puzzles-mixture-of-n-sampling/docker-compose.yml
index 1a4abb2c6..bd58d159a 100644
--- a/examples/chess-puzzles-mixture-of-n-sampling/docker-compose.yml
+++ b/examples/chess-puzzles-mixture-of-n-sampling/docker-compose.yml
@@ -30,6 +30,8 @@ services:
       - ${ENV_FILE:-.env}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
     depends_on:
       clickhouse:
         condition: service_healthy
diff --git a/examples/data-extraction-ner/docker-compose.yml b/examples/data-extraction-ner/docker-compose.yml
index 699ba05ef..ce93d484f 100644
--- a/examples/data-extraction-ner/docker-compose.yml
+++ b/examples/data-extraction-ner/docker-compose.yml
@@ -30,6 +30,8 @@ services:
       - ${ENV_FILE:-.env}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
     depends_on:
       clickhouse:
         condition: service_healthy
diff --git a/examples/gsm8k-custom-recipe-dspy/docker-compose.yml b/examples/gsm8k-custom-recipe-dspy/docker-compose.yml
index 699ba05ef..ce93d484f 100644
--- a/examples/gsm8k-custom-recipe-dspy/docker-compose.yml
+++ b/examples/gsm8k-custom-recipe-dspy/docker-compose.yml
@@ -30,6 +30,8 @@ services:
       - ${ENV_FILE:-.env}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
     depends_on:
       clickhouse:
         condition: service_healthy
diff --git a/examples/guides/batch-inference/docker-compose.yml b/examples/guides/batch-inference/docker-compose.yml
index 8350520dd..512b2d7ab 100644
--- a/examples/guides/batch-inference/docker-compose.yml
+++ b/examples/guides/batch-inference/docker-compose.yml
@@ -26,6 +26,8 @@ services:
       - OPENAI_API_KEY=${OPENAI_API_KEY:?Environment variable OPENAI_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
     depends_on:
       clickhouse:
         condition: service_healthy
diff --git a/examples/guides/episodes/docker-compose.yml b/examples/guides/episodes/docker-compose.yml
index 8350520dd..512b2d7ab 100644
--- a/examples/guides/episodes/docker-compose.yml
+++ b/examples/guides/episodes/docker-compose.yml
@@ -26,6 +26,8 @@ services:
       - OPENAI_API_KEY=${OPENAI_API_KEY:?Environment variable OPENAI_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
     depends_on:
       clickhouse:
         condition: service_healthy
diff --git a/examples/guides/metrics-feedback/docker-compose.yml b/examples/guides/metrics-feedback/docker-compose.yml
index 8350520dd..512b2d7ab 100644
--- a/examples/guides/metrics-feedback/docker-compose.yml
+++ b/examples/guides/metrics-feedback/docker-compose.yml
@@ -26,6 +26,8 @@ services:
       - OPENAI_API_KEY=${OPENAI_API_KEY:?Environment variable OPENAI_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
     depends_on:
       clickhouse:
         condition: service_healthy
diff --git a/examples/guides/prompts-templates-schemas/docker-compose.yml b/examples/guides/prompts-templates-schemas/docker-compose.yml
index 8350520dd..512b2d7ab 100644
--- a/examples/guides/prompts-templates-schemas/docker-compose.yml
+++ b/examples/guides/prompts-templates-schemas/docker-compose.yml
@@ -26,6 +26,8 @@ services:
       - OPENAI_API_KEY=${OPENAI_API_KEY:?Environment variable OPENAI_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
     depends_on:
       clickhouse:
         condition: service_healthy
diff --git a/examples/guides/providers/anthropic/docker-compose.yml b/examples/guides/providers/anthropic/docker-compose.yml
index cbc7c8e78..280ffd2fd 100644
--- a/examples/guides/providers/anthropic/docker-compose.yml
+++ b/examples/guides/providers/anthropic/docker-compose.yml
@@ -10,3 +10,5 @@ services:
       - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:?Environment variable ANTHROPIC_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
diff --git a/examples/guides/providers/azure/docker-compose.yml b/examples/guides/providers/azure/docker-compose.yml
index 75ee9d0bf..4cada1bad 100644
--- a/examples/guides/providers/azure/docker-compose.yml
+++ b/examples/guides/providers/azure/docker-compose.yml
@@ -10,3 +10,5 @@ services:
       - AZURE_OPENAI_API_KEY=${AZURE_OPENAI_API_KEY:?Environment variable AZURE_OPENAI_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
diff --git a/examples/guides/providers/deepseek/docker-compose.yml b/examples/guides/providers/deepseek/docker-compose.yml
index b87daea15..5c76193a9 100644
--- a/examples/guides/providers/deepseek/docker-compose.yml
+++ b/examples/guides/providers/deepseek/docker-compose.yml
@@ -10,3 +10,5 @@ services:
       - DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY:?Environment variable DEEPSEEK_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
diff --git a/examples/guides/providers/fireworks/docker-compose.yml b/examples/guides/providers/fireworks/docker-compose.yml
index 5bc651154..5e44b4791 100644
--- a/examples/guides/providers/fireworks/docker-compose.yml
+++ b/examples/guides/providers/fireworks/docker-compose.yml
@@ -10,3 +10,5 @@ services:
       - FIREWORKS_API_KEY=${FIREWORKS_API_KEY:?Environment variable FIREWORKS_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
diff --git a/examples/guides/providers/gcp-vertex-ai-anthropic/docker-compose.yml b/examples/guides/providers/gcp-vertex-ai-anthropic/docker-compose.yml
index 7eacb7d54..b80ccac1f 100644
--- a/examples/guides/providers/gcp-vertex-ai-anthropic/docker-compose.yml
+++ b/examples/guides/providers/gcp-vertex-ai-anthropic/docker-compose.yml
@@ -11,3 +11,5 @@ services:
       - GCP_VERTEX_CREDENTIALS_PATH=${GCP_VERTEX_CREDENTIALS_PATH:+/app/gcp-credentials.json}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
diff --git a/examples/guides/providers/gcp-vertex-ai-gemini/docker-compose.yml b/examples/guides/providers/gcp-vertex-ai-gemini/docker-compose.yml
index 7eacb7d54..b80ccac1f 100644
--- a/examples/guides/providers/gcp-vertex-ai-gemini/docker-compose.yml
+++ b/examples/guides/providers/gcp-vertex-ai-gemini/docker-compose.yml
@@ -11,3 +11,5 @@ services:
       - GCP_VERTEX_CREDENTIALS_PATH=${GCP_VERTEX_CREDENTIALS_PATH:+/app/gcp-credentials.json}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
diff --git a/examples/guides/providers/google-ai-studio-gemini/docker-compose.yml b/examples/guides/providers/google-ai-studio-gemini/docker-compose.yml
index f3b6985b7..6788f715e 100644
--- a/examples/guides/providers/google-ai-studio-gemini/docker-compose.yml
+++ b/examples/guides/providers/google-ai-studio-gemini/docker-compose.yml
@@ -10,3 +10,5 @@ services:
       - GOOGLE_AI_STUDIO_API_KEY=${GOOGLE_AI_STUDIO_API_KEY:?Environment variable GOOGLE_AI_STUDIO_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
diff --git a/examples/guides/providers/hyperbolic/docker-compose.yml b/examples/guides/providers/hyperbolic/docker-compose.yml
index e0fc02882..8fc2f7ef9 100644
--- a/examples/guides/providers/hyperbolic/docker-compose.yml
+++ b/examples/guides/providers/hyperbolic/docker-compose.yml
@@ -10,3 +10,5 @@ services:
       - HYPERBOLIC_API_KEY=${HYPERBOLIC_API_KEY:?Environment variable HYPERBOLIC_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
diff --git a/examples/guides/providers/mistral/docker-compose.yml b/examples/guides/providers/mistral/docker-compose.yml
index 32de45e27..239ff8f6f 100644
--- a/examples/guides/providers/mistral/docker-compose.yml
+++ b/examples/guides/providers/mistral/docker-compose.yml
@@ -10,3 +10,5 @@ services:
       - MISTRAL_API_KEY=${MISTRAL_API_KEY:?Environment variable MISTRAL_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
diff --git a/examples/guides/providers/openai-compatible/docker-compose.yml b/examples/guides/providers/openai-compatible/docker-compose.yml
index ebe091e1c..8239d1292 100644
--- a/examples/guides/providers/openai-compatible/docker-compose.yml
+++ b/examples/guides/providers/openai-compatible/docker-compose.yml
@@ -7,6 +7,8 @@ services:
     volumes:
       - ./config:/app/config:ro
     # environment:
-      # - OLLAMA_API_KEY=${OLLAMA_API_KEY:?Environment variable OLLAMA_API_KEY must be set.}
+    #   - OLLAMA_API_KEY=${OLLAMA_API_KEY:?Environment variable OLLAMA_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
diff --git a/examples/guides/providers/openai/docker-compose.yml b/examples/guides/providers/openai/docker-compose.yml
index 75bb2e662..39863aae6 100644
--- a/examples/guides/providers/openai/docker-compose.yml
+++ b/examples/guides/providers/openai/docker-compose.yml
@@ -10,3 +10,5 @@ services:
       - OPENAI_API_KEY=${OPENAI_API_KEY:?Environment variable OPENAI_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
diff --git a/examples/guides/providers/together/docker-compose.yml b/examples/guides/providers/together/docker-compose.yml
index 9f92829b9..18a05b028 100644
--- a/examples/guides/providers/together/docker-compose.yml
+++ b/examples/guides/providers/together/docker-compose.yml
@@ -10,3 +10,5 @@ services:
       - TOGETHER_API_KEY=${TOGETHER_API_KEY:?Environment variable TOGETHER_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
diff --git a/examples/guides/providers/xai/docker-compose.yml b/examples/guides/providers/xai/docker-compose.yml
index 2c00ffd38..4e40dad1c 100644
--- a/examples/guides/providers/xai/docker-compose.yml
+++ b/examples/guides/providers/xai/docker-compose.yml
@@ -10,3 +10,5 @@ services:
       - XAI_API_KEY=${XAI_API_KEY:?Environment variable XAI_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
diff --git a/examples/guides/streaming-inference/docker-compose.yml b/examples/guides/streaming-inference/docker-compose.yml
index 8688339ae..72f2fa817 100644
--- a/examples/guides/streaming-inference/docker-compose.yml
+++ b/examples/guides/streaming-inference/docker-compose.yml
@@ -11,3 +11,5 @@ services:
       - OPENAI_API_KEY=${OPENAI_API_KEY:?Environment variable OPENAI_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
diff --git a/examples/haiku-hidden-preferences/docker-compose.yml b/examples/haiku-hidden-preferences/docker-compose.yml
index 699ba05ef..ce93d484f 100644
--- a/examples/haiku-hidden-preferences/docker-compose.yml
+++ b/examples/haiku-hidden-preferences/docker-compose.yml
@@ -30,6 +30,8 @@ services:
       - ${ENV_FILE:-.env}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
     depends_on:
       clickhouse:
         condition: service_healthy
diff --git a/examples/quickstart/docker-compose.yml b/examples/quickstart/docker-compose.yml
index 74c5d655b..42fff22d9 100644
--- a/examples/quickstart/docker-compose.yml
+++ b/examples/quickstart/docker-compose.yml
@@ -26,6 +26,8 @@ services:
       - OPENAI_API_KEY=${OPENAI_API_KEY:?Environment variable OPENAI_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
     depends_on:
       clickhouse:
         condition: service_healthy
diff --git a/examples/readme/docker-compose.yml b/examples/readme/docker-compose.yml
index 7512625bc..1512c71ff 100644
--- a/examples/readme/docker-compose.yml
+++ b/examples/readme/docker-compose.yml
@@ -23,6 +23,8 @@ services:
       - OPENAI_API_KEY=${OPENAI_API_KEY:?Environment variable OPENAI_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
     depends_on:
       clickhouse:
         condition: service_healthy
diff --git a/examples/tutorial/01-simple-chatbot/docker-compose.yml b/examples/tutorial/01-simple-chatbot/docker-compose.yml
index 8350520dd..512b2d7ab 100644
--- a/examples/tutorial/01-simple-chatbot/docker-compose.yml
+++ b/examples/tutorial/01-simple-chatbot/docker-compose.yml
@@ -26,6 +26,8 @@ services:
       - OPENAI_API_KEY=${OPENAI_API_KEY:?Environment variable OPENAI_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
     depends_on:
       clickhouse:
         condition: service_healthy
diff --git a/examples/tutorial/02-email-copilot/docker-compose.yml b/examples/tutorial/02-email-copilot/docker-compose.yml
index 067061af1..9dbdeca21 100644
--- a/examples/tutorial/02-email-copilot/docker-compose.yml
+++ b/examples/tutorial/02-email-copilot/docker-compose.yml
@@ -27,6 +27,8 @@ services:
       - OPENAI_API_KEY=${OPENAI_API_KEY:?Environment variable OPENAI_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
     depends_on:
       clickhouse:
         condition: service_healthy
diff --git a/examples/tutorial/03-weather-rag/docker-compose.yml b/examples/tutorial/03-weather-rag/docker-compose.yml
index 8350520dd..512b2d7ab 100644
--- a/examples/tutorial/03-weather-rag/docker-compose.yml
+++ b/examples/tutorial/03-weather-rag/docker-compose.yml
@@ -26,6 +26,8 @@ services:
       - OPENAI_API_KEY=${OPENAI_API_KEY:?Environment variable OPENAI_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
     depends_on:
       clickhouse:
         condition: service_healthy
diff --git a/examples/tutorial/04-email-data-extraction/docker-compose.yml b/examples/tutorial/04-email-data-extraction/docker-compose.yml
index 8350520dd..512b2d7ab 100644
--- a/examples/tutorial/04-email-data-extraction/docker-compose.yml
+++ b/examples/tutorial/04-email-data-extraction/docker-compose.yml
@@ -26,6 +26,8 @@ services:
       - OPENAI_API_KEY=${OPENAI_API_KEY:?Environment variable OPENAI_API_KEY must be set.}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
     depends_on:
       clickhouse:
         condition: service_healthy
diff --git a/ui/fixtures/docker-compose.yml b/ui/fixtures/docker-compose.yml
index 1aa0829d2..17dc8d083 100644
--- a/ui/fixtures/docker-compose.yml
+++ b/ui/fixtures/docker-compose.yml
@@ -34,6 +34,8 @@ services:
       - ${ENV_FILE:-../.env}
     ports:
       - "3000:3000"
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
     depends_on:
       clickhouse:
         condition: service_healthy


Test patch: