Skip to content

Add backend embedding endpoint via LiteLLM #52

@ajacobm

Description

@ajacobm

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

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions