Skip to content

Commit f433e17

Browse files
committed
feat: rename BASE_URL to IMAGE_BASE_URL
1 parent bcd6f17 commit f433e17

3 files changed

Lines changed: 33 additions & 8 deletions

File tree

.env.example

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ GEMINI_API_KEY=
2626
# Path to store generated images
2727
STORAGE_PATH=./generated_images
2828

29-
# Base URL for serving images (e.g., http://localhost:8000 or https://api.example.com)
30-
BASE_URL=http://localhost:8000
29+
# IMPORTANT: URL where THIS API serves images (not Open WebUI or other services!)
30+
# This should be the URL where this image-generation API is accessible.
31+
# Examples:
32+
# - Local: http://localhost:8000
33+
# - Docker: http://openapi-image-gen:8000 (use container name)
34+
# - External: https://images.example.com
35+
IMAGE_BASE_URL=http://localhost:8000
3136

3237
# -----------------------------------------------------------------------------
3338
# Security (Optional)
@@ -36,8 +41,15 @@ BASE_URL=http://localhost:8000
3641
API_BEARER_TOKEN=
3742

3843
# -----------------------------------------------------------------------------
39-
# Model Registry
44+
# Model Configuration
4045
# -----------------------------------------------------------------------------
46+
# Default model for image generation (optional, uses first available if not set)
47+
# Examples: gemini/gemini-2.0-flash-exp-image-generation, dall-e-3, gpt-image-1
48+
DEFAULT_MODEL=
49+
50+
# Filter LiteLLM models to only show image generation models (default: true)
51+
FILTER_IMAGE_MODELS=true
52+
4153
# Cache TTL for model list in seconds (default: 3600 = 1 hour)
4254
MODEL_CACHE_TTL=3600
4355

app/services/storage_service.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ async def save_image(self, image_data: bytes, extension: str = "png") -> str:
3434

3535
relative_url = f"/images/{filename}"
3636

37-
if settings.BASE_URL:
38-
return f"{settings.BASE_URL.rstrip('/')}{relative_url}"
39-
return relative_url
37+
return f"{settings.IMAGE_BASE_URL.rstrip('/')}{relative_url}"
4038

4139

4240
storage_service = StorageService()

tests/test_storage_service.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ async def test_save_image(temp_storage):
1313
# Create service with temp storage
1414
with patch("app.services.storage_service.settings") as mock_settings:
1515
mock_settings.STORAGE_PATH = str(temp_storage)
16-
mock_settings.BASE_URL = "http://localhost:8000"
16+
mock_settings.IMAGE_BASE_URL = "http://localhost:8000"
1717

1818
service = StorageService()
1919

@@ -42,7 +42,7 @@ async def test_save_image_different_extensions(temp_storage):
4242
"""
4343
with patch("app.services.storage_service.settings") as mock_settings:
4444
mock_settings.STORAGE_PATH = str(temp_storage)
45-
mock_settings.BASE_URL = "http://localhost:8000"
45+
mock_settings.IMAGE_BASE_URL = "http://localhost:8000"
4646

4747
service = StorageService()
4848

@@ -53,3 +53,18 @@ async def test_save_image_different_extensions(temp_storage):
5353

5454
filename = url.split("/")[-1]
5555
assert (temp_storage / filename).exists()
56+
57+
58+
@pytest.mark.asyncio
59+
async def test_save_image_with_custom_base_url(temp_storage):
60+
"""
61+
Test that IMAGE_BASE_URL is used correctly.
62+
"""
63+
with patch("app.services.storage_service.settings") as mock_settings:
64+
mock_settings.STORAGE_PATH = str(temp_storage)
65+
mock_settings.IMAGE_BASE_URL = "http://image-api:8000"
66+
67+
service = StorageService()
68+
url = await service.save_image(b"test", "png")
69+
70+
assert url.startswith("http://image-api:8000/images/")

0 commit comments

Comments
 (0)