Skip to content

feat(providers): add Bitdeer AI as a JSON-configured provider - #36734

Open
ruijietey wants to merge 2 commits into
BerriAI:litellm_internal_stagingfrom
ruijietey:litellm_add_bitdeer_provider
Open

feat(providers): add Bitdeer AI as a JSON-configured provider#36734
ruijietey wants to merge 2 commits into
BerriAI:litellm_internal_stagingfrom
ruijietey:litellm_add_bitdeer_provider

Conversation

@ruijietey

Copy link
Copy Markdown

TLDR

Problem this solves:

  • Bitdeer AI's OpenAI-compatible inference API has no named provider in LiteLLM
  • Callers must manually pass a custom api_base/api_key today

How it solves it:

  • Registers bitdeer-ai in the JSON-configured provider system (providers.json)
  • Adds pricing for 3 models to model_prices_and_context_window.json

User Flow

Before: a developer wants to call a Bitdeer-hosted model through LiteLLM

  1. They call litellm.completion(model="moonshotai/Kimi-K3", api_base="https://api-inference.bitdeer.ai/v1", api_key=os.environ["BITDEER_API_KEY"])
  2. This works, but there is no named "bitdeer-ai" provider, no cost tracking, and no auto-detection from api_base alone

After: the same developer gets a named provider with cost tracking

  1. They call litellm.completion(model="bitdeer-ai/moonshotai/Kimi-K3", api_key=os.environ["BITDEER_API_KEY"]) with no api_base needed
  2. The request resolves to https://api-inference.bitdeer.ai/v1/chat/completions and the response includes cost calculated from model_prices_and_context_window.json
  3. Passing only api_base="https://api-inference.bitdeer.ai/v1" with a bare model name also auto-resolves to custom_llm_provider="bitdeer-ai"

Relevant issues

Linear ticket

Pre-Submission checklist

  • I have added meaningful tests
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests) — ran locally (pytest, schema validation against model_prices_and_context_window.schema.json, ruff check scoped to touched litellm/ files); have not run full CI
  • I have received a Greptile Confidence Score of at least 4/5 — pending, will request after this opens

Screenshots / Proof of Fix

No live Bitdeer API key was available while preparing this PR, so there is no real end-to-end curl proof against the live endpoint. What is verified locally:

$ python3 -m pytest tests/test_litellm/llms/openai_like/test_bitdeer_provider.py -v
8 passed
$ python3 -c "import json, jsonschema; jsonschema.validate(json.load(open('model_prices_and_context_window.json')), json.load(open('model_prices_and_context_window.schema.json'))); print('schema valid')"
schema valid

Happy to run a real curl against a live Bitdeer key if a maintainer or the Bitdeer team can supply one for verification before merge.

Type

🆕 New Feature

Caveats (if any)

  • No live API key was available to produce real end-to-end proof, see above
  • Only 3 of Bitdeer's models are registered here; more can follow in a separate PR

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Registers Bitdeer's OpenAI-compatible inference API (api-inference.bitdeer.ai)
following the existing JSON-configured provider pattern: providers.json entry,
LlmProviders enum member, openai_compatible_providers list entry, and the
api_base auto-detection branch in get_llm_provider_logic.py.

Adds pricing for 6 models to model_prices_and_context_window.json
(Kimi-K3, Kimi-K2.6, GLM-5.2, Qwen3.5-397B-A17B, DeepSeek-V4-Pro,
DeepSeek-V4-Flash), sourced from bitdeer.ai's published pricing page.
Keeps moonshotai/Kimi-K3, zai-org/GLM-5.2, and deepseek-ai/DeepSeek-V4-Flash;
drops Kimi-K2.6, Qwen3.5-397B-A17B, and DeepSeek-V4-Pro. Renames the provider
slug from bitdeer to bitdeer-ai to match Bitdeer's preferred identifier.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps

greptile-apps Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR registers Bitdeer AI as a JSON-configured OpenAI-compatible provider and adds pricing and capability metadata for three models.

  • Adds provider identification, URL autodetection, environment-key lookup, and OpenAI-compatible dispatch registration.
  • Adds model pricing/context metadata and focused provider-resolution tests.
  • The URL-autodetection credential precedence needs correction, and one pricing key is duplicated.

Confidence Score: 4/5

The provider wiring is mostly complete, but the explicit credential precedence defect should be fixed before merging.

Bitdeer requests using api_base autodetection can authenticate with BITDEER_API_KEY instead of the caller’s explicit key when both are present; the pricing registry also contains a non-blocking duplicate key.

Files Needing Attention: litellm/litellm_core_utils/get_llm_provider_logic.py; model_prices_and_context_window.json

Important Files Changed

Filename Overview
litellm/litellm_core_utils/get_llm_provider_logic.py Adds Bitdeer endpoint autodetection, but the branch can replace an explicit API key with BITDEER_API_KEY.
litellm/llms/openai_like/providers.json Correctly registers Bitdeer's base URL, credential environment variable, and token-parameter mapping.
model_prices_and_context_window.json Adds three Bitdeer pricing records, but DeepSeek-V4-Flash is declared twice under the same key.
litellm/types/utils.py Consistently adds bitdeer-ai to the provider enum.
litellm/constants.py Consistently adds Bitdeer to endpoint and OpenAI-compatible provider registries.
tests/test_litellm/llms/openai_like/test_bitdeer_provider.py Covers registration, routing, URL detection, and pricing, but does not exercise URL autodetection with competing explicit and environment keys.

Reviews (1): Last reviewed commit: "Trim Bitdeer models to 3 and rename slug..." | Re-trigger Greptile

Comment on lines +328 to +330
elif endpoint == "https://api-inference.bitdeer.ai/v1":
custom_llm_provider = "bitdeer-ai"
dynamic_api_key = get_secret_str("BITDEER_API_KEY")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Explicit API key gets overwritten

If BITDEER_API_KEY is set, URL autodetection replaces the caller's explicit api_key with that environment value, causing authentication to use the wrong Bitdeer account or fail despite a valid explicit credential.

Suggested change
elif endpoint == "https://api-inference.bitdeer.ai/v1":
custom_llm_provider = "bitdeer-ai"
dynamic_api_key = get_secret_str("BITDEER_API_KEY")
elif endpoint == "https://api-inference.bitdeer.ai/v1":
custom_llm_provider = "bitdeer-ai"
dynamic_api_key = api_key or get_secret_str("BITDEER_API_KEY")

Knowledge Base Used: LLM Provider Adapters

Comment on lines +47210 to +47213
"bitdeer-ai/deepseek-ai/DeepSeek-V4-Flash": {
"supports_prompt_caching": true,
"source": "https://www.bitdeer.ai/en/pricing/ai-models"
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Duplicate model pricing key

bitdeer-ai/deepseek-ai/DeepSeek-V4-Flash is declared twice, so standard JSON loading silently discards the first capability record and existing schema and pricing tests cannot detect edits made to it.

Suggested change
"bitdeer-ai/deepseek-ai/DeepSeek-V4-Flash": {
"supports_prompt_caching": true,
"source": "https://www.bitdeer.ai/en/pricing/ai-models"
},

Knowledge Base Used: Cost Tracking and Budget Enforcement

},
"bitdeer-ai": {
"base_url": "https://api-inference.bitdeer.ai/v1",
"api_key_env": "BITDEER_API_KEY",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: API key exfiltration through an overridden base URL

A caller can submit model: "bitdeer-ai/..." with api_base pointing to a server they control and omit api_key. The JSON-provider resolver preserves that api_base but falls back to BITDEER_API_KEY, so the outbound request exposes the server's credential in its Authorization header. Reject untrusted base-URL overrides for this provider, or require an explicit request API key whenever the selected base URL differs from the configured Bitdeer URL.

@veria-ai

veria-ai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

PR overview

This pull request adds Bitdeer AI as an OpenAI-compatible provider configured through the JSON provider registry.

One security issue remains open: callers can override the Bitdeer API base URL while the provider still falls back to the server’s configured Bitdeer API key. This can expose that credential to an attacker-controlled endpoint, so the provider should restrict base-URL overrides or require an explicit key for nonstandard URLs.

Open issues (1)

Fixed/addressed: 0 · PR risk: 6/10

@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing ruijietey:litellm_add_bitdeer_provider (e4ab197) with litellm_internal_staging (d86336a)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants