Skip to content

Commit 66a6a09

Browse files
authored
Merge pull request #37743 from BerriAI/litellm_cognition_provider_identity
feat(cognition): give Cognition its own provider identity
2 parents dad4c1a + 6742637 commit 66a6a09

15 files changed

Lines changed: 333 additions & 0 deletions

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ curl -X POST 'http://0.0.0.0:4000/v1/chat/completions' \
292292
| [Clarifai (`clarifai`)](https://docs.litellm.ai/docs/providers/clarifai) |||| | | | | | | |
293293
| [Cloudflare AI Workers (`cloudflare`)](https://docs.litellm.ai/docs/providers/cloudflare_workers) |||| | | | | | | |
294294
| [Codestral (`codestral`)](https://docs.litellm.ai/docs/providers/codestral) |||| | | | | | | |
295+
| [Cognition (`cognition`)](https://docs.litellm.ai/docs/providers/cognition) |||| | | | | | | |
295296
| [Cohere (`cohere`)](https://docs.litellm.ai/docs/providers/cohere) ||||| | | | | ||
296297
| [Cohere Chat (`cohere_chat`)](https://docs.litellm.ai/docs/providers/cohere) |||| | | | | | | |
297298
| [CometAPI (`cometapi`)](https://docs.litellm.ai/docs/providers/cometapi) ||||| | | | | | |

litellm/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,7 @@
779779
"https://api.libertai.io/v1",
780780
"https://pinstripes.io/v1",
781781
"https://api.meta.ai/v1",
782+
"https://api.cognition.ai/v1",
782783
]
783784

784785

@@ -846,6 +847,7 @@
846847
"pinstripes", # Pinstripes - JSON-configured provider
847848
"darkbloom",
848849
"meta", # Meta Model API (Muse Spark) - JSON-configured provider
850+
"cognition",
849851
]
850852
openai_text_completion_compatible_providers: Final[list] = [ # providers that support `/v1/completions`
851853
"together_ai",

litellm/litellm_core_utils/get_llm_provider_logic.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,9 @@ def get_llm_provider(
349349
elif endpoint == "https://api.meta.ai/v1":
350350
custom_llm_provider = "meta"
351351
dynamic_api_key = get_secret_str("META_API_KEY")
352+
elif (json_provider := JSONProviderRegistry.get_by_base_url(endpoint)) is not None:
353+
custom_llm_provider = json_provider.slug
354+
dynamic_api_key = api_key if api_key is not None else get_secret_str(json_provider.api_key_env)
352355

353356
if api_base is not None and not isinstance(api_base, str):
354357
raise Exception(f"api base needs to be a string. api_base={api_base}")

litellm/llms/openai_like/json_loader.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ def exists(cls, slug: str) -> bool:
6565
"""Check if a provider is defined via JSON"""
6666
return slug in cls._providers
6767

68+
@classmethod
69+
def get_by_base_url(cls, base_url: str) -> SimpleProviderConfig | None:
70+
"""Get a provider configuration by its default base url"""
71+
return next((provider for provider in cls._providers.values() if provider.base_url == base_url), None)
72+
6873
@classmethod
6974
def supports_responses_api(cls, slug: str) -> bool:
7075
"""Check if a JSON provider supports the Responses API"""

litellm/llms/openai_like/providers.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@
175175
"base_class": "openai_gpt",
176176
"supported_endpoints": ["/v1/chat/completions", "/v1/responses", "/v1/messages"]
177177
},
178+
"cognition": {
179+
"base_url": "https://api.cognition.ai/v1",
180+
"api_key_env": "COGNITION_API_KEY",
181+
"api_base_env": "COGNITION_API_BASE"
182+
},
178183
"pinstripes": {
179184
"base_url": "https://pinstripes.io/v1",
180185
"api_key_env": "PINSTRIPES_API_KEY",

litellm/model_prices_and_context_window_backup.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48938,6 +48938,26 @@
4893848938
"supports_reasoning": true,
4893948939
"supports_vision": false
4894048940
},
48941+
"cognition/swe-1.6": {
48942+
"input_cost_per_token": 5e-07,
48943+
"output_cost_per_token": 2.5e-06,
48944+
"cache_read_input_token_cost": 2e-07,
48945+
"litellm_provider": "cognition",
48946+
"mode": "chat",
48947+
"supports_function_calling": true,
48948+
"supports_prompt_caching": true,
48949+
"source": "https://docs.devin.ai/windsurf/plugins/cascade/models"
48950+
},
48951+
"cognition/swe-1.7": {
48952+
"input_cost_per_token": 2.5e-06,
48953+
"output_cost_per_token": 1.25e-05,
48954+
"cache_read_input_token_cost": 1e-06,
48955+
"litellm_provider": "cognition",
48956+
"mode": "chat",
48957+
"supports_function_calling": true,
48958+
"supports_prompt_caching": true,
48959+
"source": "https://docs.devin.ai/windsurf/plugins/cascade/models"
48960+
},
4894148961
"pinstripes/ps/glm-4.5-air": {
4894248962
"max_tokens": 128000,
4894348963
"max_input_tokens": 128000,

litellm/provider_endpoints_support_backup.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,23 @@
528528
"interactions": true
529529
}
530530
},
531+
"cognition": {
532+
"display_name": "Cognition (`cognition`)",
533+
"url": "https://docs.litellm.ai/docs/providers/cognition",
534+
"endpoints": {
535+
"chat_completions": true,
536+
"messages": true,
537+
"responses": true,
538+
"embeddings": false,
539+
"image_generations": false,
540+
"audio_transcriptions": false,
541+
"audio_speech": false,
542+
"moderations": false,
543+
"batches": false,
544+
"rerank": false,
545+
"a2a": false
546+
}
547+
},
531548
"cohere": {
532549
"display_name": "Cohere (`cohere`)",
533550
"url": "https://docs.litellm.ai/docs/providers/cohere",

litellm/proxy/public_endpoints/provider_create_fields.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,34 @@
772772
],
773773
"default_model_placeholder": "gpt-3.5-turbo"
774774
},
775+
{
776+
"provider": "Cognition",
777+
"provider_display_name": "Cognition",
778+
"litellm_provider": "cognition",
779+
"credential_fields": [
780+
{
781+
"key": "api_base",
782+
"label": "API Base",
783+
"placeholder": "https://api.cognition.ai/v1",
784+
"tooltip": null,
785+
"required": false,
786+
"field_type": "text",
787+
"options": null,
788+
"default_value": null
789+
},
790+
{
791+
"key": "api_key",
792+
"label": "API Key",
793+
"placeholder": null,
794+
"tooltip": null,
795+
"required": true,
796+
"field_type": "password",
797+
"options": null,
798+
"default_value": null
799+
}
800+
],
801+
"default_model_placeholder": "cognition/swe-1.7"
802+
},
775803
{
776804
"provider": "Cohere",
777805
"provider_display_name": "Cohere",

litellm/types/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3782,6 +3782,7 @@ class LlmProviders(str, Enum):
37823782
TENSORMESH = "tensormesh"
37833783
LIBERTAI = "libertai"
37843784
PINSTRIPES = "pinstripes"
3785+
COGNITION = "cognition"
37853786
DARKBLOOM = "darkbloom"
37863787
META = "meta"
37873788
LITELLM_AGENT = "litellm_agent"

model_prices_and_context_window.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48938,6 +48938,26 @@
4893848938
"supports_reasoning": true,
4893948939
"supports_vision": false
4894048940
},
48941+
"cognition/swe-1.6": {
48942+
"input_cost_per_token": 5e-07,
48943+
"output_cost_per_token": 2.5e-06,
48944+
"cache_read_input_token_cost": 2e-07,
48945+
"litellm_provider": "cognition",
48946+
"mode": "chat",
48947+
"supports_function_calling": true,
48948+
"supports_prompt_caching": true,
48949+
"source": "https://docs.devin.ai/windsurf/plugins/cascade/models"
48950+
},
48951+
"cognition/swe-1.7": {
48952+
"input_cost_per_token": 2.5e-06,
48953+
"output_cost_per_token": 1.25e-05,
48954+
"cache_read_input_token_cost": 1e-06,
48955+
"litellm_provider": "cognition",
48956+
"mode": "chat",
48957+
"supports_function_calling": true,
48958+
"supports_prompt_caching": true,
48959+
"source": "https://docs.devin.ai/windsurf/plugins/cascade/models"
48960+
},
4894148961
"pinstripes/ps/glm-4.5-air": {
4894248962
"max_tokens": 128000,
4894348963
"max_input_tokens": 128000,

0 commit comments

Comments
 (0)