feat(cognition): give Cognition its own provider identity - #37743
Conversation
Cognition serves an OpenAI-compatible /v1/chat/completions endpoint, so it has been onboarded as custom_llm_provider: openai. That books its traffic as OpenAI, which means OpenAI-specific cost discounts and provider-level reporting apply to it. Registers cognition through the JSON provider registry: a providers.json entry with COGNITION_API_KEY and COGNITION_API_BASE, LlmProviders.COGNITION, the constants.py provider lists, cost map entries for swe-1.6 and swe-1.7, the provider endpoints matrix, the dashboard provider fields, and tests. JSON providers can now also be resolved from their base url alone, so an api_base pointing at a known provider no longer falls through to an unresolved provider.
Greptile SummaryThe PR gives Cognition a distinct OpenAI-compatible provider identity and adds its pricing, endpoint metadata, provider-creation fields, dashboard mappings, and regression coverage.
Confidence Score: 5/5The PR appears safe to merge because no blocking failure remains within the eligible follow-up scope. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| litellm/litellm_core_utils/get_llm_provider_logic.py | Extends known-base-URL inference to JSON-registered OpenAI-compatible providers. |
| litellm/llms/openai_like/providers.json | Registers Cognition’s default endpoint and credential environment variables. |
| model_prices_and_context_window.json | Adds built-in pricing and capability metadata for Cognition SWE-1.6 and SWE-1.7. |
| litellm/proxy/public_endpoints/provider_create_fields.json | Makes Cognition selectable through the public provider-fields contract. |
| ui/litellm-dashboard/src/components/provider_info_helpers.tsx | Adds Cognition to dashboard provider mappings and model placeholders. |
| tests/test_litellm/llms/openai_like/test_cognition_provider.py | Covers Cognition registration, provider inference, credentials, pricing, and routed cost attribution. |
Reviews (4): Last reviewed commit: "docs(cognition): tick the responses colu..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The swe-1.7 rates were carried over from the closed prior attempt and match SWE-1.7 Lightning, 5x the SWE-1.7 Max and Medium rates the vendor publishes. swe-1.6 was already on the standard tier, so the two entries disagreed with each other. Both now read 0.5 in, 2.5 out, 0.2 cached per million tokens. Also drops the redundant registry comment in constants.py.
…upport The swe-1.7 rates were briefly lowered to the standard tier. The docs page records the API-served swe-1.7 as the Cerebras-served Lightning tier, so put the matching rates back rather than have the cost map and the docs disagree. Cognition also answers /v1/responses through the chat-completions bridge, the same as every other provider in the JSON registry, so the endpoints support matrix should say so instead of under-declaring it.
The support matrix says cognition serves /v1/responses, but the README row left that column blank, so the two disagreed. Every other provider row tracks the matrix, so bring this one in line.
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 6742637. Configure here.
tin-berri
left a comment
There was a problem hiding this comment.
Clean, well-scoped addition — registers Cognition as its own JSON-configured provider (same pattern as pinstripes/meta/darkbloom) so its traffic stops getting mis-booked as OpenAI for pricing/reporting. Nice generalization: instead of another hardcoded endpoint-equality branch in get_llm_provider, it adds JSONProviderRegistry.get_by_base_url so any JSON-configured provider gets auto-detection by base_url for free, and correctly preserves a caller-supplied api_key over the env-var fallback (covered by test_autodetected_api_base_keeps_the_caller_api_key). Cost-map entries are isolated from OpenAI pricing and proven end-to-end via a mocked Router spend-attribution test, not just a unit check. CI green. Approved.
TLDR
Problem this solves:
model: cognition/swe-1.7fails with "LLM Provider NOT provided"openai/workaround books Cognition traffic as OpenAIHow it solves it:
cognitionentry to the JSON provider registryLlmProviders.COGNITIONand bothconstants.pyprovider listscognition/swe-1.6andcognition/swe-1.7User Flow
Before: a
cognition/model entry fails outright, and theopenai/workaround books the traffic as OpenAImodel: cognition/swe-1.7to config.yaml and starts the proxyPOST /v1/chat/completionswith"model": "swe-1.7"LLM Provider NOT provided ... You passed model=cognition/swe-1.7model: openai/swe-1.7plus anapi_baseoverride; requests succeed, but/spend/logsand provider-level spend reports attribute the traffic toopenai, so OpenAI-specific discounts and reporting apply to itAfter: the same entry works and every report carries the
cognitionidentitymodel: cognition/swe-1.7to config.yaml (key fromCOGNITION_API_KEYorapi_key) and starts the proxyPOST /v1/chat/completionswith"model": "swe-1.7"/spend/logsrows carrycustom_llm_provider: cognitionand cost computed from the built-in SWE pricing, so provider-level reporting and discounts stay per-providerRelevant issues
Linear ticket
Resolves LIT-5348
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Cognition serves per-customer OpenAI-compatible endpoints, so the upstream stand-in here is a second LiteLLM proxy on 127.0.0.1:43117 serving model
swe-1.7backed by a realopenai/gpt-4o-minikey, with real round trips and real spend. That mirrors the load-bearing fact, which is that the endpoint is a plain/v1/chat/completionsStand-in upstream config:
Config under test, carrying the new provider and the current workaround side by side:
Before (9432f40)
The
cognition/swe-1.7deploymentcurl -s http://127.0.0.1:52941/v1/models -H "Authorization: Bearer sk-repro-lit5348"lists only the workaroundProvider attribution
openai/swe-1.7answers, so the endpoint itself is finecurl -s http://127.0.0.1:52941/model/info -H "Authorization: Bearer sk-repro-lit5348"attributes it to OpenAIBuilt-in pricing for the SWE models
After (6742637)
The
cognition/swe-1.7deployment/v1/modelsnow lists both entriesProvider attribution
curl -s http://127.0.0.1:59649/model/info -H "Authorization: Bearer sk-repro-lit5348"separates the twoBuilt-in pricing for the SWE models
Endpoint coverage behind the support matrix
The provider entry declares
/messagesand/responsesalongside/chat/completions, both served through the bridge rather than a native Cognition endpoint. Checked at the same commit so the matrix isn't claiming something the proxy won't do. There's no Before pair here because the deployment doesn't exist before the fix, which the first case already showsType
🆕 New Feature
Caveats (if any)
/v1/chat/completionsx-litellm-response-costin QA reflects the stand-in proxy's own cost header, not the new ratesswe-1.7is mapped at the Lightning rates. The standard tier is 5x cheaper and the published table doesn't say which one the API serves, so it's worth confirming against a real contract before anyone leans on the cost numbersmax_input_tokensandmax_output_tokensresponses: truereflects the chat-completions bridge, verified live against the stand-in, not a native Cognition responses endpointFinal Attestation
Note
Medium Risk
Touches provider resolution and spend attribution so Cognition traffic is no longer billed or reported as OpenAI. Routing is JSON-config based with tests, but cost numbers and endpoint coverage still depend on published rates and the chat-completions bridge.
Overview
Gives Cognition a real provider identity so
cognition/swe-1.7works without theopenai/workaround that mis-attributed spend.Registers
cognitionin the JSON OpenAI-like registry (COGNITION_API_KEY/https://api.cognition.ai/v1) and infers it from a known base URL viaJSONProviderRegistry.get_by_base_url. Adds cost map entries forcognition/swe-1.6andcognition/swe-1.7(function calling + prompt caching) so spend logs use Cognition pricing, not OpenAI discounts.Surfaces Cognition in the dashboard Add Model flow and endpoint matrix for chat, messages, and responses.
Reviewed by Cursor Bugbot for commit 6742637. Bugbot is set up for automated code reviews on this repo. Configure here.