fix(vapi): read SAMBANOVA_API_KEY from the environment - #48
Open
AkhileshSamba wants to merge 1 commit into
Open
Conversation
`app.py` hardcoded `SambaNova(api_key="YOUR_SAMBANOVA_API_KEY")` and never read the environment, so the documented setup could not work. Following the SambaNova docs page for this integration verbatim produces: sambanova.AuthenticationError: Error code: 401 - Incorrect API key provided: YOUR_S*****_KEY The API echoes the placeholder back, confirming the exported SAMBANOVA_API_KEY was ignored. The README already advises "use environment variables for secrets" under Notes and Best Practices, but the code never did. Now reads SAMBANOVA_API_KEY and exits early with a message naming the problem, the fix, and where to get a key if it is unset. Verified both paths: - unset: exits with the guidance message, no traceback - set: the API echoes the exported key, not the placeholder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
vapi/app.py:15hardcodes the API key and never reads the environment:The SambaNova docs page for this integration tells readers to
export SAMBANOVA_API_KEY=..., so that export is a no-op and the documented flow cannot complete.Reproduction
Clean clone, following the documented steps verbatim:
Returns HTTP 500:
The API echoes the placeholder back, which confirms the exported variable is ignored. Because
app.run(debug=True), the reader gets a full Werkzeug traceback page rather than a clean error.The README already says "Use environment variables for secrets" under Notes and Best Practices. The code never did.
Fix
Read
SAMBANOVA_API_KEYfrom the environment, and exit early with a message naming the problem, the fix, and where to get a key if it is missing.Verified both paths:
SAMBANOVA_API_KEY is not set.plus the export command and the portal linkYOUR_S*****_KEYTested with a deliberately invalid key to confirm the value reaches the API: the error changed from
Incorrect API key provided: YOUR_S*****_KEYtoIncorrect API key provided: sk-ups*****7722, my exported value.Two other things I found but did not change here
Flagging rather than fixing, so this PR stays a one-file change. Happy to send either as a follow-up.
vapi/README.mdgives the wrong Vapi endpoint URL. It says to pastehttps://abcd-1234.ngrok-free.dev/chat/completionsinto Vapi's endpoint field. Vapi's own docs say to paste the bare ngrok URL, because Vapi treats it as the OpenAI base URL and appends/chat/completionsitself. Including the path yields/chat/completions/chat/completionsand a 404. The SambaNova docs page was corrected for this; the README was not.app.run(debug=True)combined with the documented ngrok tunnel is a real exposure. The 500 above returns source snippets, absolute filesystem paths, and a PIN-gatedEVALEXconsole to anyone holding the public URL. The docs page now carries a warning about this, but adebug=os.environ.get("FLASK_DEBUG") == "1"default would be safer for anyone who copies this into something longer-lived.🤖 Generated with Claude Code