Repository navigation
feat(providers): add CoralBricks as a native provider #44700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
5763b4a
88814a9
5f5db59
f8568e3
c789c5c
07dc9e8
430c736
9f9a8be
35f9b6f
18ffd76
1dfd035
cb1a23d
efb24af
a4fb718
93c5048
d5bbab5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16429,6 +16429,52 @@ | |
| "supports_function_calling": true, | ||
| "supports_tool_choice": true | ||
| }, | ||
| "coralbricks/glm-5.3-fp4": { | ||
|
greptile-apps[bot] marked this conversation as resolved.
Resolved
|
||
| "cache_creation_input_token_cost": 1.68e-06, | ||
| "cache_read_input_token_cost": 0.0, | ||
| "input_cost_per_token": 1.12e-06, | ||
| "litellm_provider": "coralbricks", | ||
| "max_input_tokens": 1048576, | ||
| "max_tokens": 1048576, | ||
| "mode": "chat", | ||
| "output_cost_per_token": 4.4e-06, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Reasoning-heavy calls inflate CoralBricks spend When reasoning tokens exceed completion tokens, Learn moreCoralBricks can return a chat usage block where Example: A response reporting 10 completion tokens and 12 reasoning tokens bills 12 output tokens, rather than the vendor's 10, even before any text tokens are counted Recommended fix: Normalize CoralBricks reasoning details against Was this helpful? React with 👍 or 👎 to provide feedback.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CoralBricks nests reasoning inside its output count (35 of 39 tokens in the proof). The arithmetic is the shared calculator every OpenAI-style provider uses |
||
| "source": "https://www.coralbricks.ai/pricing", | ||
| "supported_endpoints": [ | ||
| "/v1/chat/completions", | ||
| "/v1/responses", | ||
| "/v1/messages" | ||
| ], | ||
| "supports_function_calling": true, | ||
| "supports_native_streaming": true, | ||
| "supports_prompt_caching": true, | ||
| "supports_reasoning": true, | ||
| "supports_system_messages": true, | ||
| "supports_tool_choice": true, | ||
| "supports_vision": false | ||
| }, | ||
| "coralbricks/deepseek-v4.1-flash-fast-fp4": { | ||
| "cache_creation_input_token_cost": 9e-08, | ||
| "cache_read_input_token_cost": 0.0, | ||
| "input_cost_per_token": 3e-07, | ||
| "litellm_provider": "coralbricks", | ||
| "max_input_tokens": 1048576, | ||
| "max_tokens": 1048576, | ||
| "mode": "chat", | ||
| "output_cost_per_token": 1.2e-06, | ||
| "source": "https://www.coralbricks.ai/pricing", | ||
| "supported_endpoints": [ | ||
| "/v1/chat/completions", | ||
| "/v1/responses", | ||
| "/v1/messages" | ||
| ], | ||
| "supports_function_calling": true, | ||
| "supports_native_streaming": true, | ||
| "supports_prompt_caching": true, | ||
| "supports_reasoning": true, | ||
| "supports_system_messages": true, | ||
| "supports_tool_choice": true, | ||
| "supports_vision": true | ||
| }, | ||
| "computer-use-preview": { | ||
| "deprecation_date": "2026-07-23", | ||
| "input_cost_per_token": 3e-06, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| import { test, expect, APIRequestContext, Page as PlaywrightPage } from "@playwright/test"; | ||
| import { randomUUID } from "node:crypto"; | ||
| import { Page } from "../../fixtures/pages"; | ||
| import { navigateToPage } from "../../helpers/navigation"; | ||
| import { captureRequestBody } from "../../helpers/roundTrip"; | ||
|
|
||
| const master = process.env.LITELLM_MASTER_KEY ?? "sk-integration-master"; | ||
| const headers = { Authorization: `Bearer ${master}` }; | ||
| const upstream = (process.env.INTEGRATION_UPSTREAM_URL ?? "http://127.0.0.1:8190").replace(/\/+$/, ""); | ||
| const CORALBRICKS_MODEL = "deepseek-v4.1-flash-fast-fp4"; | ||
| const UI_KEY = "cb_ui_integration_key"; | ||
| const UPSTREAM_PROMPT_TOKENS = 20; | ||
| const UPSTREAM_COMPLETION_TOKENS = 20; | ||
|
|
||
| type DeploymentRow = { | ||
| model_name: string; | ||
| litellm_params?: { model?: string }; | ||
| model_info?: { id?: string; input_cost_per_token?: number; output_cost_per_token?: number }; | ||
| }; | ||
|
|
||
| type SpendRow = { | ||
| request_id: string; | ||
| custom_llm_provider: string; | ||
| model: string; | ||
| model_group: string; | ||
| prompt_tokens: number; | ||
| completion_tokens: number; | ||
| spend: number | string; | ||
| }; | ||
|
|
||
| const optionNamed = (label: string): RegExp => | ||
| new RegExp(`(^|\\s)${label.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`); | ||
|
|
||
| async function loginAsAdmin(page: PlaywrightPage): Promise<void> { | ||
| await page.goto("/ui/login"); | ||
| await page.getByPlaceholder("Enter your username").fill("admin"); | ||
| await page.getByPlaceholder("Enter your password").fill(master); | ||
| await page.getByRole("button", { name: "Login", exact: true }).click(); | ||
| await expect(page).toHaveURL( | ||
| (url) => url.pathname.startsWith("/ui") && !url.pathname.includes("login"), | ||
| ); | ||
| } | ||
|
|
||
| async function selectProvider(page: PlaywrightPage, providerName: string): Promise<void> { | ||
| const providerDropdown = page.getByRole("combobox", { name: "Provider", exact: true }); | ||
| await providerDropdown.click(); | ||
| await providerDropdown.fill(providerName); | ||
| await page.getByRole("option", { name: optionNamed(providerName) }).click(); | ||
| await expect(providerDropdown).toHaveValue(providerName); | ||
| } | ||
|
|
||
| async function deploymentNamed( | ||
| request: APIRequestContext, | ||
| modelName: string, | ||
| ): Promise<DeploymentRow | undefined> { | ||
| const response = await request.get("/v2/model/info", { headers }); | ||
| expect(response.ok(), await response.text()).toBe(true); | ||
| const rows = (await response.json()).data as DeploymentRow[]; | ||
| return rows.find((row) => row.model_name === modelName); | ||
| } | ||
|
|
||
| async function deleteDeployment(request: APIRequestContext, modelName: string): Promise<void> { | ||
| const stored = await deploymentNamed(request, modelName); | ||
| const id = stored?.model_info?.id; | ||
| if (!id) return; | ||
| const deleted = await request.post("/model/delete", { headers, data: { id } }); | ||
| expect(deleted.ok(), await deleted.text()).toBe(true); | ||
| } | ||
|
|
||
| async function chatOnce(request: APIRequestContext, modelName: string): Promise<{ status: number; body: string }> { | ||
| const response = await request.post("/v1/chat/completions", { | ||
| headers, | ||
| data: { model: modelName, messages: [{ role: "user", content: `hello from ${modelName}` }] }, | ||
| }); | ||
| return { status: response.status(), body: await response.text() }; | ||
| } | ||
|
|
||
| async function spendRow(request: APIRequestContext, requestId: string): Promise<SpendRow | undefined> { | ||
| const response = await request.get(`/spend/logs?request_id=${encodeURIComponent(requestId)}`, { headers }); | ||
| expect(response.ok(), await response.text()).toBe(true); | ||
| const rows = (await response.json()) as SpendRow[]; | ||
| return rows[0]; | ||
| } | ||
|
|
||
| test("the Add Model form offers CoralBricks and the deployment it creates serves and bills a chat", async ({ | ||
| page, | ||
| request, | ||
| }) => { | ||
| const alias = `integration-ui-coralbricks-${randomUUID().replace(/-/g, "").slice(0, 12)}`; | ||
| try { | ||
| await loginAsAdmin(page); | ||
| await navigateToPage(page, Page.Models); | ||
| await page.getByRole("tab", { name: "Add Model" }).click(); | ||
|
|
||
| await selectProvider(page, "CoralBricks"); | ||
|
|
||
| await page.getByRole("combobox", { name: "Select models" }).click(); | ||
| await page.getByRole("option", { name: "Custom Model Name (Enter below)" }).click(); | ||
| await page.keyboard.press("Escape"); | ||
| await page.getByPlaceholder("Enter custom model name").fill(CORALBRICKS_MODEL); | ||
|
|
||
| const publicName = page.getByRole("row").filter({ hasText: CORALBRICKS_MODEL }).getByRole("textbox"); | ||
| await expect(publicName).toHaveValue(CORALBRICKS_MODEL); | ||
| await publicName.fill(alias); | ||
|
|
||
| await page.locator("#api_base").fill(`${upstream}/v1`); | ||
| await page.locator("#api_key").fill(UI_KEY); | ||
|
|
||
| const created = await captureRequestBody(page, { method: "POST", urlIncludes: "/model/new" }, async () => { | ||
| await page.getByTestId("add-model-btn").click(); | ||
| }); | ||
| expect(created.model_name, "the public name typed into the mapping row").toBe(alias); | ||
| expect(created.litellm_params?.model, "the custom model name typed into the form").toBe(CORALBRICKS_MODEL); | ||
| expect(created.litellm_params?.custom_llm_provider, "the provider the picker maps CoralBricks to").toBe( | ||
| "coralbricks", | ||
| ); | ||
| expect(created.litellm_params?.api_base).toBe(`${upstream}/v1`); | ||
| expect(created.litellm_params?.api_key).toBe(UI_KEY); | ||
| await expect(page.getByText("created successfully")).toBeVisible({ timeout: 15_000 }); | ||
|
|
||
| let served = { status: 0, body: "" }; | ||
| await expect | ||
| .poll( | ||
| async () => { | ||
| served = await chatOnce(request, alias); | ||
| return served.status; | ||
| }, | ||
| { message: `the deployment added through the UI never served a chat: ${served.body}`, timeout: 60_000 }, | ||
| ) | ||
| .toBe(200); | ||
| const requestId = JSON.parse(served.body).id as string; | ||
| expect(requestId, served.body).toBeTruthy(); | ||
|
|
||
| const stored = await deploymentNamed(request, alias); | ||
| const inputRate = stored?.model_info?.input_cost_per_token; | ||
| const outputRate = stored?.model_info?.output_cost_per_token; | ||
| expect(inputRate, JSON.stringify(stored)).toBeGreaterThan(0); | ||
| expect(Number.isFinite(inputRate)).toBe(true); | ||
| expect(outputRate, JSON.stringify(stored)).toBeGreaterThan(0); | ||
| expect(Number.isFinite(outputRate)).toBe(true); | ||
| const expectedSpend = UPSTREAM_PROMPT_TOKENS * inputRate! + UPSTREAM_COMPLETION_TOKENS * outputRate!; | ||
|
|
||
| let row: SpendRow | undefined; | ||
| await expect | ||
| .poll( | ||
| async () => { | ||
| row = await spendRow(request, requestId); | ||
| return row?.request_id; | ||
| }, | ||
| { message: `no spend row for ${requestId}`, timeout: 60_000 }, | ||
| ) | ||
| .toBe(requestId); | ||
| expect(row?.custom_llm_provider, JSON.stringify(row)).toBe("coralbricks"); | ||
| expect(row?.model, JSON.stringify(row)).toBe(created.litellm_params.model); | ||
| expect(row?.model_group, JSON.stringify(row)).toBe(alias); | ||
| expect(row?.prompt_tokens, JSON.stringify(row)).toBe(UPSTREAM_PROMPT_TOKENS); | ||
| expect(row?.completion_tokens, JSON.stringify(row)).toBe(UPSTREAM_COMPLETION_TOKENS); | ||
| expect(Number(row?.spend), JSON.stringify(row)).toBeCloseTo(expectedSpend, 10); | ||
| } finally { | ||
| await deleteDeployment(request, alias); | ||
| } | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.