[GH-ISSUE #5907] Support token embeddings for v1/embeddings #65723

Open
opened 2026-05-03 22:24:47 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @WoJiaoFuXiaoYun on GitHub (Jul 24, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/5907

Originally assigned to: @npardal on GitHub.

What is the issue?

When encoding with tiktoken, the interface is no longer compatible

tiktoken.get_encoding("cl100k_base").encode(text)
{
    "input": [30624,99849,64479,51392,31809,29207,233,45829],
    "model": "nomic-embed-text"
}
{
    "error": {
        "message": "invalid input type",
        "type": "api_error",
        "param": null,
        "code": null
    }
}

I hope it can be compatible, thank you

OS

No response

GPU

No response

CPU

No response

Ollama version

ollama version is 0.2.7

Originally created by @WoJiaoFuXiaoYun on GitHub (Jul 24, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/5907 Originally assigned to: @npardal on GitHub. ### What is the issue? When encoding with `tiktoken`, the interface is no longer compatible ``` tiktoken.get_encoding("cl100k_base").encode(text) ``` ```json { "input": [30624,99849,64479,51392,31809,29207,233,45829], "model": "nomic-embed-text" } ``` ``` { "error": { "message": "invalid input type", "type": "api_error", "param": null, "code": null } } ``` I hope it can be compatible, thank you ### OS _No response_ ### GPU _No response_ ### CPU _No response_ ### Ollama version ollama version is 0.2.7
GiteaMirror added the feature requestapi labels 2026-05-03 22:24:48 -05:00
Author
Owner

@royjhan commented on GitHub (Jul 30, 2024):

The supported functionality can be found here: #5470
While we can't provide a timeline for support right now, we appreciate the issue and we are aware

<!-- gh-comment-id:2258877724 --> @royjhan commented on GitHub (Jul 30, 2024): The supported functionality can be found here: #5470 While we can't provide a timeline for support right now, we appreciate the issue and we are aware
Author
Owner

@xldistance commented on GitHub (Aug 3, 2024):

Version 0.3.3 is still not compatible with OpenAIEmbedding
The code I run is as follows

    text_embedder = OpenAIEmbedding(
        # ollama本地嵌入模型
        api_key="ollama",
        api_base="http://localhost:11434/v1",
        model="bge:m3",
        deployment_name="bge:m3",
        api_type=OpenaiApiType.OpenAI,
        max_retries=20,
    )

The runtime error is as follows

2024-08-03 23:59:34,423 - httpx - INFO - HTTP Request: POST http://localhost:11434/v1/embeddings "HTTP/1.1 400 Bad Request"
Error embedding chunk {'OpenAIEmbedding': "Error code: 400 - {'error': {'message': 'invalid input type', 'type': 'api_error', 'param': None, 'code': None}}"}
<!-- gh-comment-id:2266894465 --> @xldistance commented on GitHub (Aug 3, 2024): Version 0.3.3 is still not compatible with OpenAIEmbedding The code I run is as follows ``` text_embedder = OpenAIEmbedding( # ollama本地嵌入模型 api_key="ollama", api_base="http://localhost:11434/v1", model="bge:m3", deployment_name="bge:m3", api_type=OpenaiApiType.OpenAI, max_retries=20, ) ``` The runtime error is as follows ``` 2024-08-03 23:59:34,423 - httpx - INFO - HTTP Request: POST http://localhost:11434/v1/embeddings "HTTP/1.1 400 Bad Request" Error embedding chunk {'OpenAIEmbedding': "Error code: 400 - {'error': {'message': 'invalid input type', 'type': 'api_error', 'param': None, 'code': None}}"} ```
Author
Owner

@codefromthecrypt commented on GitHub (Sep 12, 2024):

ps here's the langchain workaround until this is in. While not perfect, certainly proceeds!

    # Until https://github.com/ollama/ollama/issues/5907, we cannot use OpenAIEmbeddings because it
    # produces embeddings requests with list of numbers, not a list of strings.
    # embeddings = OpenAIEmbeddings(base_url=ollama_base_url + '/v1', api_key="unused", model="all-minilm:33m")
    embeddings = OllamaEmbeddings(base_url=ollama_base_url, model="all-minilm:33m")
<!-- gh-comment-id:2345193247 --> @codefromthecrypt commented on GitHub (Sep 12, 2024): ps here's the langchain workaround until this is in. While not perfect, certainly proceeds! ```python # Until https://github.com/ollama/ollama/issues/5907, we cannot use OpenAIEmbeddings because it # produces embeddings requests with list of numbers, not a list of strings. # embeddings = OpenAIEmbeddings(base_url=ollama_base_url + '/v1', api_key="unused", model="all-minilm:33m") embeddings = OllamaEmbeddings(base_url=ollama_base_url, model="all-minilm:33m") ```
Author
Owner

@nidhishgajjar commented on GitHub (Apr 21, 2026):

Orb Code Review (powered by GLM-4.7 on Orb Cloud)## SummaryThis PR appears to be a minimal change. Please provide more context about what this PR aims to accomplish.## Assessment⚠️ Needs More InformationThe diff is very small. Please add a description, tests, or more substantial changes to facilitate a thorough review.

<!-- gh-comment-id:4286187138 --> @nidhishgajjar commented on GitHub (Apr 21, 2026): **Orb Code Review** (powered by GLM-4.7 on [Orb Cloud](https://orbcloud.dev))## SummaryThis PR appears to be a minimal change. Please provide more context about what this PR aims to accomplish.## Assessment⚠️ **Needs More Information**The diff is very small. Please add a description, tests, or more substantial changes to facilitate a thorough review.
Author
Owner

@nidhishgajjar commented on GitHub (Apr 21, 2026):

Orb Code Review (powered by GLM-4.7 on Orb Cloud)## SummaryThis PR appears to be a minimal change. Please provide more context about what this PR aims to accomplish.## Assessment⚠️ Needs More InformationThe diff is very small. Please add a description, tests, or more substantial changes to facilitate a thorough review.

<!-- gh-comment-id:4286189121 --> @nidhishgajjar commented on GitHub (Apr 21, 2026): **Orb Code Review** (powered by GLM-4.7 on [Orb Cloud](https://orbcloud.dev))## SummaryThis PR appears to be a minimal change. Please provide more context about what this PR aims to accomplish.## Assessment⚠️ **Needs More Information**The diff is very small. Please add a description, tests, or more substantial changes to facilitate a thorough review.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#65723