Skip to content

feat(cognition): give Cognition its own provider identity - #37743

Merged
mateo-berri merged 4 commits into
litellm_internal_stagingfrom
litellm_cognition_provider_identity
Aug 21, 2026
Merged

feat(cognition): give Cognition its own provider identity#37743
mateo-berri merged 4 commits into
litellm_internal_stagingfrom
litellm_cognition_provider_identity

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • model: cognition/swe-1.7 fails with "LLM Provider NOT provided"
  • The openai/ workaround books Cognition traffic as OpenAI
  • OpenAI-specific cost discounts wrongly apply to that traffic
  • No built-in pricing for the SWE models

How it solves it:

  • Adds a cognition entry to the JSON provider registry
  • Registers LlmProviders.COGNITION and both constants.py provider lists
  • Infers the provider from a known registry base URL
  • Adds cost map entries for cognition/swe-1.6 and cognition/swe-1.7
  • Surfaces Cognition in provider endpoints support and the dashboard, covering chat completions, messages, and responses

User Flow

Before: a cognition/ model entry fails outright, and the openai/ workaround books the traffic as OpenAI

  1. User adds model: cognition/swe-1.7 to config.yaml and starts the proxy
  2. User sends POST /v1/chat/completions with "model": "swe-1.7"
  3. The request fails with 400: LLM Provider NOT provided ... You passed model=cognition/swe-1.7
  4. User falls back to model: openai/swe-1.7 plus an api_base override; requests succeed, but /spend/logs and provider-level spend reports attribute the traffic to openai, so OpenAI-specific discounts and reporting apply to it

After: the same entry works and every report carries the cognition identity

  1. User adds model: cognition/swe-1.7 to config.yaml (key from COGNITION_API_KEY or api_key) and starts the proxy
  2. User sends POST /v1/chat/completions with "model": "swe-1.7"
  3. The response comes back normally from the OpenAI-compatible Cognition endpoint
  4. /spend/logs rows carry custom_llm_provider: cognition and cost computed from the built-in SWE pricing, so provider-level reporting and discounts stay per-provider

Relevant issues

Linear ticket

Resolves LIT-5348

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. 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
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to 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.7 backed by a real openai/gpt-4o-mini key, with real round trips and real spend. That mirrors the load-bearing fact, which is that the endpoint is a plain /v1/chat/completions

Stand-in upstream config:

model_list:
  - model_name: swe-1.7
    litellm_params:
      model: openai/gpt-4o-mini
      api_key: os.environ/OPENAI_API_KEY
general_settings:
  master_key: sk-inner-upstream-lit5348

Config under test, carrying the new provider and the current workaround side by side:

model_list:
  - model_name: swe-1.7
    litellm_params:
      model: cognition/swe-1.7
      api_base: http://127.0.0.1:43117/v1
      api_key: sk-inner-upstream-lit5348
  - model_name: swe-workaround
    litellm_params:
      model: openai/swe-1.7
      api_base: http://127.0.0.1:43117/v1
      api_key: sk-inner-upstream-lit5348
general_settings:
  master_key: sk-repro-lit5348

Before (9432f40)

The cognition/swe-1.7 deployment

  1. Start the proxy on the config above; the router drops the deployment at startup
router.py:7779 - Error creating deployment: litellm.BadRequestError: LLM Provider NOT
provided. Pass in the LLM provider you are trying to call. You passed
model=cognition/swe-1.7 ... ignoring and continuing with other deployments.
  1. curl -s http://127.0.0.1:52941/v1/models -H "Authorization: Bearer sk-repro-lit5348" lists only the workaround
['swe-workaround']
  1. Call it anyway
$ curl -s -X POST http://127.0.0.1:52941/v1/chat/completions \
    -H "Authorization: Bearer sk-repro-lit5348" -H 'Content-Type: application/json' \
    -d '{"model":"swe-1.7","messages":[{"role":"user","content":"say hi in three words"}]}'
{"error":{"message":"litellm.BadRequestError: You passed in model=swe-1.7. There are no
healthy deployments for this model. Received Model Group=swe-1.7
Available Model Group Fallbacks=None","type":null,"param":null,"code":"400"}}
HTTP_STATUS=400

Provider attribution

  1. The same upstream through openai/swe-1.7 answers, so the endpoint itself is fine
$ curl -s -D - -X POST http://127.0.0.1:52941/v1/chat/completions \
    -H "Authorization: Bearer sk-repro-lit5348" -H 'Content-Type: application/json' \
    -d '{"model":"swe-workaround","messages":[{"role":"user","content":"say hi in three words"}]}'
HTTP/1.1 200 OK
x-litellm-model-name: openai/swe-1.7
x-litellm-model-api-base: http://127.0.0.1:43117/v1
... "content":"Hello, how are you?"
  1. curl -s http://127.0.0.1:52941/model/info -H "Authorization: Bearer sk-repro-lit5348" attributes it to OpenAI
swe-workaround -> openai/swe-1.7 | provider: openai

Built-in pricing for the SWE models

  1. Look the models up in the cost map
$ python -c "from litellm import get_model_info; get_model_info(model='cognition/swe-1.7')"
Exception: This model isn't mapped yet. model=cognition/swe-1.7
  1. A warning at startup says the same, so cost fields fall back to zero
utils.py:2907 - register_model: model=cognition/swe-1.7 not in built-in cost map and no
prefix/region variant matched; cache cost fields will default to 0

After (6742637)

The cognition/swe-1.7 deployment

  1. Start the proxy on the same config; no deployment error at startup, and /v1/models now lists both entries
$ curl -s http://127.0.0.1:59649/v1/models -H "Authorization: Bearer sk-repro-lit5348"
['swe-1.7', 'swe-workaround']
  1. Call it
$ curl -s -X POST http://127.0.0.1:59649/v1/chat/completions \
    -H "Authorization: Bearer sk-repro-lit5348" -H 'Content-Type: application/json' \
    -d '{"model":"swe-1.7","messages":[{"role":"user","content":"say hi in three words"}]}'
{"id":"chatcmpl-EF81kbd7oBF7U4eLUhGXd9rijhtTb","model":"swe-1.7","object":"chat.completion",
"choices":[{"finish_reason":"stop","index":0,"message":{"content":"Hello there, friend!",
"role":"assistant"}}],"usage":{"completion_tokens":5,"prompt_tokens":12,"total_tokens":17}}
HTTP_STATUS=200

Provider attribution

  1. The new entry answers under its own provider identity
$ curl -s -D - -X POST http://127.0.0.1:59649/v1/chat/completions \
    -H "Authorization: Bearer sk-repro-lit5348" -H 'Content-Type: application/json' \
    -d '{"model":"swe-1.7","messages":[{"role":"user","content":"say hi in three words"}]}'
HTTP/1.1 200 OK
x-litellm-model-name: cognition/swe-1.7
x-litellm-model-api-base: http://127.0.0.1:43117/v1
  1. curl -s http://127.0.0.1:59649/model/info -H "Authorization: Bearer sk-repro-lit5348" separates the two
swe-1.7 -> cognition/swe-1.7 | provider: cognition
swe-workaround -> openai/swe-1.7 | provider: openai

Built-in pricing for the SWE models

  1. Both models resolve from the cost map
$ python -c "from litellm import get_model_info; print(get_model_info(model='cognition/swe-1.7'))"
cognition/swe-1.7 provider: cognition in: 2.5e-06 out: 1.25e-05
cognition/swe-1.6 provider: cognition in: 5e-07 out: 2.5e-06
  1. Cost computes off those rates
$ python -c "from litellm.cost_calculator import cost_per_token; print(sum(cost_per_token(model='swe-1.7', custom_llm_provider='cognition', prompt_tokens=12, completion_tokens=5)))"
9.25e-05

Endpoint coverage behind the support matrix

The provider entry declares /messages and /responses alongside /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 shows

$ curl -s -X POST http://127.0.0.1:59649/v1/responses \
    -H "Authorization: Bearer sk-repro-lit5348" -H 'Content-Type: application/json' \
    -d '{"model":"swe-1.7","input":"say hi in three words"}'
HTTP_STATUS=200
{"id":"resp_ULDMbm2upSXUxPa9V7Zlrpc3zFTT-0atS79DLNpNVjxRnatxKdqCFI0HFwtqDWY9UNdwjHrp47FhMV...

$ curl -s -X POST http://127.0.0.1:59649/v1/messages \
    -H "Authorization: Bearer sk-repro-lit5348" -H 'Content-Type: application/json' \
    -d '{"model":"swe-1.7","max_tokens":32,"messages":[{"role":"user","content":"say hi in three words"}]}'
HTTP_STATUS=200
{"id":"chatcmpl-EF81oODR5HNkjrUOT8pZgjGO8bqw4","type":"message","role":"assistant","model":"swe-1.7",
"usage":{"input_tokens":12,"output_tokens":5},"content":[{"type":"text","text":"Hello there, friend!"}],
"stop_reason":"end_turn"}

Type

🆕 New Feature

Caveats (if any)

  • No shareable Cognition endpoint or key, so QA ran against a stand-in upstream serving the same plain /v1/chat/completions
  • x-litellm-response-cost in QA reflects the stand-in proxy's own cost header, not the new rates
  • swe-1.7 is 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 numbers
  • Published pricing lists no context window, so both entries omit max_input_tokens and max_output_tokens
  • responses: true reflects the chat-completions bridge, verified live against the stand-in, not a native Cognition responses endpoint
  • Docs page ships separately in litellm-docs [Bug]: Temperature parameter for non openai models don't work if the temperature is 0 #822

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

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.7 works without the openai/ workaround that mis-attributed spend.

Registers cognition in the JSON OpenAI-like registry (COGNITION_API_KEY / https://api.cognition.ai/v1) and infers it from a known base URL via JSONProviderRegistry.get_by_base_url. Adds cost map entries for cognition/swe-1.6 and cognition/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.

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-apps

greptile-apps Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR gives Cognition a distinct OpenAI-compatible provider identity and adds its pricing, endpoint metadata, provider-creation fields, dashboard mappings, and regression coverage.

  • Registers Cognition in provider resolution and shared provider registries.
  • Adds SWE-1.6 and SWE-1.7 pricing metadata.
  • Exposes Cognition through endpoint-support data and the dashboard.
  • Adds provider identity, routing, costing, and public-endpoint tests.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains within the eligible follow-up scope.

No blocking failure remains.

Important Files Changed

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

Comment thread litellm/constants.py Outdated
@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

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.
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

…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.
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

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.
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

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.

✅ 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.

@mateo-berri
mateo-berri enabled auto-merge August 21, 2026 01:36

@tin-berri tin-berri left a comment

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.

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.

@mateo-berri
mateo-berri merged commit 66a6a09 into litellm_internal_staging Aug 21, 2026
74 checks passed
@mateo-berri
mateo-berri deleted the litellm_cognition_provider_identity branch August 21, 2026 01:38
@codspeed-hq

codspeed-hq Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_cognition_provider_identity (6742637) with litellm_internal_staging (e07a712)1

Open in CodSpeed

Footnotes

  1. No successful run was found on litellm_internal_staging (6eacdbf) during the generation of this report, so e07a712 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

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