Skip to content

Switch generation to RunPod completions endpoint and make model optional#45

Open
deepfates wants to merge 3 commits intomainfrom
codex/replace-api-endpoint-for-completions
Open

Switch generation to RunPod completions endpoint and make model optional#45
deepfates wants to merge 3 commits intomainfrom
codex/replace-api-endpoint-for-completions

Conversation

@deepfates
Copy link
Copy Markdown
Owner

Motivation

  • Use the provided RunPod completions endpoint without requiring a provider-specific model string.
  • Remove OpenRouter-specific header/credential assumptions for the new completions path.
  • Allow generation requests to omit model and still produce output by falling back to a configured model.

Description

  • Updated the OpenAI-compatible client to point at https://xob3rm6bnyl1j1-8000.proxy.runpod.net/v1 and to use config.completionsApiKey instead of the previous OpenRouter key and headers (server/apis/openaiClient.ts).
  • Replaced the required OpenRouter config flow with a new LOOMPAD_COMPLETIONS_API_KEY backed completionsApiKey field in server/config.ts (defaulted to a safe string for non-production use).
  • Made model optional in GenerateRequestBody and changed validation so model is only validated when present (server/apis/validators.ts).
  • Updated generateText to resolve a model config from the provided model or fall back to the first configured model and stopped sending model in the upstream /completions request payload (server/apis/generation.ts).
  • Aligned the judge code to read the renamed completionsApiKey config field (server/apis/judge.ts).
  • Added and adjusted tests to cover the model-optional behavior in server/__tests__/validators.test.ts.

Testing

  • Ran bun test server/__tests__/validators.test.ts and all validator tests passed.
  • Ran the full test suite via bun test and all tests passed (no failures).

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1649640c8e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread server/apis/generation.ts
Comment on lines 61 to +62
if (!modelConfig) {
return res.status(400).json({ error: "Invalid model specified" });
return res.status(500).json({ error: "No models configured" });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Return client error for unknown model IDs

validateGenerateRequestBody only checks that model is a non-empty string, so a request like { model: "does-not-exist" } reaches generateText; with the new fallback logic, selectedModelId is set to that invalid string and getModel returns undefined, which now returns HTTP 500 ("No models configured") instead of a 4xx invalid-model error. This turns a user input mistake into a server error and can trigger misleading alerts/retries for bad client requests.

Useful? React with 👍 / 👎.

Comment thread server/config.ts
Comment on lines +29 to +30
const completionsApiKey =
process.env.LOOMPAD_COMPLETIONS_API_KEY?.trim() || "not-required";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Fail fast when completions key is missing

validateConfig now always supplies a placeholder ("not-required") when LOOMPAD_COMPLETIONS_API_KEY is unset, but /api/judge still calls OpenRouter (judge.ts) with apiKey: config.completionsApiKey; in production this allows boot to succeed and then makes judge requests fail at runtime with auth errors. The previous behavior guarded against this by requiring a real key outside development.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant