#pragma once #include #include #include namespace svapi { std::vector parseEmbeddingResponse(const nlohmann::json& body); // Split an OpenAI-compatible base URL into the origin (scheme://host[:port] — // httplib::Client ignores any path) and a path prefix to prepend to // "/v1/embeddings". e.g. "https://api.openai.com" -> {"https://api.openai.com", ""}; // "https://openrouter.ai/api" -> {"https://openrouter.ai", "/api"}. struct EmbeddingEndpoint { std::string origin; std::string path; }; EmbeddingEndpoint splitEmbeddingBase(const std::string& apiBase); class EmbeddingClient { public: EmbeddingClient(std::string apiBase, std::string apiKey, uint32_t connectTimeoutSec = 10, uint32_t readTimeoutSec = 60, uint32_t poolSize = 4); std::vector embed(const std::string& model, const std::string& text); private: std::string apiBase_, apiKey_; uint32_t connectTimeoutSec_, readTimeoutSec_, poolSize_; }; }