Skip to content

Use CURSOR_API_KEY for LLM narrative env config#4

Merged
trenchsheikh merged 1 commit into
mainfrom
cursor/use-cursor-api-key-env-29b7
Apr 30, 2026
Merged

Use CURSOR_API_KEY for LLM narrative env config#4
trenchsheikh merged 1 commit into
mainfrom
cursor/use-cursor-api-key-env-29b7

Conversation

@trenchsheikh

Copy link
Copy Markdown
Owner

Summary

Rename the optional LLM-narrative env vars to use a Cursor-style naming, and make the upstream endpoint configurable so a Cursor API key (or any OpenAI-compatible provider key) can be used.

Env var changes

Before After
OPENAI_API_KEY CURSOR_API_KEY
OPENAI_MODEL CURSOR_MODEL
(new) CURSOR_API_BASE_URL (default https://api.openai.com/v1)

What changed

  • app/core/config.py: openai_api_key / openai_model settings replaced with cursor_api_key, cursor_model, plus a new cursor_api_base_url.
  • app/services/underwriting/llm.py: builds the chat-completions URL from cursor_api_base_url and authenticates with cursor_api_key. Behavior is unchanged when the key is unset (rule-based narrative is returned and the LLM never affects outcome / amount / APR).
  • .env.example and backend/.env.example: updated to the new variable names with explanatory comments.
  • README.md: feature blurb, underwriting section, and config table updated to reference CURSOR_API_KEY / CURSOR_API_BASE_URL / CURSOR_MODEL.

Testing

  • pytest -q — all 15 tests pass.
  • Smoke test against a local mock HTTP server confirms:
    • request goes to ${CURSOR_API_BASE_URL}/chat/completions
    • Authorization: Bearer ${CURSOR_API_KEY} is sent
    • model field uses CURSOR_MODEL
    • narrative is enriched with the assistant note on success

Notes

CURSOR_API_BASE_URL defaults to OpenAI's host so existing deployments continue to work after just renaming the env var. Point it at any other OpenAI-compatible chat-completions endpoint to use a different provider.

Slack Thread

Open in Web Open in Cursor 

Rename optional LLM env vars from OPENAI_* to CURSOR_*:

- OPENAI_API_KEY  -> CURSOR_API_KEY
- OPENAI_MODEL    -> CURSOR_MODEL
- (new)             CURSOR_API_BASE_URL (default https://api.openai.com/v1)

The LLM client still hits an OpenAI-compatible /chat/completions endpoint,
so a Cursor API key (or any OpenAI-compatible provider key) can be used by
pointing CURSOR_API_BASE_URL at the right host. Updated config, llm
service, .env.example files at repo root and backend/, and README.

Co-authored-by: Mr T <trenchsheikh@users.noreply.github.com>
@trenchsheikh trenchsheikh marked this pull request as ready for review April 30, 2026 18:37
@trenchsheikh trenchsheikh merged commit cff1c72 into main Apr 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants