Skip to content

Add backend embedding endpoint via LiteLLM#53

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/add-embedding-endpoint-litelm
Draft

Add backend embedding endpoint via LiteLLM#53
Copilot wants to merge 5 commits intomainfrom
copilot/add-embedding-endpoint-litelm

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 19, 2026

Adds server-side embedding generation to support developer-local and hosted deployment architectures through LiteLLM's provider abstraction.

Implementation

Core endpoint (src/codenav/server/vector_api.py)

  • POST /api/vector/embedding with OpenAI-compatible request/response format
  • Single string or batch input support
  • Per-request model override via model parameter
  • Provider routing via LiteLLM (Azure OpenAI, OpenAI, Ollama, etc.)

Configuration

  • LITELLM_EMBEDDING_MODEL: Default model selection
  • AZURE_API_KEY, AZURE_API_BASE, AZURE_API_VERSION: Azure OpenAI
  • OPENAI_API_KEY: OpenAI direct

Dependencies

  • Added litellm>=1.61.15 to web extras (version vetted for known CVEs)

Example

curl -X POST http://localhost:8000/api/vector/embedding \
  -H "Content-Type: application/json" \
  -d '{"input": ["code snippet", "documentation"], "model": "text-embedding-3-small"}'

Response follows OpenAI embeddings API format:

{
  "object": "list",
  "data": [
    {"object": "embedding", "index": 0, "embedding": [0.1, 0.2, ...]},
    {"object": "embedding", "index": 1, "embedding": [0.3, 0.4, ...]}
  ],
  "model": "text-embedding-3-small",
  "usage": {"prompt_tokens": 10, "total_tokens": 10}
}

Testing

  • 11 test cases covering request validation, single/batch processing, model override, environment config, and error handling
  • Dual dict/object access pattern for LiteLLM response compatibility
Original prompt

This section details on the original issue you should resolve

<issue_title>Add backend embedding endpoint via LiteLLM</issue_title>
<issue_description>## Summary
Add a backend endpoint for embedding text using LiteLLM to support server-side embedding operations.

Background

Per docs/gitnexus-frontend-assessment.md, the architecture should support:

  • Developer-local setups (Ollama, in-browser)
  • Hosted deployments (Azure OpenAI) routed through LiteLLM
  • Embeddings as a configurable provider, not architecture coupling

The frontend now has a configurable embedding provider system (frontend/src/core/embeddings/providers/). The backend needs complementary endpoints.

Requirements

Endpoint: POST /api/vector/embedding

Request:
{
  "input": ["text1", "text2", ...] | "single text",
  "model": "optional-model-override"
}

Response:
{
  "object": "list",
  "data": [
    { "object": "embedding", "index": 0, "embedding": [0.1, 0.2, ...] },
    ...
  ],
  "model": "model-used",
  "usage": { "prompt_tokens": 10, "total_tokens": 10 }
}

Implementation Notes

  1. Use LiteLLM for routing to configured embedding provider
  2. Support environment-based configuration (LITELLM_EMBEDDING_MODEL, AZURE_OPENAI_*, etc.)
  3. Follow OpenAI-compatible response format
  4. Add to src/codenav/server/ router

Configuration

  • Environment variables for provider selection
  • Support Azure OpenAI, OpenAI, Ollama through LiteLLM proxy
  • Document in README or .env.example

Related

  • Frontend providers: frontend/src/core/embeddings/providers/
  • API contract draft: docs/gitnexus-frontend-assessment.md section 11.3
  • Session notes: docs/sessions/SESSION_20_SIGMA3_FRONTEND_REWRITE.md</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits January 19, 2026 00:25
Co-authored-by: ajacobm <170154633+ajacobm@users.noreply.github.com>
Co-authored-by: ajacobm <170154633+ajacobm@users.noreply.github.com>
Co-authored-by: ajacobm <170154633+ajacobm@users.noreply.github.com>
Co-authored-by: ajacobm <170154633+ajacobm@users.noreply.github.com>
Copilot AI changed the title [WIP] Add backend embedding endpoint via LiteLLM Add backend embedding endpoint via LiteLLM Jan 19, 2026
Copilot AI requested a review from ajacobm January 19, 2026 00:35
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.

Add backend embedding endpoint via LiteLLM

2 participants