Skip to content

Commit 11c0c3d

Browse files
committed
added image deployment key
1 parent 501e949 commit 11c0c3d

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

.github/workflows/azure-container-api.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ jobs:
6565
"APPINSIGHTS_CONNECTIONSTRING=secretref:appinsights-connectionstring" \
6666
"COSMOSDB_CONNECTION=secretref:cosmosdb-connection" \
6767
"FOUNDRY_CONNECTION=secretref:foundry-connection" \
68+
"AZURE_IMAGE_DEPLOYMENT=secretref:azure-image-deployment" \
6869
"AZURE_IMAGE_ENDPOINT=secretref:azure-image-endpoint" \
6970
"AZURE_IMAGE_API_KEY=secretref:azure-image-api-key" \
7071
"SUSTINEO_STORAGE=secretref:sustineo-storage" \

api/agent/agents.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from api.agent.common import execute_foundry_agent, post_request
1515

1616

17+
AZURE_IMAGE_DEPLOYMENT = os.environ.get("AZURE_IMAGE_DEPLOYMENT", "EMPTY")
1718
AZURE_IMAGE_ENDPOINT = os.environ.get("AZURE_IMAGE_ENDPOINT", "EMPTY").rstrip("/")
1819
AZURE_IMAGE_API_KEY = os.environ.get("AZURE_IMAGE_API_KEY", "EMPTY")
1920
AZURE_SORA_ENDPOINT = os.environ.get("AZURE_SORA_ENDPOINT", "EMPTY").rstrip("/")
@@ -24,7 +25,7 @@
2425

2526
@agent(
2627
name="Image Generation Agent",
27-
description="This agent can generate a number of images based upon a detailed description. This agent is based on the GPT-Image-1 model and is capable of generating images in a variety of styles. It can also generate images in a specific style, such as a painting or a photograph. The agent can also generate images with different levels of detail and complexity.",
28+
description="This agent can generate a number of images based upon a detailed description. This agent is based on a powerful image model and is capable of generating images in a variety of styles. It can also generate images in a specific style, such as a painting or a photograph. The agent can also generate images with different levels of detail and complexity.",
2829
)
2930
async def gpt_image_generation(
3031
description: Annotated[
@@ -44,8 +45,7 @@ async def gpt_image_generation(
4445
size: str = "1024x1024"
4546
quality: str = "low"
4647
api_version = "2025-04-01-preview"
47-
deployment_name = "gpt-image-1"
48-
endpoint = f"{AZURE_IMAGE_ENDPOINT}/openai/deployments/{deployment_name}/images/generations?api-version={api_version}"
48+
endpoint = f"{AZURE_IMAGE_ENDPOINT}/openai/deployments/{AZURE_IMAGE_DEPLOYMENT}/images/generations?api-version={api_version}"
4949

5050
await notify(
5151
id="image_generation", status="step in_progress", information="Executing Model"
@@ -243,8 +243,7 @@ async def gpt_image_edit(
243243
)
244244

245245
api_version = "2025-04-01-preview"
246-
deployment_name = "gpt-image-1"
247-
endpoint = f"{AZURE_IMAGE_ENDPOINT}/openai/deployments/{deployment_name}/images/edits?api-version={api_version}"
246+
endpoint = f"{AZURE_IMAGE_ENDPOINT}/openai/deployments/{AZURE_IMAGE_DEPLOYMENT}/images/edits?api-version={api_version}"
248247

249248
await notify(
250249
id="image_edit", status="step in_progress", information="Executing Model"

api/tools/image/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from api.storage import save_image_blob
1212

13+
AZURE_IMAGE_DEPLOYMENT = os.environ.get("AZURE_IMAGE_DEPLOYMENT", "EMPTY")
1314
AZURE_IMAGE_ENDPOINT = os.environ.get("AZURE_IMAGE_ENDPOINT", "EMPTY").rstrip("/")
1415
AZURE_IMAGE_API_KEY = os.environ.get("AZURE_IMAGE_API_KEY", "EMPTY")
1516
BASE_URL = os.environ.get("BASE_URL", "http://localhost:8000").rstrip("/")
@@ -82,8 +83,7 @@ class ImageCreateRequest(BaseModel):
8283
)
8384
async def create_image(request: ImageCreateRequest) -> ImageResponse:
8485
api_version = "2025-04-01-preview"
85-
deployment_name = "gpt-image-1"
86-
endpoint = f"{AZURE_IMAGE_ENDPOINT}/openai/deployments/{deployment_name}/images/edits?api-version={api_version}"
86+
endpoint = f"{AZURE_IMAGE_ENDPOINT}/openai/deployments/{AZURE_IMAGE_DEPLOYMENT}/images/edits?api-version={api_version}"
8787
size: str = "1024x1024"
8888
quality: str = "low"
8989

@@ -110,7 +110,7 @@ async def create_image(request: ImageCreateRequest) -> ImageResponse:
110110

111111
async with aiohttp.ClientSession() as session:
112112
headers = {
113-
"api-key": AZURE_IMAGE_API_KEY,
113+
"Authorization": f"Bearer {AZURE_IMAGE_API_KEY}",
114114
}
115115

116116
form_data = aiohttp.FormData()

0 commit comments

Comments
 (0)