Skip to content

Support base64 embedding responses in the Rust SDK#86

Merged
AnthonyRonning merged 2 commits into
masterfrom
codex-embeddings-api-investigation-opensecret-sdk
Jul 11, 2026
Merged

Support base64 embedding responses in the Rust SDK#86
AnthonyRonning merged 2 commits into
masterfrom
codex-embeddings-api-investigation-opensecret-sdk

Conversation

@AnthonyRonning

@AnthonyRonning AnthonyRonning commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • model embedding response values as either float vectors or base64 strings
  • preserve the requested representation through SDK deserialization and serialization
  • add ergonomic accessors for both representations
  • add SDK contract and encrypted live integration coverage for both float and base64

Why

Tinfoil already supports encoding_format: "base64", and OpenSecret already preserves that provider response through its encrypted embeddings endpoint. The Rust SDK currently requires every embedding value to deserialize as Vec<f64>, causing otherwise valid base64 responses to fail before Maple Proxy can return them.

This fixes the response model at the SDK layer. No OpenSecret backend or Maple Proxy behavior change is needed.

Compatibility

This changes the Rust representation of EmbeddingData.embedding from Vec<f64> to EmbeddingVector. Consumers upgrading the SDK and directly reading that field can match the enum or use as_floats() / as_base64(). The HTTP API and wire format are unchanged.

Testing

  • cargo test --lib --all-features — 32 passed
  • cargo clippy --all-targets --all-features -- -D warnings
  • encrypted live SDK test with encoding_format: "float" — 768 finite values
  • encrypted live SDK test with encoding_format: "base64" — valid base64 decoding to 768 float32 values

Related to OpenSecretCloud/maple-proxy#40.


Open in Devin Review

Summary by CodeRabbit

  • New Features
    • Embedding responses can now be returned as either float arrays or base64-encoded values.
    • Added helpers to read embeddings in the requested representation.
    • Clients can request explicit float or base64 embedding encoding modes.
  • Bug Fixes
    • Improved handling by rejecting unsupported/unknown embedding response shapes during parsing.
  • Tests
    • Expanded integration coverage for both encoding formats, including dimensionality, decoding, and usage metadata.
  • Chores
    • Bumped the Rust crate version to 3.3.0.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 11, 2026

Copy link
Copy Markdown

Deploying opensecret-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3ba56e6
Status: ✅  Deploy successful!
Preview URL: https://5ec46a0d.opensecret-sdk.pages.dev
Branch Preview URL: https://codex-embeddings-api-investi.opensecret-sdk.pages.dev

View logs

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7b5bda95-e03f-4a65-abc7-f0223ff4b816

📥 Commits

Reviewing files that changed from the base of the PR and between d675372 and 3ba56e6.

📒 Files selected for processing (1)
  • rust/Cargo.toml
✅ Files skipped from review due to trivial changes (1)
  • rust/Cargo.toml

📝 Walkthrough

Walkthrough

Rust embedding types now accept float-array or base64-string wire representations. Unit and integration tests validate both formats, accessor behavior, serialization, dimensions, decoded byte lengths, finiteness, and usage fields. The Rust package version is updated to 3.3.0.

Changes

Embedding format support

Layer / File(s) Summary
Embedding vector contract
rust/src/types.rs
Adds the untagged EmbeddingVector enum and accessors, updates EmbeddingData.embedding, and tests both supported representations plus invalid object input.
Encoding-specific integration coverage
rust/tests/ai_integration.rs
Adds float and base64 encoding tests and updates multi-input and string-conversion assertions to use the new accessors.
Package version update
rust/Cargo.toml
Bumps the package version from 3.2.0 to 3.3.0.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Poem

A bunny found two ways to hop,
Through floating fields or strings on top.
It checked each byte and number bright,
Then nibbled tests by moonlit light.
“Both forms deserialize right!”

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main SDK change, though it only mentions base64 and omits the new float-vector representation support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex-embeddings-api-investigation-opensecret-sdk

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@AnthonyRonning
AnthonyRonning merged commit a09addf into master Jul 11, 2026
8 of 9 checks passed
@AnthonyRonning
AnthonyRonning deleted the codex-embeddings-api-investigation-opensecret-sdk branch July 11, 2026 19:59
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.

1 participant