diff --git a/.env.example b/.env.example index d0ef16b..6096d2f 100644 --- a/.env.example +++ b/.env.example @@ -3,7 +3,7 @@ QDRANT_PORT=6334 # QDRANT_API_KEY= # QDRANT_TLS=false OPENAI_API_KEY=sk-... -# EMBEDDING_BASE_URL=https://api.openai.com/v1 +# EMBEDDING_BASE_URL=https://api.openai.com EMBEDDING_MODEL=text-embedding-3-small MCP_TOKEN=change-me PORT=8080 diff --git a/embed.go b/embed.go index abda7d6..4083145 100644 --- a/embed.go +++ b/embed.go @@ -12,7 +12,7 @@ import ( ) const defaultModel = "text-embedding-3-small" -const defaultBaseURL = "https://api.openai.com/v1" +const defaultBaseURL = "https://api.openai.com" type embedder struct { apiKey string @@ -61,7 +61,7 @@ func (e *embedder) embedText(ctx context.Context, text string) ([]float32, error return nil, fmt.Errorf("marshal embedding request: %w", err) } - req, err := http.NewRequestWithContext(ctx, http.MethodPost, e.baseURL+"/embeddings", bytes.NewReader(body)) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, e.baseURL+"/v1/embeddings", bytes.NewReader(body)) if err != nil { return nil, fmt.Errorf("create embedding request: %w", err) } diff --git a/flake.nix b/flake.nix index 0ad364c..cae191a 100644 --- a/flake.nix +++ b/flake.nix @@ -77,8 +77,8 @@ embeddingBaseUrl = lib.mkOption { type = lib.types.str; - default = "https://api.openai.com/v1"; - description = "Base URL for the embeddings API."; + default = "https://api.openai.com"; + description = "Base URL for the embeddings API. Do not include /v1 suffix; it is appended automatically."; }; embeddingModel = lib.mkOption {