Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@ OPENSCALE_MODEL=deepseek/deepseek-v4.1-flash
# DESCRIPTION: OpenScale Chat Completions endpoint.
OPENSCALE_ENDPOINT=https://api.openscale.so/v1/chat/completions

# ------------------------------------------------------------------------------
# Standard Compute (OpenAI-compatible)
# ------------------------------------------------------------------------------
# DESCRIPTION: Standard Compute API key from https://standardcompute.com.
# STANDARDCOMPUTE_API_KEY=your-standardcompute-api-key
# DESCRIPTION: Default Standard Compute model. "StandardCompute" routes each request to the cheapest enabled model that can handle it, with automatic fallback. Pinned ids are listed at GET https://api.stdcmpt.com/v1/models.
STANDARDCOMPUTE_MODEL=StandardCompute
# DESCRIPTION: Standard Compute Chat Completions endpoint.
STANDARDCOMPUTE_ENDPOINT=https://api.stdcmpt.com/v1/chat/completions

# ------------------------------------------------------------------------------
# Ollama (local models)
# ------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ Claude Code / Cursor / Codex / Cline / Continue
| **AtmoRouter** | Cloud | Claude, GPT, Gemini, GLM, Kimi, Qwen, DeepSeek, and other OpenAI-compatible models | $-$$ |
| **Runcrate** | Cloud | DeepSeek, GLM, Kimi, Qwen, gpt-oss, and other open-weight models | $-$$ |
| **OpenScale** | Cloud | DeepSeek V4.1 Flash, GLM 5.3 Flash | $ |
| **Standard Compute** | Cloud | Routed `StandardCompute` model plus pinned Claude, GPT, Gemini, DeepSeek, GLM, Kimi, Qwen and other models | $-$$$ |
| **DeepSeek** | Cloud | DeepSeek R1, Reasoner | $ |
| **Z.ai** | Cloud | GLM-4.7, GLM-4.5-Air | $ |
| **Moonshot AI** | Cloud | Kimi K2.6, Kimi K3 | $ |
Expand Down
13 changes: 12 additions & 1 deletion bin/lynkr-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,17 @@ const PROVIDERS = {
],
defaultModel: 'deepseek/deepseek-v4.1-flash',
},
standardcompute: {
label: 'Standard Compute (OpenAI-compatible)',
local: false,
creds: [
{ key: 'STANDARDCOMPUTE_API_KEY', label: 'Standard Compute API key', secret: true },
],
extras: [
{ key: 'STANDARDCOMPUTE_ENDPOINT', label: 'Chat Completions endpoint', default: 'https://api.stdcmpt.com/v1/chat/completions' },

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.

maintainability · low
The 'standardcompute' provider entry includes a hardcoded default endpoint URL ('https://api.stdcmpt.com/v1/chat/completions'). This should ideally be configurable via environment variables or configuration files to support different deployments or testing environments.

Suggestion:

Suggested change
{ key: 'STANDARDCOMPUTE_ENDPOINT', label: 'Chat Completions endpoint', default: 'https://api.stdcmpt.com/v1/chat/completions' },
{ key: 'STANDARDCOMPUTE_ENDPOINT', label: 'Chat Completions endpoint', default: process.env.STANDARDCOMPUTE_ENDPOINT || 'https://api.stdcmpt.com/v1/chat/completions' },

],
defaultModel: 'StandardCompute',
},
openrouter: {
label: 'OpenRouter (100+ models, one key)',
local: false,
Expand Down Expand Up @@ -250,7 +261,7 @@ const PROVIDERS = {

const PROVIDER_ORDER = [
'ollama', 'llamacpp', 'lmstudio',
'azure-anthropic', 'azure-openai', 'openai', 'atlas', 'cheaperinference', 'atmorouter', 'runcrate', 'openscale', 'openrouter', 'edenai',
'azure-anthropic', 'azure-openai', 'openai', 'atlas', 'cheaperinference', 'atmorouter', 'runcrate', 'openscale', 'standardcompute', 'openrouter', 'edenai',
'databricks', 'bedrock', 'vertex', 'zai', 'moonshot', 'baidu', 'fireworks', 'orcarouter',
];
const TIERS = ['SIMPLE', 'MEDIUM', 'COMPLEX', 'REASONING'];
Expand Down
36 changes: 36 additions & 0 deletions documentation/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,42 @@ TIER_REASONING=openscale:deepseek/deepseek-v4.1-flash

---

### 8f. Standard Compute (OpenAI-Compatible)

**Best for:** One key for a routed model plus pinned open and frontier models, through Lynkr's static or tier-based routing

#### Configuration

```env
MODEL_PROVIDER=standardcompute
STANDARDCOMPUTE_API_KEY=your-standardcompute-api-key
STANDARDCOMPUTE_MODEL=StandardCompute
STANDARDCOMPUTE_ENDPOINT=https://api.stdcmpt.com/v1/chat/completions
```

Create a key at [standardcompute.com](https://standardcompute.com). The endpoint is OpenAI-compatible, so Lynkr converts Anthropic messages and tools to Chat Completions requests and transforms streamed OpenAI SSE events back to Anthropic events.

The default model `StandardCompute` is routed: each request goes to the cheapest enabled model that can handle it, with automatic fallback. To pin a model, set its id instead. Standard Compute can also be selected per tier:

```env
TIER_SIMPLE=standardcompute:StandardCompute
TIER_MEDIUM=standardcompute:deepseek/deepseek-v4.1-flash
TIER_COMPLEX=standardcompute:z-ai/glm-5.3
TIER_REASONING=standardcompute:moonshotai/kimi-k3
```

`STANDARDCOMPUTE_MODEL` is the static-routing default. A model named in `TIER_*` takes precedence for that tier. The full model list is public at `GET https://api.stdcmpt.com/v1/models`.

#### Behavior

- Supports non-streaming and streaming Chat Completions
- Supports Anthropic-format tools through Lynkr's existing OpenAI conversion path
- Relays model reasoning as `reasoning_content`
- Uses Bearer authentication and accepts a custom `STANDARDCOMPUTE_ENDPOINT`
- Does not automatically replay billable Chat Completions POST requests

---

### 9. LM Studio (Local with GUI)

**Best for:** Local models with graphical interface
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"start:supervised": "while true; do node index.js 2>&1 | npx pino-pretty --sync; code=$?; echo \"[supervisor] lynkr exited ($code) — restarting in 3s\"; sleep 3; done",
"lint": "eslint src index.js",
"test": "npm run test:unit && npm run test:performance",
"test:unit": "LYNKR_KNN_DIR=/tmp/lynkr-test-knn DATABRICKS_API_KEY=test-key DATABRICKS_API_BASE=http://test.com LOG_FILE_ENABLED=false node --test test/routing.test.js test/hybrid-routing-integration.test.js test/retry-logic.test.js test/sse-transformer.test.js test/passthrough-stream.test.js test/passthrough-mode.test.js test/openrouter-error-resilience.test.js test/format-conversion.test.js test/azure-openai-config.test.js test/azure-openai-format-conversion.test.js test/azure-openai-routing.test.js test/azure-openai-streaming.test.js test/azure-openai-error-resilience.test.js test/azure-openai-integration.test.js test/openai-integration.test.js test/atlas-integration.test.js test/cheaperinference-integration.test.js test/atmorouter-integration.test.js test/runcrate-integration.test.js test/openscale-integration.test.js test/toon-compression.test.js test/gcf-compression.test.js test/llamacpp-integration.test.js test/resilience.test.js test/telemetry-routing.test.js test/memory/store.test.js test/memory/surprise.test.js test/memory/extractor.test.js test/memory/search.test.js test/memory/retriever.test.js test/memory/distiller.test.js test/memory/distiller-freeze.test.js test/memory/wiki.test.js test/memory/skills-cache.test.js test/memory/tencentdb-launcher.test.js test/distill.test.js test/large-payload.test.js test/prompt-cache-injection.test.js test/risk-analyzer.test.js test/interaction-block.test.js test/preflight.test.js test/token-reduction.test.js test/session-affinity.test.js test/cache-state.test.js test/cache-switch-cost.test.js test/lens-recommendations.test.js test/model-registry-cost.test.js test/output-format-guard.test.js test/tier-fallback.test.js test/wrap.test.js test/init.test.js test/tool-call-response-metadata.test.js test/degradation.test.js test/routing-telemetry-columns.test.js test/sticky-routing.test.js test/knn-ambiguous-escalate.test.js test/deescalator.test.js test/client-profiles.test.js test/openai-ingress-tool-injection.test.js test/tool-result-compression-gate.test.js test/strip-internal-fields.test.js test/complexity-tool-subtraction.test.js test/bandit.test.js test/routing-propensity.test.js test/reward-pipeline.test.js test/knn-cold-start.test.js test/calibration.test.js test/feedback-loop.test.js test/session-fingerprint.test.js test/side-request-guards.test.js test/verifier.test.js test/intent-score.test.js test/difficulty-classifier.test.js test/classifier-setup.test.js test/usage-stats.test.js test/loop-guard.test.js test/moonshot-model-mapping.test.js test/baidu-model-mapping.test.js test/tenant-policy-ingress-parity.test.js test/decide.test.js test/embeddings-degradation.test.js test/health-probe.test.js test/stuck-detector.test.js test/onnx-embedder.test.js test/ope.test.js test/hierarchical-budget.test.js test/token-rate-limit.test.js test/otel-export.test.js test/mcp-broker.test.js test/compression-budget.test.js test/gpt-utils.test.js test/dedup-observe-only.test.js test/context-window-header.test.js test/token-budget-auto.test.js test/opencode-setup.test.js test/auth-mode-first-party.test.js test/harness-envelope.test.js test/task-ledger.test.js test/jev-router.test.js test/jev-routing.test.js test/force-patterns.test.js test/upstream-fidelity.test.js test/tool-schema-compression.test.js test/tool-strict-preservation.test.js test/passthrough-route.test.js test/quota-ledger.test.js test/shortfall-semantic.test.js test/routing-decisions.test.js test/routing-corpus.test.js test/switch-gate-grounding.test.js",
"test:unit": "LYNKR_KNN_DIR=/tmp/lynkr-test-knn DATABRICKS_API_KEY=test-key DATABRICKS_API_BASE=http://test.com LOG_FILE_ENABLED=false node --test test/routing.test.js test/hybrid-routing-integration.test.js test/retry-logic.test.js test/sse-transformer.test.js test/passthrough-stream.test.js test/passthrough-mode.test.js test/openrouter-error-resilience.test.js test/format-conversion.test.js test/azure-openai-config.test.js test/azure-openai-format-conversion.test.js test/azure-openai-routing.test.js test/azure-openai-streaming.test.js test/azure-openai-error-resilience.test.js test/azure-openai-integration.test.js test/openai-integration.test.js test/atlas-integration.test.js test/cheaperinference-integration.test.js test/atmorouter-integration.test.js test/runcrate-integration.test.js test/openscale-integration.test.js test/standardcompute-integration.test.js test/toon-compression.test.js test/gcf-compression.test.js test/llamacpp-integration.test.js test/resilience.test.js test/telemetry-routing.test.js test/memory/store.test.js test/memory/surprise.test.js test/memory/extractor.test.js test/memory/search.test.js test/memory/retriever.test.js test/memory/distiller.test.js test/memory/distiller-freeze.test.js test/memory/wiki.test.js test/memory/skills-cache.test.js test/memory/tencentdb-launcher.test.js test/distill.test.js test/large-payload.test.js test/prompt-cache-injection.test.js test/risk-analyzer.test.js test/interaction-block.test.js test/preflight.test.js test/token-reduction.test.js test/session-affinity.test.js test/cache-state.test.js test/cache-switch-cost.test.js test/lens-recommendations.test.js test/model-registry-cost.test.js test/output-format-guard.test.js test/tier-fallback.test.js test/wrap.test.js test/init.test.js test/tool-call-response-metadata.test.js test/degradation.test.js test/routing-telemetry-columns.test.js test/sticky-routing.test.js test/knn-ambiguous-escalate.test.js test/deescalator.test.js test/client-profiles.test.js test/openai-ingress-tool-injection.test.js test/tool-result-compression-gate.test.js test/strip-internal-fields.test.js test/complexity-tool-subtraction.test.js test/bandit.test.js test/routing-propensity.test.js test/reward-pipeline.test.js test/knn-cold-start.test.js test/calibration.test.js test/feedback-loop.test.js test/session-fingerprint.test.js test/side-request-guards.test.js test/verifier.test.js test/intent-score.test.js test/difficulty-classifier.test.js test/classifier-setup.test.js test/usage-stats.test.js test/loop-guard.test.js test/moonshot-model-mapping.test.js test/baidu-model-mapping.test.js test/tenant-policy-ingress-parity.test.js test/decide.test.js test/embeddings-degradation.test.js test/health-probe.test.js test/stuck-detector.test.js test/onnx-embedder.test.js test/ope.test.js test/hierarchical-budget.test.js test/token-rate-limit.test.js test/otel-export.test.js test/mcp-broker.test.js test/compression-budget.test.js test/gpt-utils.test.js test/dedup-observe-only.test.js test/context-window-header.test.js test/token-budget-auto.test.js test/opencode-setup.test.js test/auth-mode-first-party.test.js test/harness-envelope.test.js test/task-ledger.test.js test/jev-router.test.js test/jev-routing.test.js test/force-patterns.test.js test/upstream-fidelity.test.js test/tool-schema-compression.test.js test/passthrough-route.test.js test/quota-ledger.test.js test/shortfall-semantic.test.js test/routing-decisions.test.js test/routing-corpus.test.js test/switch-gate-grounding.test.js",
"test:memory": "LYNKR_KNN_DIR=/tmp/lynkr-test-knn DATABRICKS_API_KEY=test-key DATABRICKS_API_BASE=http://test.com node --test test/memory/store.test.js test/memory/surprise.test.js test/memory/extractor.test.js test/memory/search.test.js test/memory/retriever.test.js test/memory/distiller.test.js test/memory/distiller-freeze.test.js test/memory/wiki.test.js test/memory/skills-cache.test.js test/memory/tencentdb-launcher.test.js",
"test:new-features": "LYNKR_KNN_DIR=/tmp/lynkr-test-knn DATABRICKS_API_KEY=test-key DATABRICKS_API_BASE=http://test.com node --test test/passthrough-mode.test.js test/openrouter-error-resilience.test.js test/format-conversion.test.js",
"test:performance": "LYNKR_KNN_DIR=/tmp/lynkr-test-knn DATABRICKS_API_KEY=test-key DATABRICKS_API_BASE=http://test.com node test/hybrid-routing-performance.test.js && DATABRICKS_API_KEY=test-key DATABRICKS_API_BASE=http://test.com node test/performance-tests.js",
Expand Down
13 changes: 13 additions & 0 deletions src/api/providers-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@ async function getConfiguredProviders() {
});
}

// Check Standard Compute (OpenAI-compatible Chat Completions)
if (config.standardcompute?.apiKey) {
providers.push({
name: "standardcompute",
type: "standardcompute",
baseUrl: config.standardcompute.endpoint || "https://api.stdcmpt.com/v1/chat/completions",

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.

maintainability · medium
Hardcoded URL string 'https://api.stdcmpt.com/v1/chat/completions' appears in multiple files (providers-handler.js, orchestrator/index.js). If this endpoint changes, it requires updates in multiple places. Consider moving this to a configuration constant or config object to avoid duplication and ensure consistency.

Suggestion:

Suggested change
baseUrl: config.standardcompute.endpoint || "https://api.stdcmpt.com/v1/chat/completions",
const STANDARD_COMPUTE_ENDPOINT = 'https://api.stdcmpt.com/v1/chat/completions';
... // later
baseUrl: config.standardcompute.endpoint || STANDARD_COMPUTE_ENDPOINT,

enabled: true,
models: [
{ id: config.standardcompute.model || "StandardCompute", name: "Configured Model" },
]
});
}

// Check OpenRouter
if (config.openrouter?.apiKey) {
providers.push({
Expand Down
68 changes: 68 additions & 0 deletions src/clients/databricks.js
Original file line number Diff line number Diff line change
Expand Up @@ -1998,6 +1998,72 @@ async function invokeOpenScale(body) {
return response;
}

async function invokeStandardCompute(body) {
if (!config.standardcompute?.apiKey) {
throw new Error("Standard Compute API key is not configured.");
}

const {
convertAnthropicToolsToOpenRouter,
convertAnthropicMessagesToOpenRouter
} = require("./openrouter-utils");
Comment on lines +2001 to +2009

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.

maintainability · medium
The conditional require('openrouter-utils') inside invokeStandardCompute may cause runtime errors if the file doesn't exist or exports change. It should be moved to the top of the file like other imports for consistency and earlier failure detection.

Suggestion:

Suggested change
async function invokeStandardCompute(body) {
if (!config.standardcompute?.apiKey) {
throw new Error("Standard Compute API key is not configured.");
}
const {
convertAnthropicToolsToOpenRouter,
convertAnthropicMessagesToOpenRouter
} = require("./openrouter-utils");
Move the require to the top of the file with other imports instead of inside the function.


const endpoint = config.standardcompute.endpoint || "https://api.stdcmpt.com/v1/chat/completions";

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.

maintainability · low
The endpoint default 'https://api.stdcmpt.com/v1/chat/completions' is hardcoded in two places: here and in config/index.js. This is consistent with how other providers are configured. Consider documenting this URL in the config file alongside other provider endpoints for easier discovery.

const headers = {
"Authorization": `Bearer ${config.standardcompute.apiKey}`,
"Content-Type": "application/json",
};

const messages = convertAnthropicMessagesToOpenRouter(body.messages || []);
if (body.system) {
messages.unshift({ role: "system", content: body.system });
}

const standardComputeBody = {
model: body._suggestionModeModel || body._tierModel || config.standardcompute.model || "StandardCompute",
messages,
temperature: body.temperature ?? 0.7,
max_tokens: body.max_tokens ?? 16384,

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.

performance · low
max_tokens defaults to 16384, which is consistent with other providers in the codebase (e.g., atmorouter, openscale, runcrate). However, providers may have different limits. Consider documenting the expected max_tokens range for StandardCompute in comments.

top_p: body.top_p ?? 1.0,
stream: body.stream ?? false,
};

const toolsToSend = Array.isArray(body.tools) ? body.tools : [];

if (toolsToSend.length > 0) {
standardComputeBody.tools = convertAnthropicToolsToOpenRouter(toolsToSend);
standardComputeBody.parallel_tool_calls = false;
standardComputeBody.tool_choice = forwardToolChoice(body);

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.

maintainability · medium
The forwardToolChoice function is called but not imported at the top of the file. While it appears to be defined elsewhere in the file (line 1755) and exported, relying on a function definition that comes after this code path is a code organization anti-pattern. This could cause issues if the file is refactored. Consider either: (1) importing forwardToolChoice if it's available in a shared module, or (2) moving the definition closer to its first usage.

Suggestion:

Suggested change
standardComputeBody.tool_choice = forwardToolChoice(body);
import { forwardToolChoice } from './shared-tool-utils'; // or similar shared module

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.

maintainability · low
The forwardToolChoice function is defined at line 55 in the same file, so it is available when called here. No action needed.

}

logger.debug({
endpoint,
model: standardComputeBody.model,
hasTools: !!standardComputeBody.tools,
toolCount: standardComputeBody.tools?.length || 0,
temperature: standardComputeBody.temperature,
max_tokens: standardComputeBody.max_tokens,
}, "=== STANDARDCOMPUTE REQUEST ===");

// Chat completions are billable POSTs, so Standard Compute requests are never
// replayed automatically (same policy as invokeAtmoRouter). A 429 is thrown
// so invokeModel's caller can escalate to a different provider/tier.
const response = await performJsonRequest(endpoint, {
headers,
body: standardComputeBody,
maxRetriesOverride: 0,
retryableStatusesOverride: [],
}, "Standard Compute");

if (!response.ok && response.status === 429) {
const err = new Error(`Standard Compute rate-limited: ${String(response.json?.error?.message || '').slice(0, 120)}`);
err.status = 429;
throw err;
}

return response;
}

async function invokeLlamaCpp(body, _incomingHeaders = {}) {
if (!config.llamacpp?.endpoint) {
throw new Error("llama.cpp endpoint is not configured.");
Expand Down Expand Up @@ -4029,6 +4095,7 @@ const PROVIDER_INVOKERS = {
atmorouter: invokeAtmoRouter,
runcrate: invokeRuncrate,
openscale: invokeOpenScale,
standardcompute: invokeStandardCompute,
llamacpp: invokeLlamaCpp,
lmstudio: invokeLMStudio,
bedrock: invokeBedrock,
Expand Down Expand Up @@ -4968,6 +5035,7 @@ module.exports = {
invokeAtmoRouter,
invokeRuncrate,
invokeOpenScale,
invokeStandardCompute,
invokeOrcaRouter,
invokeCursor,
PROVIDER_INVOKERS,
Expand Down
2 changes: 1 addition & 1 deletion src/clients/provider-capabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const NATIVE_THINKING_BEDROCK_MODELS = [
"claude-haiku",
];

const REASONING_CONTENT_PROVIDERS = new Set(["moonshot", "openrouter", "edenai", "openai", "azure-openai", "atlas", "cheaperinference", "atmorouter", "runcrate", "openscale", "orcarouter"]);
const REASONING_CONTENT_PROVIDERS = new Set(["moonshot", "openrouter", "edenai", "openai", "azure-openai", "atlas", "cheaperinference", "atmorouter", "runcrate", "openscale", "standardcompute", "orcarouter"]);

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.

maintainability · medium
The addition of 'standardcompute' to REASONING_CONTENT_PROVIDERS is consistent with other providers. However, verify that StandardCompute actually supports reasoning content by checking the provider documentation. If not, remove it from this set.


function supportsNativeThinking(providerType, model) {
if (NATIVE_THINKING_PROVIDERS.has(providerType)) return true;
Expand Down
Loading
Loading