Skip to content

Conversation

@sunyuhan1998
Copy link
Contributor

As mentioned in the issue #3786 , when using embedding models, we need to support the encodingFormat=base64 parameter. When this format is used, the model returns the embedding field as a base64-encoded string representing a float array. This PR adds support for handling that format.

Changes in this PR:

  1. Introduced a custom JSON deserializer, OpenAiEmbeddingDeserializer, for the embedding field in org.springframework.ai.openai.api.OpenAiApi.Embedding. This deserializer automatically converts the base64-encoded string back into a float array when parsing the API response.
  2. Added corresponding unit tests.

Fixes: #3786

…Api.Embedding`

Introduce `OpenAiEmbeddingDeserializer` to handle base64-encoded embeddings
returned by the model when encodingFormat=base64 is specified.

Signed-off-by: Sun Yuhan <[email protected]>
@sunyuhan1998 sunyuhan1998 changed the title feat: GH-3786 Provide encodingFormat=base64 support for the OpenAI embedding model GH-3786 Provide encodingFormat=base64 support for the OpenAI embedding model Jul 13, 2025
@sunyuhan1998 sunyuhan1998 changed the title GH-3786 Provide encodingFormat=base64 support for the OpenAI embedding model GH-3786: Provide encodingFormat=base64 support for the OpenAI embedding model Jul 13, 2025
@sunyuhan1998
Copy link
Contributor Author

Hi @ilayaperumalg can you help review this PR ? Thank you !

@ilayaperumalg
Copy link
Member

@sunyuhan1998 Thank you for the PR! Rebased, squashed and merged as 9e43b7e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Support for OpenAI based64 format embedding responses

2 participants