mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 20:00:47 +00:00
feat(vercel-ai-gateway): support embeddings, images and credit usage
Extend Vercel AI Gateway beyond chat: add OpenAI-compatible embeddings and image generation endpoints, credit balance fetch on the usage dashboard, retry on 429, and models catalog fetcher. Thinking/reasoning mapping is omitted pending a project-wide refactor. Co-authored-by: Ngô Tấn Tài <tantai@newnol.io.vn> Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
decolua
co-authored by
Cursor
parent
d9b030011f
commit
b33cbb0280
@@ -222,6 +222,21 @@ describe("buildEmbeddingsUrl", () => {
|
||||
expect(url).toBe("https://openrouter.ai/api/v1/embeddings");
|
||||
});
|
||||
|
||||
it("vercel-ai-gateway → https://ai-gateway.vercel.sh/v1/embeddings", async () => {
|
||||
vi.mocked(fetch).mockResolvedValueOnce(makeProviderResponse(VALID_EMBEDDING_RESPONSE));
|
||||
|
||||
await handleEmbeddingsCore(makeOptions({
|
||||
modelInfo: { provider: "vercel-ai-gateway", model: "openai/text-embedding-3-small" },
|
||||
credentials: { apiKey: "vag-test-key" },
|
||||
}));
|
||||
|
||||
const [url, init] = vi.mocked(fetch).mock.calls[0];
|
||||
const sent = JSON.parse(init.body);
|
||||
expect(url).toBe("https://ai-gateway.vercel.sh/v1/embeddings");
|
||||
expect(init.headers.Authorization).toBe("Bearer vag-test-key");
|
||||
expect(sent.model).toBe("openai/text-embedding-3-small");
|
||||
});
|
||||
|
||||
it("openai-compatible-* → uses baseUrl from providerSpecificData", async () => {
|
||||
vi.mocked(fetch).mockResolvedValueOnce(makeProviderResponse(VALID_EMBEDDING_RESPONSE));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user