Guides

Connect your app to Vallkey without code changes

How auto-connect works in Node.js, Bun, Python, Ruby, Java and .NET, which host needs what, and the one setting that breaks builds.

Updated October 2026

Tested on real Vercel and Railway deployments, and with 165 official SDK calls in Docker, October 2026

Most apps call APIs through an SDK: OpenAI, Stripe, Twilio and so on. With Vallkey, the app holds a ghost key instead of the real key. Auto-connect, a small package that starts with your app, sends every request that carries a ghost key to Vallkey. Vallkey checks it against your rules, swaps in the real key and passes the answer back. Your code stays exactly as the SDK's docs show it.

How it works

  1. Your app starts, and auto-connect with it

    One setting, a start command or a single line turns it on, depending on where the app runs. Nothing else in your code changes.

  2. A request carries a ghost key

    Auto-connect sees the ghost key, in a header, the address or a form body, and sends the request to api.vallkey.com with the same path. Requests without a ghost key are not touched: your database, your own APIs and every other call go where they always went.

  3. Vallkey checks it and swaps in the real key

    Your rules decide: which endpoints, how much per day, from where. Allowed requests reach the provider with the real key, which never leaves Vallkey. Blocked ones get a clear error. Every answer comes back with an x-guard-request-id header.

What each host needs

Auto-connect is the same everywhere. What changes is how your host starts the app. Links open the step-by-step guide for that host and language.

LanguageVercelRailwayDocker or your own server
Node.jsNext.js: a small setup file. Functions: first linetestedIn the start scripttestedNODE_OPTIONS where the app runstested
BunFirst line of each functiontestedIn the start scriptBUN_OPTIONS where the app runstested
PythonVALLKEY_AUTO=1 in the variablestestedVALLKEY_AUTO=1 in the variablestestedVALLKEY_AUTO=1tested
RubyFirst line of each functiontestedIn the ProcfiletestedRUBYOPT where the app runstested
Java, Kotlin, ScalaNot availablerailpack.json or a DockerfiletestedJAVA_TOOL_OPTIONS and the agent filetested
.NETNot availablerailpack.json or a DockerfiletestedDOTNET_STARTUP_HOOKS and the auto-connect filetested
PHPNot availableA DockerfileThe extension, with PHP_INI_SCAN_DIRtested
Elixir, ErlangNot availableA DockerfileELIXIR_ERL_OPTIONS and the auto-connect filetested
Go, RustThe SDK's address settingThe SDK's address settingThe SDK's address setting

Tested means we ran it on a real deployment, or, for Docker, with each language's official SDKs in a container that could reach nothing but Vallkey. The rest follows the same rules but has not been run on that host yet.

The one setting that breaks builds

In Node.js, Bun, Ruby, Java and .NET, auto-connect is turned on by an environment variable: NODE_OPTIONS, BUN_OPTIONS, RUBYOPT, JAVA_TOOL_OPTIONS, DOTNET_STARTUP_HOOKS. Every process of that language reads it, including the ones that build your app.

Vercel, Railway, Render and Heroku use your variables while they build

That variable, set in their variables, reaches npm install, bundle install or the Java build before auto-connect is installed, and the build fails. We saw it on Vercel and Railway. Put it where only the running app reads it: the start command, a Procfile, the first line of a function, railpack.json, or the final stage of a Dockerfile, after your app is built.

SettingIn the host's variablesWhere it goes instead
VALLKEY_AUTO=1Safe (Python)Nowhere else needed
VALLKEY_ENVSafeNames the app, such as production
VALLKEY_DEBUG=1SafeLogs each request sent to Vallkey, never the key
NODE_OPTIONSBreaks the buildThe start script, or the first line of a function
RUBYOPTBreaks the buildThe Procfile, or the first line of a function
JAVA_TOOL_OPTIONSBreaks the buildrailpack.json, or the final stage of a Dockerfile
DOTNET_STARTUP_HOOKSNot where the file israilpack.json, or the final stage of a Dockerfile

What auto-connect covers

The HTTP clients auto-connect reaches in each language, and with them the SDKs built on them:

LanguageCovers
Node.js and Bunfetch, http and https: almost every JavaScript SDK
Pythonhttpx, requests, urllib3, boto3, aiohttp, urllib
RubyNet::HTTP, and Faraday, HTTParty and rest-client on top of it
Java, Kotlin, ScalaOkHttp, Apache HttpClient 4 and 5, the JDK HttpClient, HttpURLConnection
.NETHttpClient, on .NET 8 and later
PHPThe curl extension: Guzzle, Symfony HttpClient and the SDKs' own clients
Elixir, ErlangFinch (Req), hackney (HTTPoison), httpc (Tesla's default)

Set it up from your terminal

In your project folder, the CLI tells the language from your files and does or prints each step:

Terminal
npx vallkey@latest connect   # the best way to connect this project; changes nothingnpx vallkey@latest hook      # sets up auto-connect: start script, Procfile, Next.js setup file or downloadnpx vallkey@latest doctor    # checks this project is ready on this computer

It knows the hosts in this guide: in a Vercel project it shows the first-line setup, for a Node.js app with a start script it offers to change the script, and for Java and .NET it prints the Dockerfile lines and the railpack.json.

Check every deployment

A setup that works on your computer can still miss on a host. One real request from the deployed app settles it:

Terminal
npx vallkey verify KEY_ID --request-id REQUEST_ID               # REQUEST_ID: the x-guard-request-id of your app's answernpx vallkey verify KEY_ID --request-id REQUEST_ID --expect denied  # a request your rules block, on a test keynpx vallkey status                                               # every app each key is used from

Each deployment shows up by itself

Auto-connect tells Vallkey where it runs, so a key's Activity tab and vallkey status list each app, such as Vercel · Node.js 24.21 · production or Railway · Python 3.13 · production, with its requests today and anything wrong there.

When to change the address instead

Some code cannot use auto-connect. There, set the SDK's API address to Vallkey, one line, shown on each key's Connect tab:

  • Edge functions and Next.js Edge routes: auto-connect works on Node.js only.
  • Go and Rust: compiled apps cannot be changed once built.
  • .NET native AOT or trimmed builds, which cannot use auto-connect.
  • Web pages and mobile apps: use short-lived keys instead, made for code that runs on people's devices.

Step-by-step guides

  • Vercel: Next.js, Node.js and Bun functions, Python, Ruby
  • Railway: Node.js, Python, Ruby, Java and .NET, with and without Docker
  • Auto-connect in the docs: every setting, Docker lines for each language, and the CLI

Protect your app's keys without touching its code

Create a ghost key, turn on auto-connect, deploy. Your app never holds the real key again. Free plan, no card needed.