[GH-ISSUE #22677] issue: Embedding API endpoints ignore model.params settings #35314

Closed
opened 2026-04-25 09:32:57 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @R-omk on GitHub (Mar 14, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/22677

Check Existing Issues

  • I have searched for any existing and/or related issues.
  • I have searched for any existing and/or related discussions.
  • I have also searched in the CLOSED issues AND CLOSED discussions and found no related items (your issue might already be addressed on the development branch!).
  • I am using the latest version of Open WebUI.

Installation Method

Docker

Open WebUI Version

v0.8.10-slim

Ollama Version (if applicable)

0.17.8

Operating System

Ubuntu 24.04

Browser (if applicable)

No response

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided every relevant configuration, setting, and environment variable used in my setup.
  • I have clearly listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc).
  • I have documented step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation. My steps:
  • Start with the initial platform/version/OS and dependencies used,
  • Specify exact install/launch/configure commands,
  • List URLs visited, user input (incl. example values/emails/passwords if needed),
  • Describe all options and toggles enabled or changed,
  • Include any files or environmental changes,
  • Identify the expected and actual result at each stage,
  • Ensure any reasonably skilled user can follow and hit the same issue.

Expected Behavior

When model parameters (e.g., num_ctx etc.) are configured in the model settings via the admin interface and saved to the database as model.params, these parameters should be automatically applied to all requests made to embedding endpoints, similar to how they work for chat completion endpoints.

For example, if an Ollama embedding model qwen3-embedding:4b has params.num_ctx: 32000 configured in the model settings, requests to /api/embeddings and /ollama/api/embed should automatically use this context length without requiring explicit options in each request.

Actual Behavior

The model parameters stored in model.params are completely ignored by embedding endpoints. When making requests to:

  • /api/embeddings (OpenAI-compatible endpoint)
  • /ollama/api/embed (Ollama proxy endpoint)

Only the parameters explicitly provided in the request body are forwarded to Ollama. The configured model parameters from the database are never merged or applied.

This behavior is inconsistent with chat completion endpoints, where apply_params_to_form_data() is called in process_chat_payload() to merge model parameters with request parameters.

Steps to Reproduce

  1. Configure an Ollama embedding model via admin interface (e.g., qwen3-embedding:4b)
  2. Set model parameters in the model settings, specifically:
    {
      "params": {
        "num_ctx": 32000
      }
    }
    
  3. Make an embedding request without explicit options:
    curl -X POST "http://localhost:8080/api/embeddings" \
      -H "Authorization: Bearer <api_key>" \
      -H "Content-Type: application/json" \
      -d '{"model": "ollama1.qwen3-embedding:4b", "input": "test"}'
    
  4. Check the loaded model context via Ollama ps endpoint
  5. Observe that the context length defaults to the Ollama global setting (e.g., 16384) instead of the configured 32000

Logs & Screenshots

[not applicable]

Additional Information

Workaround: Parameters are only applied when explicitly specified in the request:

curl -X POST "http://localhost:8080/api/embeddings" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"model": "ollama1.qwen3-embedding:4b", "input": "test", "options": {"num_ctx": 32000}}'

Root Cause Analysis

The issue stems from missing parameter merging logic in embedding endpoints:

Chat Completions (Works correctly):

  • File: backend/open_webui/utils/middleware.py:2011-2059
  • Function: apply_params_to_form_data() is called from process_chat_payload() at line 2149
  • Logic: Merges model.params with form_data.params and转发 to Ollama as options

Embeddings (Broken):

  • File: backend/open_webui/routers/ollama.py:1068

  • Endpoint: /ollama/api/embed

  • Line 1068: data=form_data.model_dump_json(exclude_none=True).encode()

  • Issue: Only sends request parameters, completely ignoring model.params

  • File: backend/open_webui/utils/embeddings.py:24-88

  • Function: generate_embeddings()

  • Endpoint: /api/embeddings

  • Issue: No call to apply_params_to_form_data() or similar logic

Code Locations

  • Model parameter configuration: backend/open_webui/models/models.py - params field in Model table
  • Parameter merging function: backend/open_webui/utils/middleware.py:2011 - apply_params_to_form_data()
  • Broken endpoint 1: backend/open_webui/routers/ollama.py:1016-1089 - /ollama/api/embed
  • Broken endpoint 2: backend/open_webui/main.py:1656-1680 - /api/embeddings
  • Working reference: backend/open_webui/utils/middleware.py:2143-2267 - process_chat_payload()

Code Reference - Current Broken Implementation

# backend/open_webui/routers/ollama.py:1064-1069
r = requests.request(
    method="POST",
    url=f"{url}/api/embed",
    headers=headers,
    data=form_data.model_dump_json(exclude_none=True).encode(),  # Only request data, no model.params
)

Suggested Fix

Add parameter merging similar to chat completions:

# In backend/open_webui/routers/ollama.py around line 1055
# After getting the model from MODELS state

from open_webui.utils.payload import apply_model_params_to_body_ollama

# Get model info
model_info = models.get(form_data.model, {})
model_params = model_info.get("params", {})

# Merge model params with request options
payload_dict = form_data.model_dump(exclude_none=True)
if model_params:
    payload_dict["options"] = apply_model_params_to_body(
        model_params,
        payload_dict.get("options", {}) or {},
        {}  # mappings from apply_model_params_to_body_ollama
    )

r = requests.request(
    method="POST",
    url=f"{url}/api/embed",
    headers=headers,
    data=json.dumps(payload_dict).encode(),
)

Additional Findings

Third broken endpoint: /ollama/api/embeddings (ollama.py:1099-1175) - line 1153 also ignores model.params when proxying to Ollama's /api/embeddings.

Available utility functions: backend/open_webui/utils/payload.py contains:

  • apply_model_params_to_body() (line 46)
  • apply_model_params_to_body_openai() (line 90)
  • apply_model_params_to_body_ollama() (line 124)
Originally created by @R-omk on GitHub (Mar 14, 2026). Original GitHub issue: https://github.com/open-webui/open-webui/issues/22677 ### Check Existing Issues - [x] I have searched for any existing and/or related issues. - [x] I have searched for any existing and/or related discussions. - [x] I have also searched in the CLOSED issues AND CLOSED discussions and found no related items (your issue might already be addressed on the development branch!). - [x] I am using the latest version of Open WebUI. ### Installation Method Docker ### Open WebUI Version v0.8.10-slim ### Ollama Version (if applicable) 0.17.8 ### Operating System Ubuntu 24.04 ### Browser (if applicable) _No response_ ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have **provided every relevant configuration, setting, and environment variable used in my setup.** - [x] I have clearly **listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup** (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc). - [x] I have documented **step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation**. My steps: - Start with the initial platform/version/OS and dependencies used, - Specify exact install/launch/configure commands, - List URLs visited, user input (incl. example values/emails/passwords if needed), - Describe all options and toggles enabled or changed, - Include any files or environmental changes, - Identify the expected and actual result at each stage, - Ensure any reasonably skilled user can follow and hit the same issue. ### Expected Behavior When model parameters (e.g., `num_ctx` etc.) are configured in the model settings via the admin interface and saved to the database as `model.params`, these parameters should be automatically applied to all requests made to embedding endpoints, similar to how they work for chat completion endpoints. For example, if an Ollama embedding model `qwen3-embedding:4b` has `params.num_ctx: 32000` configured in the model settings, requests to `/api/embeddings` and `/ollama/api/embed` should automatically use this context length without requiring explicit `options` in each request. ### Actual Behavior The model parameters stored in `model.params` are completely ignored by embedding endpoints. When making requests to: - `/api/embeddings` (OpenAI-compatible endpoint) - `/ollama/api/embed` (Ollama proxy endpoint) Only the parameters explicitly provided in the request body are forwarded to Ollama. The configured model parameters from the database are never merged or applied. This behavior is inconsistent with chat completion endpoints, where `apply_params_to_form_data()` is called in `process_chat_payload()` to merge model parameters with request parameters. ### Steps to Reproduce 1. Configure an Ollama embedding model via admin interface (e.g., `qwen3-embedding:4b`) 2. Set model parameters in the model settings, specifically: ```json { "params": { "num_ctx": 32000 } } ``` 3. Make an embedding request without explicit options: ```bash curl -X POST "http://localhost:8080/api/embeddings" \ -H "Authorization: Bearer <api_key>" \ -H "Content-Type: application/json" \ -d '{"model": "ollama1.qwen3-embedding:4b", "input": "test"}' ``` 4. Check the loaded model context via Ollama `ps` endpoint 5. Observe that the context length defaults to the Ollama global setting (e.g., 16384) instead of the configured 32000 ### Logs & Screenshots [not applicable] ### Additional Information **Workaround**: Parameters are only applied when explicitly specified in the request: ```bash curl -X POST "http://localhost:8080/api/embeddings" \ -H "Authorization: Bearer <api_key>" \ -H "Content-Type: application/json" \ -d '{"model": "ollama1.qwen3-embedding:4b", "input": "test", "options": {"num_ctx": 32000}}' ``` ### Root Cause Analysis The issue stems from missing parameter merging logic in embedding endpoints: **Chat Completions (Works correctly):** - File: `backend/open_webui/utils/middleware.py:2011-2059` - Function: `apply_params_to_form_data()` is called from `process_chat_payload()` at line 2149 - Logic: Merges `model.params` with `form_data.params` and转发 to Ollama as `options` **Embeddings (Broken):** - File: `backend/open_webui/routers/ollama.py:1068` - Endpoint: `/ollama/api/embed` - Line 1068: `data=form_data.model_dump_json(exclude_none=True).encode()` - Issue: Only sends request parameters, completely ignoring `model.params` - File: `backend/open_webui/utils/embeddings.py:24-88` - Function: `generate_embeddings()` - Endpoint: `/api/embeddings` - Issue: No call to `apply_params_to_form_data()` or similar logic ### Code Locations - **Model parameter configuration**: `backend/open_webui/models/models.py` - `params` field in Model table - **Parameter merging function**: `backend/open_webui/utils/middleware.py:2011` - `apply_params_to_form_data()` - **Broken endpoint 1**: `backend/open_webui/routers/ollama.py:1016-1089` - `/ollama/api/embed` - **Broken endpoint 2**: `backend/open_webui/main.py:1656-1680` - `/api/embeddings` - **Working reference**: `backend/open_webui/utils/middleware.py:2143-2267` - `process_chat_payload()` ### Code Reference - Current Broken Implementation ```python # backend/open_webui/routers/ollama.py:1064-1069 r = requests.request( method="POST", url=f"{url}/api/embed", headers=headers, data=form_data.model_dump_json(exclude_none=True).encode(), # Only request data, no model.params ) ``` ### Suggested Fix Add parameter merging similar to chat completions: ```python # In backend/open_webui/routers/ollama.py around line 1055 # After getting the model from MODELS state from open_webui.utils.payload import apply_model_params_to_body_ollama # Get model info model_info = models.get(form_data.model, {}) model_params = model_info.get("params", {}) # Merge model params with request options payload_dict = form_data.model_dump(exclude_none=True) if model_params: payload_dict["options"] = apply_model_params_to_body( model_params, payload_dict.get("options", {}) or {}, {} # mappings from apply_model_params_to_body_ollama ) r = requests.request( method="POST", url=f"{url}/api/embed", headers=headers, data=json.dumps(payload_dict).encode(), ) ``` ## Additional Findings **Third broken endpoint:** `/ollama/api/embeddings` (ollama.py:1099-1175) - line 1153 also ignores model.params when proxying to Ollama's `/api/embeddings`. **Available utility functions:** `backend/open_webui/utils/payload.py` contains: - `apply_model_params_to_body()` (line 46) - `apply_model_params_to_body_openai()` (line 90) - `apply_model_params_to_body_ollama()` (line 124)
GiteaMirror added the bug label 2026-04-25 09:32:57 -05:00
Author
Owner

@tjbck commented on GitHub (Mar 15, 2026):

Embedding models aren't supported.

<!-- gh-comment-id:4063984015 --> @tjbck commented on GitHub (Mar 15, 2026): Embedding models aren't supported.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#35314