Skip to content

feat(providers): add AI Stupid Level as a JSON-configured OpenAI-compatible provider - #47336

Open
StudioPlatforms wants to merge 8 commits into
BerriAI:mainfrom
StudioPlatforms:feat/aistupidlevel-provider
Open

StudioPlatforms wants to merge 8 commits into
BerriAI:mainfrom
StudioPlatforms:feat/aistupidlevel-provider

Conversation

@StudioPlatforms

Copy link
Copy Markdown

TLDR

Problem this solves:

  • AI Stupid Level is not a supported provider, so callers have to route through openai/ with a
    custom api_base. Tools are then gated on the cost map, and the Admin UI has no entry.

How it solves it:

  • Registers aistupidlevel in litellm/llms/openai_like/providers.json. The router accepts
    max_completion_tokens as sent, so there is no param mapping. provider_info marks
    supports_function_calling, because every model the router can choose supports tools.
  • Adds LlmProviders.AISTUPIDLEVEL, adds the provider and its base URL to the openai-compatible
    lists in constants.py, adds it to both endpoint matrices (chat, plus the messages and responses
    bridges), and adds an Add Model form entry.
  • No cost-map entries: model ids are routing modes (auto-coding, auto-reasoning, ...), so the
    model behind them changes per request, and tokens are billed by the chosen model's provider to
    the user's own key.

Relevant issues

The docs page is in BerriAI/litellm-docs#2453, which should merge first so that
test_env_keys.py finds AISTUPIDLEVEL_API_KEY / AISTUPIDLEVEL_API_BASE.

Pre-Submission checklist

  • I have added meaningful tests: tests/unit/llms/openai_like/test_aistupidlevel_provider.py
    (13 tests, all mocked with respx: registration, config, env and api_base resolution, URL
    autodetection, tool params, Add Model form, endpoint matrix, chat request, tools forwarded,
    Responses bridge, /v1/messages bridge)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • My PR passes all CI/CD checks
  • Greptile Confidence Score of at least 4/5

Screenshots / Proof of Fix

Local:

  • pytest tests/unit/llms/openai_like/test_aistupidlevel_provider.py test_json_providers.py test_reka_provider.py:
    39 passed
  • ruff check / ruff format --check: clean

Live, from this branch, against https://aistupidlevel.info with X-ASL-Sandbox: true (real routing,
mock completion, no provider call):

completion:          aistupidlevel/claude-opus-5-5 | Sandbox response from claude-opus-5-5 (anthropic).
stream:              Sandbox response from claude-opus-5-5 (anthropic).
tools:               get_weather {"city":"sandbox"}
responses:           Sandbox response from claude-fable-5-1 (anthropic)
anthropic messages:  Sandbox response from claude-opus-5-5 (anthropic).
supports_function_calling: True

Reviewers can test the same way at no cost: any router key plus the X-ASL-Sandbox: true header.

@codecov

codecov Bot commented Oct 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 1 benchmark is dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 35 untouched benchmarks


Comparing StudioPlatforms:feat/aistupidlevel-provider (9bc7da2) with main (cfe0100)

Open in CodSpeed

Adds the 10 routing modes (aistupidlevel/auto, auto-coding, auto-tooling, ...)
to the cost map and its backup, in the same shape as the Fireworks router
entries: provider, chat mode, the router's limits and capability flags, with
no prices. The limits (262,144 in, 64,000 out) are the smallest across the
models it routes to. There are no prices because each request is billed by the
routed model's provider to the caller's own key.

Tools that read model lists from the cost map can now show these modes, and
get_model_info resolves them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@StudioPlatforms

Copy link
Copy Markdown
Author

I added a second commit. It puts the 10 routing modes into the model cost map and its backup, in the same shape as the fireworks_ai/accounts/fireworks/routers/* entries: limits and capability flags, but no prices. Each request is billed by the routed model's provider to the caller's own key, so there is no fixed price to list.

With these entries, tools that read their model lists from the cost map can show the modes, and get_model_info resolves them.

These pass locally:

  • tests/unit/llms/openai_like/test_aistupidlevel_provider.py (14 tests)
  • test_aaamodel_prices_and_context_window_json_is_valid
  • tests/unit/test_cost_map_guard.py

@CLAassistant

CLAassistant commented Oct 24, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@StudioPlatforms

Copy link
Copy Markdown
Author

About the CLA check: the signing page for this repo can't load the agreement at the moment. cla-assistant answers "Bad credentials" when it fetches the linked gist, so there's nothing to sign. This is reported as cla-assistant/cla-assistant#1211 and #1212. I'll sign as soon as it loads again. The commits on this PR are now linked to the StudioPlatforms account.

…evel-provider

Resolve conflict in litellm/llms/openai_like/providers.json: keep both
the upstream 'refuseless' provider and our 'aistupidlevel' provider
entries.
…ap rows

Upstream BerriAI#48471 retired max_tokens in favor of max_input_tokens and
max_output_tokens; our routing-mode rows already carry both.
@StudioPlatforms

Copy link
Copy Markdown
Author

I merged the latest main to clear a conflict in providers.json. Both sides had added a provider, so I kept upstream's refuseless and our aistupidlevel. I also removed max_tokens from the 10 aistupidlevel/* cost-map rows to follow #48471. Each row still has max_input_tokens and max_output_tokens. All checks pass apart from osv-scan. That one fails on the existing pillow 12.3.0 and @azure/msal-node advisories in uv.lock and vscode-extension/package-lock.json. This PR doesn't touch either file, and the same check fails on main (cfe0100).

StudioPlatforms and others added 2 commits October 29, 2026 07:33
…evel-provider

Conflicts, all from both sides adding a provider at the same place: streamlake in
constants.py, types/utils.py and providers.json, and the aiand/* rows in the cost map
and its backup. Both are kept, with upstream first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@StudioPlatforms

Copy link
Copy Markdown
Author

Merged the latest main (dc6bd59) to clear the conflict. Both sides had added a provider at the end of providers.json and the LlmProviders enum, so I kept upstream's wally and our aistupidlevel.

tests/unit/llms/openai_like/ passes locally (676 tests, ours included).

Comment thread litellm/llms/openai_like/providers.json Resolved
@veria-ai

veria-ai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

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

Reviews

…ey is missing

With AISTUPIDLEVEL_API_KEY unset and no api_key passed, the shared chat path fell back
to litellm.openai_key / OPENAI_API_KEY and sent that key to aistupidlevel.info.

JSON providers can now opt in to `special_handling.require_api_key`: the request is
refused with an AuthenticationError naming the provider's env var before any client is
built (the OpenAI client would otherwise read OPENAI_API_KEY itself). aistupidlevel sets
it. Other providers are unchanged. Tests cover sync and async, and that the provider's
own key is sent when both are present.

This branch has not been deployed

No deployments
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