Repository navigation
feat: add Standard Compute provider - #136
veerareddyvishal144 merged 2 commits into
Conversation
Adds Standard Compute as an OpenAI-compatible provider (STANDARDCOMPUTE_API_KEY, STANDARDCOMPUTE_MODEL, STANDARDCOMPUTE_ENDPOINT), following the Runcrate and OpenScale provider shape: config, routing, client invoker, SSE transform, reasoning content, lynkr-init, providers API, docs and an integration test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🔍 OpenCodeReview found 4 issue(s) in this PR.
|
| providers.push({ | ||
| name: "standardcompute", | ||
| type: "standardcompute", | ||
| baseUrl: config.standardcompute.endpoint || "https://api.stdcmpt.com/v1/chat/completions", |
There was a problem hiding this comment.
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:
| 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, |
| convertAnthropicMessagesToOpenRouter | ||
| } = require("./openrouter-utils"); | ||
|
|
||
| const endpoint = config.standardcompute.endpoint || "https://api.stdcmpt.com/v1/chat/completions"; |
There was a problem hiding this comment.
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.
| model: body._suggestionModeModel || body._tierModel || config.standardcompute.model || "StandardCompute", | ||
| messages, | ||
| temperature: body.temperature ?? 0.7, | ||
| max_tokens: body.max_tokens ?? 16384, |
| if (toolsToSend.length > 0) { | ||
| standardComputeBody.tools = convertAnthropicToolsToOpenRouter(toolsToSend); | ||
| standardComputeBody.parallel_tool_calls = false; | ||
| standardComputeBody.tool_choice = forwardToolChoice(body); |
There was a problem hiding this comment.
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:
| standardComputeBody.tool_choice = forwardToolChoice(body); | |
| import { forwardToolChoice } from './shared-tool-utils'; // or similar shared module |
| if (toolsToSend.length > 0) { | ||
| standardComputeBody.tools = convertAnthropicToolsToOpenRouter(toolsToSend); | ||
| standardComputeBody.parallel_tool_calls = false; | ||
| standardComputeBody.tool_choice = forwardToolChoice(body); |
| ]; | ||
|
|
||
| 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"]); |
| case 'openscale': | ||
| return config.openscale?.endpoint ?? 'https://api.openscale.so/v1/chat/completions'; | ||
| case 'standardcompute': | ||
| return config.standardcompute?.endpoint ?? 'https://api.stdcmpt.com/v1/chat/completions'; |
There was a problem hiding this comment.
The endpoint URL 'https://api.stdcmpt.com/v1/chat/completions' is hardcoded in this file. This duplicates the value in providers-handler.js. Consider moving this to a constants file or config object to avoid duplication and potential inconsistencies.
Suggestion:
| return config.standardcompute?.endpoint ?? 'https://api.stdcmpt.com/v1/chat/completions'; | |
| const STANDARD_COMPUTE_ENDPOINT = 'https://api.stdcmpt.com/v1/chat/completions'; | |
| // Use STANDARD_COMPUTE_ENDPOINT instead of inline string |
|
Thanks for the review. I went through all 7 findings and didn't change code this time:
|
| { 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' }, |
There was a problem hiding this comment.
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:
| { 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' }, |
| async function invokeStandardCompute(body) { | ||
| if (!config.standardcompute?.apiKey) { | ||
| throw new Error("Standard Compute API key is not configured."); | ||
| } | ||
|
|
||
| const { | ||
| convertAnthropicToolsToOpenRouter, | ||
| convertAnthropicMessagesToOpenRouter | ||
| } = require("./openrouter-utils"); |
There was a problem hiding this comment.
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:
| 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 localProviders = ["ollama", "llamacpp", "lmstudio"]; | ||
| if (localProviders.includes(fallbackProvider)) { | ||
| throw new Error(`FALLBACK_PROVIDER cannot be '${fallbackProvider}' (local providers should not be fallbacks). Use cloud providers: databricks, azure-anthropic, azure-openai, openrouter, edenai, openai, atlas, cheaperinference, atmorouter, runcrate, openscale, bedrock, orcarouter`); | ||
| throw new Error(`FALLBACK_PROVIDER cannot be '${fallbackProvider}' (local providers should not be fallbacks). Use cloud providers: databricks, azure-anthropic, azure-openai, openrouter, edenai, openai, atlas, cheaperinference, atmorouter, runcrate, openscale, standardcompute, bedrock, orcarouter`); |
There was a problem hiding this comment.
The error message for FALLBACK_PROVIDER contains a long, hardcoded list of cloud providers. This list needs manual updates whenever providers are added or removed, increasing the risk of inconsistency between the error message and the actual supported providers list (SUPPORTED_MODEL_PROVIDERS). Consider deriving this list programmatically or using a centralized configuration.
| clean.tools = ensureAnthropicToolFormat(clean.tools); | ||
| } | ||
| } else if (providerType === "azure-openai" || providerType === "openai" || providerType === "atlas" || providerType === "cheaperinference" || providerType === "atmorouter" || providerType === "runcrate" || providerType === "openscale") { | ||
| } else if (providerType === "azure-openai" || providerType === "openai" || providerType === "atlas" || providerType === "cheaperinference" || providerType === "atmorouter" || providerType === "runcrate" || providerType === "openscale" || providerType === "standardcompute") { |
Adds Standard Compute as an OpenAI-compatible provider, following the same shape as the Runcrate provider (#133) and the OpenScale provider.
What it adds
MODEL_PROVIDER=standardcomputewithSTANDARDCOMPUTE_API_KEY,STANDARDCOMPUTE_MODELandSTANDARDCOMPUTE_ENDPOINT(defaulthttps://api.stdcmpt.com/v1/chat/completions)StandardCompute, which is routed: each request goes to the cheapest enabled model that can handle it, with automatic fallback. Pinned model ids (for exampledeepseek/deepseek-v4.1-flash,z-ai/glm-5.3,moonshotai/kimi-k3) come from the publicGET https://api.stdcmpt.com/v1/modelsand work inSTANDARDCOMPUTE_MODELorTIER_*invokeStandardComputeclient using the existing Anthropic to Chat Completions conversion, Bearer auth, no automatic replay of billable POSTs, and a thrown 429 so tier fallback can climb_enabledProviders,getBestCloudProvider), model tiers, orchestrator destination URL and tool sanitizing, OpenAI SSE transform, reasoning content,lynkr-init, and the providers API.env.example, README provider table,documentation/providers.mdsection 8ftest/standardcompute-integration.test.js(mirrors the OpenScale test) added totest:unit, plus the dispatch registry listTesting
Tests were not run locally; I am relying on CI for this PR.
Disclosure: I work on Standard Compute.
🤖 Generated with Claude Code