Skip to content

feat(extension): add OrcaRouter as a named dense embedding provider - #695

Open
XiaoHuo888-hue wants to merge 1 commit into
alibaba:mainfrom
XiaoHuo888-hue:feat/orcarouter-provider
Open

feat(extension): add OrcaRouter as a named dense embedding provider#695
XiaoHuo888-hue wants to merge 1 commit into
alibaba:mainfrom
XiaoHuo888-hue:feat/orcarouter-provider

Conversation

@XiaoHuo888-hue

Copy link
Copy Markdown

Summary

Add OrcaRouter as a named dense-embedding provider in the Python extension layer, mirroring the existing OpenAIDenseEmbedding / QwenDenseEmbedding provider pattern.

OrcaRouter is an OpenAI-compatible gateway that exposes a broad catalog of frontier models through a single endpoint (https://api.orcarouter.ai/v1). It also runs gateway-level, zero-trust security for AI agents on the same endpoint — screening every prompt/response and governing every tool call on a default-deny basis, with no application code changes.

Changes

  • python/zvec/extension/orcarouter_function.py: new OrcaRouterFunctionBase base class with DEFAULT_ORCAROUTER_BASE_URL, ORCAROUTER_API_KEY env-var handling, and embedding API call/response parsing. Reuses the official openai client (no new dependency).
  • python/zvec/extension/orcarouter_embedding_function.py: new OrcaRouterDenseEmbedding class with a model dimension table and LRU caching.
  • python/zvec/extension/__init__.py and python/zvec/__init__.py: export the new classes.
  • python/tests/test_embedding.py: add TestOrcaRouterDenseEmbedding mirroring the OpenAI test suite (init, env key, empty input, success, API error, invalid response, dimension mismatch, callable, custom base URL, real-API integration test).

Usage

from zvec.extension import OrcaRouterDenseEmbedding
import os

os.environ["ORCAROUTER_API_KEY"] = "sk-orca-..."
emb = OrcaRouterDenseEmbedding(model="openai/text-embedding-3-small")
vector = emb.embed("Hello, world!")

Validation

  • ruff check and ruff format --check pass on all changed files.
  • pytest python/tests/test_embedding.py -k OrcaRouter: 17 passed, 1 skipped (integration test gated behind ZVEC_RUN_INTEGRATION_TESTS=1).
  • Existing embedding tests unaffected: full test_embedding.py run — 94 passed, 13 skipped (pre-existing integration tests).
  • L3 live test: ran OrcaRouterDenseEmbedding with a real key against https://api.orcarouter.ai/v1/embeddings (model openai/text-embedding-3-small) → HTTP 200, 1536-dim vector returned.

Disclosure: I'm an engineer on the OrcaRouter team.

Add OrcaRouterDenseEmbedding and OrcaRouterFunctionBase mirroring the
existing OpenAI/Qwen provider pattern. It reuses the OpenAI-compatible
/v1/embeddings endpoint at https://api.orcarouter.ai/v1 with the
official openai client (no new dependency) and reads ORCAROUTER_API_KEY
from the environment.

- python/zvec/extension/orcarouter_function.py: base class with
  DEFAULT_ORCAROUTER_BASE_URL, key validation, and API call handling
- python/zvec/extension/orcarouter_embedding_function.py:
  OrcaRouterDenseEmbedding with model dimension table and LRU caching
- Register both in zvec.extension and top-level zvec exports
- Add TestOrcaRouterDenseEmbedding coverage mirroring the OpenAI suite

Disclosure: I'm an engineer on the OrcaRouter team.
Signed-off-by: XiaoHuo888-hue <jinhao.song@myflashcloud.com>
@XiaoHuo888-hue
XiaoHuo888-hue requested a review from Cuiyus as a code owner August 23, 2026 01:42
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


XiaoHuo888-hue seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

3 participants