[PR #13753] [MERGED] api: add native API support for experimental image generation models #14375

Closed
opened 2026-04-13 00:52:14 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/13753
Author: @jmorganca
Created: 1/17/2026
Status: Merged
Merged: 1/18/2026
Merged by: @jmorganca

Base: mainHead: imagegen-generate


📝 Commits (1)

  • 45577b7 Add experimental image generation fields to /api/generate

📊 Changes

17 files changed (+644 additions, -131 deletions)

View changed files

📝 api/types.go (+28 -0)
📝 cmd/cmd.go (+2 -1)
📝 cmd/cmd_test.go (+1 -1)
📝 docs/api.md (+62 -0)
📝 docs/api/openai-compatibility.mdx (+67 -0)
📝 llm/server.go (+9 -4)
📝 middleware/openai.go (+63 -0)
📝 middleware/openai_test.go (+151 -0)
📝 openai/openai.go (+57 -0)
📝 server/images.go (+3 -1)
📝 server/images_test.go (+19 -1)
📝 server/routes.go (+98 -60)
📝 server/sched.go (+2 -2)
📝 types/model/capability.go (+1 -1)
📝 x/imagegen/cli.go (+69 -48)
📝 x/imagegen/runner/runner.go (+5 -2)
📝 x/imagegen/server.go (+7 -10)

📄 Description

This adds native image generation support to a new /x/generate endpoint (for experimental), allowing image generation models to eventually be used through the same API as text completion models.

API changes:

  • Add width, height, steps parameters to GenerateRequest
  • Add status, total, completed, images fields to GenerateResponse
  • Return base64-encoded image data in images array when done

OpenAI compatibility:

  • Add /v1/images/generations endpoint using middleware pattern
  • Transform OpenAI image generation requests to /api/generate format
  • Return OpenAI-compatible response format with b64_json data

CLI improvements:

  • Update imagegen CLI to use new API fields directly
  • Pass width, height, steps through GenerateRequest

Internal changes:

  • Update llm.CompletionRequest/Response with image generation fields
  • Change Image field from []byte to string (base64-encoded)
  • Add Steps field to CompletionRequest
  • Rename Total to TotalSteps for clarity

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/13753 **Author:** [@jmorganca](https://github.com/jmorganca) **Created:** 1/17/2026 **Status:** ✅ Merged **Merged:** 1/18/2026 **Merged by:** [@jmorganca](https://github.com/jmorganca) **Base:** `main` ← **Head:** `imagegen-generate` --- ### 📝 Commits (1) - [`45577b7`](https://github.com/ollama/ollama/commit/45577b7ffc02a4f3232d1960b14300dab4af7428) Add experimental image generation fields to /api/generate ### 📊 Changes **17 files changed** (+644 additions, -131 deletions) <details> <summary>View changed files</summary> 📝 `api/types.go` (+28 -0) 📝 `cmd/cmd.go` (+2 -1) 📝 `cmd/cmd_test.go` (+1 -1) 📝 `docs/api.md` (+62 -0) 📝 `docs/api/openai-compatibility.mdx` (+67 -0) 📝 `llm/server.go` (+9 -4) 📝 `middleware/openai.go` (+63 -0) 📝 `middleware/openai_test.go` (+151 -0) 📝 `openai/openai.go` (+57 -0) 📝 `server/images.go` (+3 -1) 📝 `server/images_test.go` (+19 -1) 📝 `server/routes.go` (+98 -60) 📝 `server/sched.go` (+2 -2) 📝 `types/model/capability.go` (+1 -1) 📝 `x/imagegen/cli.go` (+69 -48) 📝 `x/imagegen/runner/runner.go` (+5 -2) 📝 `x/imagegen/server.go` (+7 -10) </details> ### 📄 Description This adds native image generation support to a new /x/generate endpoint (for experimental), allowing image generation models to eventually be used through the same API as text completion models. API changes: - Add width, height, steps parameters to GenerateRequest - Add status, total, completed, images fields to GenerateResponse - Return base64-encoded image data in images array when done OpenAI compatibility: - Add /v1/images/generations endpoint using middleware pattern - Transform OpenAI image generation requests to /api/generate format - Return OpenAI-compatible response format with b64_json data CLI improvements: - Update imagegen CLI to use new API fields directly - Pass width, height, steps through GenerateRequest Internal changes: - Update llm.CompletionRequest/Response with image generation fields - Change Image field from []byte to string (base64-encoded) - Add Steps field to CompletionRequest - Rename Total to TotalSteps for clarity --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 00:52:14 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#14375