From bb7b9613cd89896b0192d7966906998bb6d77fb1 Mon Sep 17 00:00:00 2001 From: shivam Date: Sat, 8 Aug 2026 02:00:47 +0000 Subject: [PATCH 1/3] docs(cognition): add the Cognition provider page Cognition is now its own provider route on LiteLLM instead of the generic OpenAI-compatible one, so document the cognition/ models, COGNITION_API_KEY, and COGNITION_API_BASE. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- docs/providers/cognition.md | 198 ++++++++++++++++++++++++++++++++++ docs/proxy/config_settings.md | 2 + sidebars.js | 1 + 3 files changed, 201 insertions(+) create mode 100644 docs/providers/cognition.md diff --git a/docs/providers/cognition.md b/docs/providers/cognition.md new file mode 100644 index 000000000..9cdc73952 --- /dev/null +++ b/docs/providers/cognition.md @@ -0,0 +1,198 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Cognition + +## Overview + +| Property | Details | +|-------|-------| +| Description | Cognition serves its SWE coding models over an OpenAI-compatible API | +| Provider Route on LiteLLM | `cognition/` | +| Link to Provider Doc | [Cognition Documentation](https://docs.devin.ai) | +| Default Base URL | `https://api.cognition.ai/v1` | +| Supported Operations | `/chat/completions`, `/messages` through LiteLLM's Anthropic Messages adapter | + +Cognition is its own provider on LiteLLM rather than a generic OpenAI-compatible route, so its spend is priced from the Cognition cost map entries and reported under `cognition` instead of being pooled with OpenAI traffic + +## API Key + +```python showLineNumbers title="Environment Variables" +import os + +os.environ["COGNITION_API_KEY"] = "your-api-key" +os.environ["COGNITION_API_BASE"] = "https://api.cognition.ai/v1" # optional override +``` + +## Models + +| Model | Input cost / 1M tokens | Output cost / 1M tokens | +|-------|------------------------|-------------------------| +| `cognition/swe-1.7` | $2.50 | $12.50 | +| `cognition/swe-1.6` | $0.30 | $1.50 | +| `cognition/swe-1.5` | $0.30 | $1.50 | + +## Usage - LiteLLM Python SDK + +### Chat Completions + +```python showLineNumbers title="Cognition Chat Completion" +import os +from litellm import completion + +os.environ["COGNITION_API_KEY"] = "your-api-key" + +response = completion( + model="cognition/swe-1.7", + messages=[{"role": "user", "content": "Write a python function that reverses a string"}], +) + +print(response.choices[0].message.content) +``` + +### Streaming + +```python showLineNumbers title="Cognition Streaming Chat Completion" +import os +from litellm import completion + +os.environ["COGNITION_API_KEY"] = "your-api-key" + +response = completion( + model="cognition/swe-1.7", + messages=[{"role": "user", "content": "Explain a binary search in two sentences"}], + stream=True, +) + +for chunk in response: + print(chunk) +``` + +### Tool Calling + +```python showLineNumbers title="Cognition Tool Calling" +import os +from litellm import completion + +os.environ["COGNITION_API_KEY"] = "your-api-key" + +tools = [ + { + "type": "function", + "function": { + "name": "run_tests", + "description": "Run the test suite for a package", + "parameters": { + "type": "object", + "properties": {"package": {"type": "string", "description": "Package name"}}, + "required": ["package"], + }, + }, + } +] + +response = completion( + model="cognition/swe-1.7", + messages=[{"role": "user", "content": "Run the tests for the billing package"}], + tools=tools, + tool_choice="auto", +) + +print(response.choices[0].message.tool_calls) +``` + +## Usage - LiteLLM Proxy + +Add Cognition to your LiteLLM Proxy configuration: + +```yaml showLineNumbers title="config.yaml" +model_list: + - model_name: swe-1.7 + litellm_params: + model: cognition/swe-1.7 + api_key: os.environ/COGNITION_API_KEY + +general_settings: + master_key: os.environ/LITELLM_MASTER_KEY +``` + +Start the proxy: + +```bash showLineNumbers title="Start LiteLLM Proxy" +export COGNITION_API_KEY="your-api-key" +export LITELLM_MASTER_KEY="sk-local-cognition" +litellm --config config.yaml --port 4000 + +# RUNNING on http://0.0.0.0:4000 +``` + + + + +```python showLineNumbers title="Cognition via Proxy - OpenAI SDK" +from openai import OpenAI + +client = OpenAI( + base_url="http://localhost:4000", + api_key="sk-local-cognition", +) + +response = client.chat.completions.create( + model="swe-1.7", + messages=[{"role": "user", "content": "hello from litellm"}], +) + +print(response.choices[0].message.content) +``` + + + + + +```bash showLineNumbers title="Cognition via Proxy - cURL" +curl http://localhost:4000/v1/chat/completions \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $LITELLM_MASTER_KEY" \ + -d '{ + "model": "swe-1.7", + "messages": [{"role": "user", "content": "hello from litellm"}] + }' +``` + + + + +You can also add Cognition from the Admin UI. Go to Models, then Add Model, pick Cognition as the provider, choose one of the `cognition/` models, and paste your key + +## Anthropic Messages Compatibility + +LiteLLM translates Anthropic Messages-shaped requests into Cognition chat completions, both through the SDK facade and the proxy's `/v1/messages` endpoint: + +```bash showLineNumbers title="Anthropic Messages through LiteLLM Proxy" +curl http://localhost:4000/v1/messages \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $LITELLM_MASTER_KEY" \ + -H "anthropic-version: 2023-06-01" \ + -d '{ + "model": "swe-1.7", + "max_tokens": 128, + "messages": [{"role": "user", "content": "hello from litellm"}] + }' +``` + +## Cost Tracking + +The `cognition/` models are registered in LiteLLM's model cost map, so per-request spend is computed automatically, returned in the `x-litellm-response-cost` response header, and recorded in spend logs under provider `cognition`. Discounts and reports configured for OpenAI do not apply to this traffic + +## Custom Endpoints + +If your Cognition endpoint is hosted elsewhere, set `COGNITION_API_BASE` or pass `api_base` per deployment; the `cognition/` route keeps the provider identity and pricing either way + +```yaml showLineNumbers title="config.yaml" +model_list: + - model_name: swe-1.7 + litellm_params: + model: cognition/swe-1.7 + api_base: https://your-cognition-endpoint/v1 + api_key: os.environ/COGNITION_API_KEY +``` diff --git a/docs/proxy/config_settings.md b/docs/proxy/config_settings.md index 72424c20e..9f0c81787 100644 --- a/docs/proxy/config_settings.md +++ b/docs/proxy/config_settings.md @@ -608,6 +608,8 @@ router_settings: | CLOUDZERO_MAX_FETCHED_DATA_RECORDS | Maximum number of data records to fetch from CloudZero | CLOUDZERO_TIMEZONE | Timezone for date handling (default: UTC) | CODESTRAL_API_BASE | Base URL for Codestral. Default is https://codestral.mistral.ai/v1 +| COGNITION_API_BASE | Base URL for Cognition. Default is https://api.cognition.ai/v1 +| COGNITION_API_KEY | API key for Cognition | COMETAPI_API_BASE | Base URL for CometAPI, read after `COMETAPI_BASE_URL`. Default is https://api.cometapi.com/v1 | COMETAPI_API_KEY | API key for CometAPI, read after `COMETAPI_KEY` | COMETAPI_BASE_URL | Base URL for CometAPI image generation, read before `COMETAPI_API_BASE` diff --git a/sidebars.js b/sidebars.js index 47f892cd5..97191e074 100644 --- a/sidebars.js +++ b/sidebars.js @@ -1080,6 +1080,7 @@ const sidebars = { "providers/clarifai", "providers/cloudflare_workers", "providers/codestral", + "providers/cognition", "providers/cohere", "providers/cometapi", "providers/compactifai", From f408d13c24cfcb56ca3a4eaecbea85f22faf6dd8 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 20 Aug 2026 13:43:25 -0700 Subject: [PATCH 2/3] docs(cognition): correct SWE pricing to the published table and note per-customer endpoints --- docs/providers/cognition.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/providers/cognition.md b/docs/providers/cognition.md index 9cdc73952..8f317147b 100644 --- a/docs/providers/cognition.md +++ b/docs/providers/cognition.md @@ -26,11 +26,12 @@ os.environ["COGNITION_API_BASE"] = "https://api.cognition.ai/v1" # optional ove ## Models -| Model | Input cost / 1M tokens | Output cost / 1M tokens | -|-------|------------------------|-------------------------| -| `cognition/swe-1.7` | $2.50 | $12.50 | -| `cognition/swe-1.6` | $0.30 | $1.50 | -| `cognition/swe-1.5` | $0.30 | $1.50 | +| Model | Input / 1M tokens | Output / 1M tokens | Cache read / 1M tokens | +|-------|-------------------|--------------------|------------------------| +| `cognition/swe-1.7` | $2.50 | $12.50 | $1.00 | +| `cognition/swe-1.6` | $0.50 | $2.50 | $0.20 | + +Pricing follows the [Cognition model pricing table](https://docs.devin.ai/windsurf/plugins/cascade/models). API-served `swe-1.7` is the Cerebras-served SWE-1.7 Lightning tier. If your contract prices differ, set `input_cost_per_token` / `output_cost_per_token` on the deployment and those override the cost map ## Usage - LiteLLM Python SDK @@ -186,7 +187,7 @@ The `cognition/` models are registered in LiteLLM's model cost map, so per-reque ## Custom Endpoints -If your Cognition endpoint is hosted elsewhere, set `COGNITION_API_BASE` or pass `api_base` per deployment; the `cognition/` route keeps the provider identity and pricing either way +Cognition provisions API endpoints per customer today, so most deployments should set `COGNITION_API_BASE` or pass `api_base` explicitly with the base URL from your Cognition onboarding. `https://api.cognition.ai/v1` is the conventional default used when neither is set. The `cognition/` route keeps the provider identity and pricing either way ```yaml showLineNumbers title="config.yaml" model_list: From 52892ff76e206bf313162f549bed9056cc4c2f10 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 20 Aug 2026 19:43:43 -0700 Subject: [PATCH 3/3] docs(cognition): swe-1.7 is the standard tier, swe-1.7-lightning is the 5x one Cognition's model list at https://docs.devin.ai/desktop/models has uid swe-1-7 at $0.50 in / $2.50 out per million with $0.20 cache reads, and uid swe-1-7-lightning at $2.50 / $12.50 with $1.00. The page had the Lightning numbers under the plain swe-1.7 row and no row for Lightning itself. Matches the cost map correction in BerriAI/litellm#37763. --- docs/providers/cognition.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/providers/cognition.md b/docs/providers/cognition.md index 8f317147b..2ee4529a2 100644 --- a/docs/providers/cognition.md +++ b/docs/providers/cognition.md @@ -28,10 +28,11 @@ os.environ["COGNITION_API_BASE"] = "https://api.cognition.ai/v1" # optional ove | Model | Input / 1M tokens | Output / 1M tokens | Cache read / 1M tokens | |-------|-------------------|--------------------|------------------------| -| `cognition/swe-1.7` | $2.50 | $12.50 | $1.00 | +| `cognition/swe-1.7` | $0.50 | $2.50 | $0.20 | +| `cognition/swe-1.7-lightning` | $2.50 | $12.50 | $1.00 | | `cognition/swe-1.6` | $0.50 | $2.50 | $0.20 | -Pricing follows the [Cognition model pricing table](https://docs.devin.ai/windsurf/plugins/cascade/models). API-served `swe-1.7` is the Cerebras-served SWE-1.7 Lightning tier. If your contract prices differ, set `input_cost_per_token` / `output_cost_per_token` on the deployment and those override the cost map +Pricing follows the [Cognition model list](https://docs.devin.ai/desktop/models). `swe-1.7` is the standard tier; `swe-1.7-lightning` is the Cerebras-served tier that answers at about 1000 tokens a second and costs 5x. If your contract prices differ, set `input_cost_per_token` / `output_cost_per_token` on the deployment and those override the cost map ## Usage - LiteLLM Python SDK