From e59ff376a41f7ca47b7541ad5c116495cbade3ee Mon Sep 17 00:00:00 2001 From: Penguin Secret Agency <155616440+PSA-Team-source@users.noreply.github.com> Date: Mon, 16 Nov 2026 11:10:03 +0700 Subject: [PATCH] feat(design): add optional UberLLM logo provider (#567) Co-authored-by: Clark Cant <127024890+clark-cant@users.noreply.github.com> --- .claude/skills/design/SKILL.md | 15 ++- .../skills/design/references/logo-design.md | 17 +++- .../skills/design/scripts/logo/generate.py | 99 ++++++++++++++++++- .../scripts/logo/tests/test_generate.py | 69 +++++++++++++ cli/assets/skills/design/SKILL.md | 15 ++- .../skills/design/references/logo-design.md | 17 +++- .../skills/design/scripts/logo/generate.py | 99 ++++++++++++++++++- .../scripts/logo/tests/test_generate.py | 69 +++++++++++++ 8 files changed, 380 insertions(+), 20 deletions(-) diff --git a/.claude/skills/design/SKILL.md b/.claude/skills/design/SKILL.md index 0dda900..56d809d 100644 --- a/.claude/skills/design/SKILL.md +++ b/.claude/skills/design/SKILL.md @@ -1,6 +1,6 @@ --- name: design -description: "Comprehensive design skill: brand identity, design tokens, UI styling, logo generation (55 styles, Gemini, Atlas Cloud, or MuAPI AI), corporate identity program (50 deliverables, CIP mockups), HTML presentations (Chart.js), banner design (22 styles, social/ads/web/print), icon design (15 styles, SVG, Gemini 3.1 Pro), social photos (HTML→screenshot, multi-platform). Actions: design logo, create CIP, generate mockups, build slides, design banner, generate icon, create social photos, social media images, brand identity, design system. Platforms: Facebook, Twitter, LinkedIn, YouTube, Instagram, Pinterest, TikTok, Threads, Google Ads." +description: "Comprehensive design skill: brand identity, design tokens, UI styling, logo generation (55 styles, Gemini, Atlas Cloud, MuAPI, or UberLLM AI), corporate identity program (50 deliverables, CIP mockups), HTML presentations (Chart.js), banner design (22 styles, social/ads/web/print), icon design (15 styles, SVG, Gemini 3.1 Pro), social photos (HTML→screenshot, multi-platform). Actions: design logo, create CIP, generate mockups, build slides, design banner, generate icon, create social photos, social media images, brand identity, design system. Platforms: Facebook, Twitter, LinkedIn, YouTube, Instagram, Pinterest, TikTok, Threads, Google Ads." argument-hint: "[design-type] [context]" license: MIT metadata: @@ -44,7 +44,7 @@ Script paths in this skill and its `references/` are relative to the directory t ## Logo Design (Built-in) 55+ styles, 30 color palettes, 25 industry guides. Gemini Nano Banana, Atlas -Cloud, and MuAPI image generation. +Cloud, MuAPI, and UberLLM image generation. ### Logo: Generate Design Brief @@ -70,6 +70,7 @@ python3 scripts/logo/generate.py --prompt "coffee shop vintage badge" --style vi python3 scripts/logo/generate.py --brand "TechFlow" --provider atlas python3 scripts/logo/generate.py --brand "TechFlow" --provider muapi python3 scripts/logo/generate.py --brand "TechFlow" --provider muapi --muapi-model nano-banana-pro +python3 scripts/logo/generate.py --brand "TechFlow" --provider uberllm ``` **IMPORTANT:** When scripts fail, try to fix them directly. @@ -314,6 +315,9 @@ pip install google-genai pillow # Optional MuAPI provider (no extra Python package required) export MUAPI_API_KEY="your-key" + +# Optional UberLLM provider (no extra Python package required) +export UBERLLM_API_KEY="your-key" # https://uberllm.dev/signup ``` MuAPI uses the asynchronous model endpoint and prediction result API. See the @@ -325,6 +329,13 @@ model slugs and sends their shared required `prompt` plus optional `aspect_ratio fields; the Pro model also accepts an optional `resolution` field that this focused logo workflow leaves at the provider default. +UberLLM uses the OpenAI-compatible `POST /v1/images/generations` route with +`response_format: b64_json`, so the image comes back in the answer and nothing +else is downloaded. The default model is `google/venice-nano-banana-2-lite`; +`--uberllm-model` takes any image model id from +`https://api.uberllm.dev/v1/models?type=image` (`GET /v1/models/` shows the +aspect ratios each model accepts). Live prices: https://uberllm.dev/models. + > **Note for Windows:** Use `python` instead of `pip` where needed (e.g., `python -m pip install ...`). ## Integration diff --git a/.claude/skills/design/references/logo-design.md b/.claude/skills/design/references/logo-design.md index 7b83120..5086922 100644 --- a/.claude/skills/design/references/logo-design.md +++ b/.claude/skills/design/references/logo-design.md @@ -1,13 +1,13 @@ # Logo Design Reference -AI-powered logo design with 55+ styles, 30 color palettes, 25 industry guides. Gemini Nano Banana is the default provider; Atlas Cloud and MuAPI are also available as explicit opt-in providers. +AI-powered logo design with 55+ styles, 30 color palettes, 25 industry guides. Gemini Nano Banana is the default provider; Atlas Cloud, MuAPI, and UberLLM are also available as explicit opt-in providers. ## Scripts | Script | Purpose | |--------|---------| | `scripts/logo/search.py` | Search styles, colors, industries; generate design briefs | -| `scripts/logo/generate.py` | Generate logos with Gemini Nano Banana, Atlas Cloud, or MuAPI | +| `scripts/logo/generate.py` | Generate logos with Gemini Nano Banana, Atlas Cloud, MuAPI, or UberLLM | | `scripts/logo/core.py` | BM25 search engine for logo data | ## Commands @@ -41,9 +41,10 @@ python3 scripts/logo/generate.py --prompt "coffee shop vintage badge" --style vi python3 scripts/logo/generate.py --brand "TechFlow" --provider atlas python3 scripts/logo/generate.py --brand "TechFlow" --provider muapi python3 scripts/logo/generate.py --brand "TechFlow" --provider muapi --muapi-model nano-banana-pro +python3 scripts/logo/generate.py --brand "TechFlow" --provider uberllm ``` -Options: `--style`, `--industry`, `--prompt`, `--provider`, `--atlas-model`, `--muapi-model` +Options: `--style`, `--industry`, `--prompt`, `--provider`, `--atlas-model`, `--muapi-model`, `--uberllm-model` ## Available Styles @@ -98,6 +99,9 @@ export ATLASCLOUD_API_KEY="your-key" # Optional MuAPI provider (no extra Python package required) export MUAPI_API_KEY="your-key" + +# Optional UberLLM provider (no extra Python package required) +export UBERLLM_API_KEY="your-key" # https://uberllm.dev/signup ``` MuAPI uses the asynchronous model endpoint and prediction result API. See the @@ -108,3 +112,10 @@ for the current model-specific schemas. The logo generator supports both documen model slugs and sends their shared required `prompt` plus optional `aspect_ratio` fields; the Pro model also accepts an optional `resolution` field that this focused logo workflow leaves at the provider default. + +UberLLM uses the OpenAI-compatible `POST /v1/images/generations` route with +`response_format: b64_json`, so the image comes back in the answer and nothing +else is downloaded. The default model is `google/venice-nano-banana-2-lite`; +`--uberllm-model` takes any image model id from +`https://api.uberllm.dev/v1/models?type=image` (`GET /v1/models/` shows the +aspect ratios each model accepts). Live prices: https://uberllm.dev/models. diff --git a/.claude/skills/design/scripts/logo/generate.py b/.claude/skills/design/scripts/logo/generate.py index 3b5773f..f188dc0 100644 --- a/.claude/skills/design/scripts/logo/generate.py +++ b/.claude/skills/design/scripts/logo/generate.py @@ -1,15 +1,19 @@ #!/usr/bin/env python3 -"""Logo generation with Gemini, Atlas Cloud, or MuAPI. +"""Logo generation with Gemini, Atlas Cloud, MuAPI, or UberLLM. Gemini remains the default provider. Atlas Cloud is opt-in with ``--provider atlas`` and uses its asynchronous image generation API. MuAPI is opt-in with ``--provider muapi`` and uses its asynchronous image generation API -with the selected model's prompt/aspect-ratio contract. +with the selected model's prompt/aspect-ratio contract. UberLLM is opt-in with +``--provider uberllm`` and uses its OpenAI-compatible image generation API; the +image comes back inside the JSON answer, so nothing else is downloaded. Models: - Nano Banana (default): gemini-2.5-flash-image - fast, high-volume, low-latency - Nano Banana Pro (--pro): gemini-3-pro-image - professional quality, advanced reasoning - MuAPI Nano Banana (--provider muapi): nano-banana - hosted asynchronous image generation +- UberLLM (--provider uberllm): google/venice-nano-banana-2-lite - any image model id from + https://api.uberllm.dev/v1/models?type=image via --uberllm-model Set GEMINI_FLASH_IMAGE_MODEL or GEMINI_PRO_IMAGE_MODEL to use another Gemini model id, for example when Google retires one of these. @@ -30,12 +34,16 @@ Usage: python generate.py --brand "TechFlow" --provider atlas python generate.py --brand "TechFlow" --provider muapi python generate.py --brand "TechFlow" --provider muapi --muapi-model nano-banana-pro + python generate.py --brand "TechFlow" --provider uberllm + python generate.py --brand "TechFlow" --provider uberllm --uberllm-model venice/recraft-v4 Batch mode (generates multiple variants): python generate.py --brand "Unikorn" --batch 9 --output-dir ./logos --pro """ import argparse +import base64 +import binascii import ipaddress import json import os @@ -75,6 +83,7 @@ load_env() GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY") ATLASCLOUD_API_KEY = os.environ.get("ATLASCLOUD_API_KEY") MUAPI_API_KEY = os.environ.get("MUAPI_API_KEY") +UBERLLM_API_KEY = os.environ.get("UBERLLM_API_KEY") # Gemini "Nano Banana" model configurations for image generation GEMINI_FLASH = ( @@ -93,6 +102,8 @@ ATLAS_API_BASE = "https://api.atlascloud.ai/api/v1" MUAPI_MODEL = "nano-banana" MUAPI_MODELS = ("nano-banana", "nano-banana-pro") MUAPI_API_BASE = "https://api.muapi.ai/api/v1" +UBERLLM_MODEL = "google/venice-nano-banana-2-lite" +UBERLLM_API_BASE = "https://api.uberllm.dev/v1" HTTP_USER_AGENT = "ui-ux-pro-max/2.5 (logo generation)" ATLAS_POLL_INTERVAL = 2 ATLAS_MAX_POLLS = 90 @@ -450,6 +461,62 @@ def _generate_with_muapi(prompt, output_path, aspect_ratio, api_key, model): raise RuntimeError("MuAPI prediction timed out while polling") +def _image_type_from_bytes(data): + """Return the MIME type of PNG, JPEG or WebP bytes, or None.""" + if data.startswith(b"\x89PNG\r\n\x1a\n"): + return "image/png" + if data.startswith(b"\xff\xd8\xff"): + return "image/jpeg" + if data[:4] == b"RIFF" and data[8:12] == b"WEBP": + return "image/webp" + return None + + +def _generate_with_uberllm(prompt, output_path, aspect_ratio, api_key, model): + """Generate with UberLLM and return the path the image was saved to. + + The request asks for ``b64_json``, so the picture comes back in the answer + and the API key is only ever sent to api.uberllm.dev. + """ + if not api_key: + raise RuntimeError("UBERLLM_API_KEY not set") + + response = _json_request( + f"{UBERLLM_API_BASE}/images/generations", + api_key, + method="POST", + payload={ + "model": model, + "prompt": prompt, + "n": 1, + "aspect_ratio": aspect_ratio, + "response_format": "b64_json", + }, + ) + data = response.get("data") if isinstance(response, dict) else None + first = data[0] if isinstance(data, list) and data else None + encoded = first.get("b64_json") if isinstance(first, dict) else None + if not isinstance(encoded, str) or not encoded: + raise RuntimeError("UberLLM did not return an image") + try: + image_data = base64.b64decode(encoded, validate=True) + except (binascii.Error, ValueError) as exc: + raise RuntimeError("UberLLM returned invalid image data") from exc + + mime_type = _image_type_from_bytes(image_data) + if mime_type is None: + raise RuntimeError("UberLLM output is not a PNG, JPEG or WebP image") + saved_path = _path_for_image_type(output_path, mime_type) + if saved_path != output_path: + print( + f"UberLLM returned {mime_type}, " + f"so saving as {saved_path} instead of {output_path}" + ) + with open(saved_path, "wb") as output_file: + output_file.write(image_data) + return saved_path + + def _path_for_image_type(output_path, mime_type): """Return output_path with the extension of the returned image type. @@ -534,8 +601,9 @@ def generate_logo( provider="gemini", atlas_model=ATLAS_MODEL, muapi_model=MUAPI_MODEL, + uberllm_model=UBERLLM_MODEL, ): - """Generate a logo using Gemini, Atlas Cloud, or MuAPI image generation. + """Generate a logo using Gemini, Atlas Cloud, MuAPI, or UberLLM image generation. Args: aspect_ratio: Image aspect ratio. Options: "1:1", "16:9", "9:16", "4:3", "3:4" @@ -557,6 +625,8 @@ def generate_logo( model_label = f"Atlas Cloud ({atlas_model})" elif provider == "muapi": model_label = f"MuAPI ({muapi_model})" + elif provider == "uberllm": + model_label = f"UberLLM ({uberllm_model})" else: model_label = ( f"Nano Banana Pro ({GEMINI_PRO})" @@ -586,6 +656,14 @@ def generate_logo( MUAPI_API_KEY, muapi_model, ) + elif provider == "uberllm": + output_path = _generate_with_uberllm( + full_prompt, + output_path, + ratio, + UBERLLM_API_KEY, + uberllm_model, + ) else: output_path = _generate_with_gemini(full_prompt, output_path, ratio, use_pro) @@ -608,6 +686,7 @@ def generate_batch( provider="gemini", atlas_model=ATLAS_MODEL, muapi_model=MUAPI_MODEL, + uberllm_model=UBERLLM_MODEL, ): """Generate multiple logo variants with different styles""" @@ -633,6 +712,8 @@ def generate_batch( if provider == "atlas" else f"MuAPI ({muapi_model})" if provider == "muapi" + else f"UberLLM ({uberllm_model})" + if provider == "uberllm" else f"Nano Banana {'Pro' if use_pro else 'Flash'}" ) ratio = aspect_ratio if aspect_ratio in ASPECT_RATIOS else DEFAULT_ASPECT_RATIO @@ -670,6 +751,7 @@ def generate_batch( provider=provider, atlas_model=atlas_model, muapi_model=muapi_model, + uberllm_model=uberllm_model, ) if result: @@ -691,7 +773,7 @@ def generate_batch( def main(): parser = argparse.ArgumentParser( - description="Generate logos using Gemini, Atlas Cloud, or MuAPI" + description="Generate logos using Gemini, Atlas Cloud, MuAPI, or UberLLM" ) parser.add_argument("--prompt", "-p", type=str, help="Logo description prompt") parser.add_argument("--brand", "-b", type=str, help="Brand name") @@ -718,7 +800,7 @@ def main(): ) parser.add_argument( "--provider", - choices=["gemini", "atlas", "muapi"], + choices=["gemini", "atlas", "muapi", "uberllm"], default="gemini", help="Image provider (default: gemini)", ) @@ -733,6 +815,11 @@ def main(): default=MUAPI_MODEL, help=f"MuAPI image model (default: {MUAPI_MODEL})", ) + parser.add_argument( + "--uberllm-model", + default=UBERLLM_MODEL, + help=f"UberLLM image model (default: {UBERLLM_MODEL})", + ) parser.add_argument( "--aspect-ratio", "-r", @@ -788,6 +875,7 @@ def main(): provider=args.provider, atlas_model=args.atlas_model, muapi_model=args.muapi_model, + uberllm_model=args.uberllm_model, ) if not results: sys.exit(1) @@ -803,6 +891,7 @@ def main(): provider=args.provider, atlas_model=args.atlas_model, muapi_model=args.muapi_model, + uberllm_model=args.uberllm_model, ) if saved_path is None: sys.exit(1) diff --git a/.claude/skills/design/scripts/logo/tests/test_generate.py b/.claude/skills/design/scripts/logo/tests/test_generate.py index e0ca6ca..9d914c8 100644 --- a/.claude/skills/design/scripts/logo/tests/test_generate.py +++ b/.claude/skills/design/scripts/logo/tests/test_generate.py @@ -1,3 +1,4 @@ +import base64 import importlib.util import io import os @@ -317,6 +318,74 @@ class MuapiGenerationTests(unittest.TestCase): json_request.assert_called_once() +class UberllmGenerationTests(unittest.TestCase): + def setUp(self): + temp_dir = tempfile.TemporaryDirectory() + self.addCleanup(temp_dir.cleanup) + self.dir = Path(temp_dir.name) + + @staticmethod + def _answer(data): + return {"data": [{"b64_json": base64.b64encode(data).decode("ascii")}]} + + @patch.object(logo_generate, "_json_request") + def test_uberllm_posts_once_and_saves_the_returned_image(self, json_request): + json_request.return_value = self._answer(PNG) + output = str(self.dir / "logo.png") + + saved = logo_generate._generate_with_uberllm( + "logo prompt", output, "1:1", "uberllm-key", "vendor/model" + ) + + json_request.assert_called_once_with( + f"{logo_generate.UBERLLM_API_BASE}/images/generations", + "uberllm-key", + method="POST", + payload={ + "model": "vendor/model", + "prompt": "logo prompt", + "n": 1, + "aspect_ratio": "1:1", + "response_format": "b64_json", + }, + ) + self.assertEqual(saved, output) + self.assertEqual(Path(saved).read_bytes(), PNG) + + @patch.object(logo_generate, "_json_request") + def test_uberllm_uses_the_extension_of_the_returned_type(self, json_request): + json_request.return_value = self._answer(JPEG) + + with patch("sys.stdout", new_callable=io.StringIO): + saved = logo_generate._generate_with_uberllm( + "logo prompt", str(self.dir / "logo.png"), "1:1", "k", "m" + ) + + self.assertEqual(saved, str(self.dir / "logo.jpg")) + self.assertFalse((self.dir / "logo.png").exists()) + + @patch.object(logo_generate, "_json_request") + def test_uberllm_rejects_missing_or_non_image_data(self, json_request): + for answer, message in ( + ({"data": []}, "did not return an image"), + ({"data": [{"b64_json": "not base64!"}]}, "invalid image data"), + (self._answer(b""), "not a PNG, JPEG or WebP"), + ): + with self.subTest(message=message): + json_request.return_value = answer + with self.assertRaisesRegex(RuntimeError, message): + logo_generate._generate_with_uberllm( + "logo prompt", str(self.dir / "logo.png"), "1:1", "k", "m" + ) + self.assertEqual(list(self.dir.iterdir()), []) + + def test_uberllm_requires_api_key(self): + with self.assertRaisesRegex(RuntimeError, "UBERLLM_API_KEY not set"): + logo_generate._generate_with_uberllm( + "logo prompt", "logo.png", "1:1", None, "vendor/model" + ) + + class GeminiImageTypeTests(unittest.TestCase): def setUp(self): self.client = Mock() diff --git a/cli/assets/skills/design/SKILL.md b/cli/assets/skills/design/SKILL.md index 0dda900..56d809d 100644 --- a/cli/assets/skills/design/SKILL.md +++ b/cli/assets/skills/design/SKILL.md @@ -1,6 +1,6 @@ --- name: design -description: "Comprehensive design skill: brand identity, design tokens, UI styling, logo generation (55 styles, Gemini, Atlas Cloud, or MuAPI AI), corporate identity program (50 deliverables, CIP mockups), HTML presentations (Chart.js), banner design (22 styles, social/ads/web/print), icon design (15 styles, SVG, Gemini 3.1 Pro), social photos (HTML→screenshot, multi-platform). Actions: design logo, create CIP, generate mockups, build slides, design banner, generate icon, create social photos, social media images, brand identity, design system. Platforms: Facebook, Twitter, LinkedIn, YouTube, Instagram, Pinterest, TikTok, Threads, Google Ads." +description: "Comprehensive design skill: brand identity, design tokens, UI styling, logo generation (55 styles, Gemini, Atlas Cloud, MuAPI, or UberLLM AI), corporate identity program (50 deliverables, CIP mockups), HTML presentations (Chart.js), banner design (22 styles, social/ads/web/print), icon design (15 styles, SVG, Gemini 3.1 Pro), social photos (HTML→screenshot, multi-platform). Actions: design logo, create CIP, generate mockups, build slides, design banner, generate icon, create social photos, social media images, brand identity, design system. Platforms: Facebook, Twitter, LinkedIn, YouTube, Instagram, Pinterest, TikTok, Threads, Google Ads." argument-hint: "[design-type] [context]" license: MIT metadata: @@ -44,7 +44,7 @@ Script paths in this skill and its `references/` are relative to the directory t ## Logo Design (Built-in) 55+ styles, 30 color palettes, 25 industry guides. Gemini Nano Banana, Atlas -Cloud, and MuAPI image generation. +Cloud, MuAPI, and UberLLM image generation. ### Logo: Generate Design Brief @@ -70,6 +70,7 @@ python3 scripts/logo/generate.py --prompt "coffee shop vintage badge" --style vi python3 scripts/logo/generate.py --brand "TechFlow" --provider atlas python3 scripts/logo/generate.py --brand "TechFlow" --provider muapi python3 scripts/logo/generate.py --brand "TechFlow" --provider muapi --muapi-model nano-banana-pro +python3 scripts/logo/generate.py --brand "TechFlow" --provider uberllm ``` **IMPORTANT:** When scripts fail, try to fix them directly. @@ -314,6 +315,9 @@ pip install google-genai pillow # Optional MuAPI provider (no extra Python package required) export MUAPI_API_KEY="your-key" + +# Optional UberLLM provider (no extra Python package required) +export UBERLLM_API_KEY="your-key" # https://uberllm.dev/signup ``` MuAPI uses the asynchronous model endpoint and prediction result API. See the @@ -325,6 +329,13 @@ model slugs and sends their shared required `prompt` plus optional `aspect_ratio fields; the Pro model also accepts an optional `resolution` field that this focused logo workflow leaves at the provider default. +UberLLM uses the OpenAI-compatible `POST /v1/images/generations` route with +`response_format: b64_json`, so the image comes back in the answer and nothing +else is downloaded. The default model is `google/venice-nano-banana-2-lite`; +`--uberllm-model` takes any image model id from +`https://api.uberllm.dev/v1/models?type=image` (`GET /v1/models/` shows the +aspect ratios each model accepts). Live prices: https://uberllm.dev/models. + > **Note for Windows:** Use `python` instead of `pip` where needed (e.g., `python -m pip install ...`). ## Integration diff --git a/cli/assets/skills/design/references/logo-design.md b/cli/assets/skills/design/references/logo-design.md index 7b83120..5086922 100644 --- a/cli/assets/skills/design/references/logo-design.md +++ b/cli/assets/skills/design/references/logo-design.md @@ -1,13 +1,13 @@ # Logo Design Reference -AI-powered logo design with 55+ styles, 30 color palettes, 25 industry guides. Gemini Nano Banana is the default provider; Atlas Cloud and MuAPI are also available as explicit opt-in providers. +AI-powered logo design with 55+ styles, 30 color palettes, 25 industry guides. Gemini Nano Banana is the default provider; Atlas Cloud, MuAPI, and UberLLM are also available as explicit opt-in providers. ## Scripts | Script | Purpose | |--------|---------| | `scripts/logo/search.py` | Search styles, colors, industries; generate design briefs | -| `scripts/logo/generate.py` | Generate logos with Gemini Nano Banana, Atlas Cloud, or MuAPI | +| `scripts/logo/generate.py` | Generate logos with Gemini Nano Banana, Atlas Cloud, MuAPI, or UberLLM | | `scripts/logo/core.py` | BM25 search engine for logo data | ## Commands @@ -41,9 +41,10 @@ python3 scripts/logo/generate.py --prompt "coffee shop vintage badge" --style vi python3 scripts/logo/generate.py --brand "TechFlow" --provider atlas python3 scripts/logo/generate.py --brand "TechFlow" --provider muapi python3 scripts/logo/generate.py --brand "TechFlow" --provider muapi --muapi-model nano-banana-pro +python3 scripts/logo/generate.py --brand "TechFlow" --provider uberllm ``` -Options: `--style`, `--industry`, `--prompt`, `--provider`, `--atlas-model`, `--muapi-model` +Options: `--style`, `--industry`, `--prompt`, `--provider`, `--atlas-model`, `--muapi-model`, `--uberllm-model` ## Available Styles @@ -98,6 +99,9 @@ export ATLASCLOUD_API_KEY="your-key" # Optional MuAPI provider (no extra Python package required) export MUAPI_API_KEY="your-key" + +# Optional UberLLM provider (no extra Python package required) +export UBERLLM_API_KEY="your-key" # https://uberllm.dev/signup ``` MuAPI uses the asynchronous model endpoint and prediction result API. See the @@ -108,3 +112,10 @@ for the current model-specific schemas. The logo generator supports both documen model slugs and sends their shared required `prompt` plus optional `aspect_ratio` fields; the Pro model also accepts an optional `resolution` field that this focused logo workflow leaves at the provider default. + +UberLLM uses the OpenAI-compatible `POST /v1/images/generations` route with +`response_format: b64_json`, so the image comes back in the answer and nothing +else is downloaded. The default model is `google/venice-nano-banana-2-lite`; +`--uberllm-model` takes any image model id from +`https://api.uberllm.dev/v1/models?type=image` (`GET /v1/models/` shows the +aspect ratios each model accepts). Live prices: https://uberllm.dev/models. diff --git a/cli/assets/skills/design/scripts/logo/generate.py b/cli/assets/skills/design/scripts/logo/generate.py index 3b5773f..f188dc0 100644 --- a/cli/assets/skills/design/scripts/logo/generate.py +++ b/cli/assets/skills/design/scripts/logo/generate.py @@ -1,15 +1,19 @@ #!/usr/bin/env python3 -"""Logo generation with Gemini, Atlas Cloud, or MuAPI. +"""Logo generation with Gemini, Atlas Cloud, MuAPI, or UberLLM. Gemini remains the default provider. Atlas Cloud is opt-in with ``--provider atlas`` and uses its asynchronous image generation API. MuAPI is opt-in with ``--provider muapi`` and uses its asynchronous image generation API -with the selected model's prompt/aspect-ratio contract. +with the selected model's prompt/aspect-ratio contract. UberLLM is opt-in with +``--provider uberllm`` and uses its OpenAI-compatible image generation API; the +image comes back inside the JSON answer, so nothing else is downloaded. Models: - Nano Banana (default): gemini-2.5-flash-image - fast, high-volume, low-latency - Nano Banana Pro (--pro): gemini-3-pro-image - professional quality, advanced reasoning - MuAPI Nano Banana (--provider muapi): nano-banana - hosted asynchronous image generation +- UberLLM (--provider uberllm): google/venice-nano-banana-2-lite - any image model id from + https://api.uberllm.dev/v1/models?type=image via --uberllm-model Set GEMINI_FLASH_IMAGE_MODEL or GEMINI_PRO_IMAGE_MODEL to use another Gemini model id, for example when Google retires one of these. @@ -30,12 +34,16 @@ Usage: python generate.py --brand "TechFlow" --provider atlas python generate.py --brand "TechFlow" --provider muapi python generate.py --brand "TechFlow" --provider muapi --muapi-model nano-banana-pro + python generate.py --brand "TechFlow" --provider uberllm + python generate.py --brand "TechFlow" --provider uberllm --uberllm-model venice/recraft-v4 Batch mode (generates multiple variants): python generate.py --brand "Unikorn" --batch 9 --output-dir ./logos --pro """ import argparse +import base64 +import binascii import ipaddress import json import os @@ -75,6 +83,7 @@ load_env() GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY") ATLASCLOUD_API_KEY = os.environ.get("ATLASCLOUD_API_KEY") MUAPI_API_KEY = os.environ.get("MUAPI_API_KEY") +UBERLLM_API_KEY = os.environ.get("UBERLLM_API_KEY") # Gemini "Nano Banana" model configurations for image generation GEMINI_FLASH = ( @@ -93,6 +102,8 @@ ATLAS_API_BASE = "https://api.atlascloud.ai/api/v1" MUAPI_MODEL = "nano-banana" MUAPI_MODELS = ("nano-banana", "nano-banana-pro") MUAPI_API_BASE = "https://api.muapi.ai/api/v1" +UBERLLM_MODEL = "google/venice-nano-banana-2-lite" +UBERLLM_API_BASE = "https://api.uberllm.dev/v1" HTTP_USER_AGENT = "ui-ux-pro-max/2.5 (logo generation)" ATLAS_POLL_INTERVAL = 2 ATLAS_MAX_POLLS = 90 @@ -450,6 +461,62 @@ def _generate_with_muapi(prompt, output_path, aspect_ratio, api_key, model): raise RuntimeError("MuAPI prediction timed out while polling") +def _image_type_from_bytes(data): + """Return the MIME type of PNG, JPEG or WebP bytes, or None.""" + if data.startswith(b"\x89PNG\r\n\x1a\n"): + return "image/png" + if data.startswith(b"\xff\xd8\xff"): + return "image/jpeg" + if data[:4] == b"RIFF" and data[8:12] == b"WEBP": + return "image/webp" + return None + + +def _generate_with_uberllm(prompt, output_path, aspect_ratio, api_key, model): + """Generate with UberLLM and return the path the image was saved to. + + The request asks for ``b64_json``, so the picture comes back in the answer + and the API key is only ever sent to api.uberllm.dev. + """ + if not api_key: + raise RuntimeError("UBERLLM_API_KEY not set") + + response = _json_request( + f"{UBERLLM_API_BASE}/images/generations", + api_key, + method="POST", + payload={ + "model": model, + "prompt": prompt, + "n": 1, + "aspect_ratio": aspect_ratio, + "response_format": "b64_json", + }, + ) + data = response.get("data") if isinstance(response, dict) else None + first = data[0] if isinstance(data, list) and data else None + encoded = first.get("b64_json") if isinstance(first, dict) else None + if not isinstance(encoded, str) or not encoded: + raise RuntimeError("UberLLM did not return an image") + try: + image_data = base64.b64decode(encoded, validate=True) + except (binascii.Error, ValueError) as exc: + raise RuntimeError("UberLLM returned invalid image data") from exc + + mime_type = _image_type_from_bytes(image_data) + if mime_type is None: + raise RuntimeError("UberLLM output is not a PNG, JPEG or WebP image") + saved_path = _path_for_image_type(output_path, mime_type) + if saved_path != output_path: + print( + f"UberLLM returned {mime_type}, " + f"so saving as {saved_path} instead of {output_path}" + ) + with open(saved_path, "wb") as output_file: + output_file.write(image_data) + return saved_path + + def _path_for_image_type(output_path, mime_type): """Return output_path with the extension of the returned image type. @@ -534,8 +601,9 @@ def generate_logo( provider="gemini", atlas_model=ATLAS_MODEL, muapi_model=MUAPI_MODEL, + uberllm_model=UBERLLM_MODEL, ): - """Generate a logo using Gemini, Atlas Cloud, or MuAPI image generation. + """Generate a logo using Gemini, Atlas Cloud, MuAPI, or UberLLM image generation. Args: aspect_ratio: Image aspect ratio. Options: "1:1", "16:9", "9:16", "4:3", "3:4" @@ -557,6 +625,8 @@ def generate_logo( model_label = f"Atlas Cloud ({atlas_model})" elif provider == "muapi": model_label = f"MuAPI ({muapi_model})" + elif provider == "uberllm": + model_label = f"UberLLM ({uberllm_model})" else: model_label = ( f"Nano Banana Pro ({GEMINI_PRO})" @@ -586,6 +656,14 @@ def generate_logo( MUAPI_API_KEY, muapi_model, ) + elif provider == "uberllm": + output_path = _generate_with_uberllm( + full_prompt, + output_path, + ratio, + UBERLLM_API_KEY, + uberllm_model, + ) else: output_path = _generate_with_gemini(full_prompt, output_path, ratio, use_pro) @@ -608,6 +686,7 @@ def generate_batch( provider="gemini", atlas_model=ATLAS_MODEL, muapi_model=MUAPI_MODEL, + uberllm_model=UBERLLM_MODEL, ): """Generate multiple logo variants with different styles""" @@ -633,6 +712,8 @@ def generate_batch( if provider == "atlas" else f"MuAPI ({muapi_model})" if provider == "muapi" + else f"UberLLM ({uberllm_model})" + if provider == "uberllm" else f"Nano Banana {'Pro' if use_pro else 'Flash'}" ) ratio = aspect_ratio if aspect_ratio in ASPECT_RATIOS else DEFAULT_ASPECT_RATIO @@ -670,6 +751,7 @@ def generate_batch( provider=provider, atlas_model=atlas_model, muapi_model=muapi_model, + uberllm_model=uberllm_model, ) if result: @@ -691,7 +773,7 @@ def generate_batch( def main(): parser = argparse.ArgumentParser( - description="Generate logos using Gemini, Atlas Cloud, or MuAPI" + description="Generate logos using Gemini, Atlas Cloud, MuAPI, or UberLLM" ) parser.add_argument("--prompt", "-p", type=str, help="Logo description prompt") parser.add_argument("--brand", "-b", type=str, help="Brand name") @@ -718,7 +800,7 @@ def main(): ) parser.add_argument( "--provider", - choices=["gemini", "atlas", "muapi"], + choices=["gemini", "atlas", "muapi", "uberllm"], default="gemini", help="Image provider (default: gemini)", ) @@ -733,6 +815,11 @@ def main(): default=MUAPI_MODEL, help=f"MuAPI image model (default: {MUAPI_MODEL})", ) + parser.add_argument( + "--uberllm-model", + default=UBERLLM_MODEL, + help=f"UberLLM image model (default: {UBERLLM_MODEL})", + ) parser.add_argument( "--aspect-ratio", "-r", @@ -788,6 +875,7 @@ def main(): provider=args.provider, atlas_model=args.atlas_model, muapi_model=args.muapi_model, + uberllm_model=args.uberllm_model, ) if not results: sys.exit(1) @@ -803,6 +891,7 @@ def main(): provider=args.provider, atlas_model=args.atlas_model, muapi_model=args.muapi_model, + uberllm_model=args.uberllm_model, ) if saved_path is None: sys.exit(1) diff --git a/cli/assets/skills/design/scripts/logo/tests/test_generate.py b/cli/assets/skills/design/scripts/logo/tests/test_generate.py index e0ca6ca..9d914c8 100644 --- a/cli/assets/skills/design/scripts/logo/tests/test_generate.py +++ b/cli/assets/skills/design/scripts/logo/tests/test_generate.py @@ -1,3 +1,4 @@ +import base64 import importlib.util import io import os @@ -317,6 +318,74 @@ class MuapiGenerationTests(unittest.TestCase): json_request.assert_called_once() +class UberllmGenerationTests(unittest.TestCase): + def setUp(self): + temp_dir = tempfile.TemporaryDirectory() + self.addCleanup(temp_dir.cleanup) + self.dir = Path(temp_dir.name) + + @staticmethod + def _answer(data): + return {"data": [{"b64_json": base64.b64encode(data).decode("ascii")}]} + + @patch.object(logo_generate, "_json_request") + def test_uberllm_posts_once_and_saves_the_returned_image(self, json_request): + json_request.return_value = self._answer(PNG) + output = str(self.dir / "logo.png") + + saved = logo_generate._generate_with_uberllm( + "logo prompt", output, "1:1", "uberllm-key", "vendor/model" + ) + + json_request.assert_called_once_with( + f"{logo_generate.UBERLLM_API_BASE}/images/generations", + "uberllm-key", + method="POST", + payload={ + "model": "vendor/model", + "prompt": "logo prompt", + "n": 1, + "aspect_ratio": "1:1", + "response_format": "b64_json", + }, + ) + self.assertEqual(saved, output) + self.assertEqual(Path(saved).read_bytes(), PNG) + + @patch.object(logo_generate, "_json_request") + def test_uberllm_uses_the_extension_of_the_returned_type(self, json_request): + json_request.return_value = self._answer(JPEG) + + with patch("sys.stdout", new_callable=io.StringIO): + saved = logo_generate._generate_with_uberllm( + "logo prompt", str(self.dir / "logo.png"), "1:1", "k", "m" + ) + + self.assertEqual(saved, str(self.dir / "logo.jpg")) + self.assertFalse((self.dir / "logo.png").exists()) + + @patch.object(logo_generate, "_json_request") + def test_uberllm_rejects_missing_or_non_image_data(self, json_request): + for answer, message in ( + ({"data": []}, "did not return an image"), + ({"data": [{"b64_json": "not base64!"}]}, "invalid image data"), + (self._answer(b""), "not a PNG, JPEG or WebP"), + ): + with self.subTest(message=message): + json_request.return_value = answer + with self.assertRaisesRegex(RuntimeError, message): + logo_generate._generate_with_uberllm( + "logo prompt", str(self.dir / "logo.png"), "1:1", "k", "m" + ) + self.assertEqual(list(self.dir.iterdir()), []) + + def test_uberllm_requires_api_key(self): + with self.assertRaisesRegex(RuntimeError, "UBERLLM_API_KEY not set"): + logo_generate._generate_with_uberllm( + "logo prompt", "logo.png", "1:1", None, "vendor/model" + ) + + class GeminiImageTypeTests(unittest.TestCase): def setUp(self): self.client = Mock()