Skip to content

feat(server): add /sdapi/v1/extra-single-image and /sdcpp/v1/upscale …#2

Open
mihard wants to merge 6 commits into
dockerfrom
claude/clever-hawking-6tNeg
Open

feat(server): add /sdapi/v1/extra-single-image and /sdcpp/v1/upscale …#2
mihard wants to merge 6 commits into
dockerfrom
claude/clever-hawking-6tNeg

Conversation

@mihard

@mihard mihard commented May 24, 2026

Copy link
Copy Markdown
Owner

…endpoints

Adds standalone image upscaling to both API surfaces:

  • POST /sdapi/v1/extra-single-image (synchronous, A1111-compatible) Accepts image + upscaler_1/upscaler_2 + scale/target dims. Returns {"image": "", "html_info": ""}.

  • POST /sdcpp/v1/upscale (async, native sdcpp API) Queues an upscale job, polled via GET /sdcpp/v1/jobs/{id}.

Shared upscale logic (perform_upscale) handles:

  • Built-in upscalers: None (passthrough), Lanczos (CatmullRom filter), Nearest (Box filter) via new resize_sd_image() in media_io
  • Model-backed upscalers: new_upscaler_ctx/upscale from hires_upscalers_dir
  • Optional two-upscaler pixel blending (upscaler_2_visibility)
  • ESRGAN output → exact target size resize when dims differ

Also adds ExtraSingleImageRequest, ExtraSingleImageResponse, and UpscaleRequest schemas to openapi.yaml (19 routes validated).

https://claude.ai/code/session_01WVK99Jp6uLuZwnXpydhK3G

Summary

Related Issue / Discussion

Additional Information

Checklist

claude added 6 commits May 24, 2026 09:40
Introduces an OpenAPI 3.1.0 specification covering all 17 server API
endpoints across the three API families (OpenAI, sdapi WebUI, sdcpp
native), with 29 fully documented schema components.

Two new server routes are registered:
- GET /openapi.yaml  — serves the embedded OpenAPI specification
- GET /docs          — serves Swagger UI (via CDN) pointing at the spec

Implementation:
- examples/server/openapi.yaml      — canonical spec file (for tooling)
- examples/server/routes_docs.cpp   — embeds spec + Swagger UI HTML and
                                      registers the two new routes
- examples/server/routes.h          — declares register_docs_endpoints()
- examples/server/main.cpp          — calls register_docs_endpoints()
- examples/server/CMakeLists.txt    — adds routes_docs.cpp to the build

https://claude.ai/code/session_01UWEVrPisViQsb7DQm1eGn4
Two improvements to the OpenAPI spec plumbing:

1. openapi.yaml is now the single source of truth. A new CMake custom
   command runs gen_openapi_yaml_h.py to generate openapi_yaml.h at
   build time (rebuilds only when openapi.yaml changes). routes_docs.cpp
   includes the generated header instead of embedding a 1500-line copy.

2. A new validation gate (validate_openapi.py) runs as a pre-build step
   and fails the build if openapi.yaml paths do not match the routes
   registered in routes_openai.cpp, routes_sdapi.cpp, and
   routes_sdcpp.cpp. Parameterised httplib regex paths are mapped to
   their OpenAPI path template equivalents before comparison.

https://claude.ai/code/session_01UWEVrPisViQsb7DQm1eGn4
Adds .github/workflows/docker-ci.yml which triggers on push to any
branch descended from the `docker` base branch (determined via
git merge-base ancestry check).

Flow per push:
1. check-ancestry — fast gate; skips all subsequent jobs if the branch
   is not descended from `docker`
2. build-linux-cpu + build-linux-vulkan — run in parallel; each
   installs pyyaml, runs validate_openapi.py explicitly, then builds
   with cmake (cmake also re-runs the validator as a pre-build step)
3. build-and-push-docker — gated on both CI jobs passing; builds
   Dockerfile.vulkan and pushes to ghcr.io/mihard/stable-diffusion.cpp
   tagged <sanitized-branch>-<short-sha>

https://claude.ai/code/session_01QA3cwbaLkeP2sBbxAFKQFj
- Dockerfile.vulkan: add python3 + python3-yaml to build stage so the
  cmake pre-build step (validate_openapi.py) can run inside the container
- docker-ci.yml: drop build-linux-vulkan job — Vulkan compilation is
  already validated by the Docker build itself (same as upstream CI)
  Update build-and-push-docker needs accordingly

https://claude.ai/code/session_01QA3cwbaLkeP2sBbxAFKQFj
- docker-ci.yml: change IMAGE_NAME to <repo>/vulkan so images are
  published as ghcr.io/mihard/stable-diffusion.cpp/vulkan:<branch>-<sha>
- cleanup-ghcr.yml: weekly scheduled job (Sundays 03:00 UTC) using
  snok/container-retention-policy to delete vulkan image versions
  older than 30 days; also wired to workflow_dispatch for manual runs

https://claude.ai/code/session_01QA3cwbaLkeP2sBbxAFKQFj
…endpoints

Adds standalone image upscaling to both API surfaces:

- POST /sdapi/v1/extra-single-image (synchronous, A1111-compatible)
  Accepts image + upscaler_1/upscaler_2 + scale/target dims. Returns
  {"image": "<base64-png>", "html_info": ""}.

- POST /sdcpp/v1/upscale (async, native sdcpp API)
  Queues an upscale job, polled via GET /sdcpp/v1/jobs/{id}.

Shared upscale logic (perform_upscale) handles:
  - Built-in upscalers: None (passthrough), Lanczos (CatmullRom filter),
    Nearest (Box filter) via new resize_sd_image() in media_io
  - Model-backed upscalers: new_upscaler_ctx/upscale from hires_upscalers_dir
  - Optional two-upscaler pixel blending (upscaler_2_visibility)
  - ESRGAN output → exact target size resize when dims differ

Also adds ExtraSingleImageRequest, ExtraSingleImageResponse, and
UpscaleRequest schemas to openapi.yaml (19 routes validated).

https://claude.ai/code/session_01WVK99Jp6uLuZwnXpydhK3G
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants