Skip to main content
configure() is the only function you need for HTTP API keys. It returns a config object ready to spread into any provider SDK constructor. The key is never in your process — in development, it stays in the local proxy; in production, it is injected by the Elding cloud proxy server-side.
The same line works in development and in production. No if (process.env.NODE_ENV). No change between environments.

How it works

configure() returns { apiKey, baseURL, defaultHeaders }. What those fields contain depends on the environment.

Development

Requires elding proxy running. apiKey is a placeholder ({{OPENAI_API_KEY}}). Requests go through the local proxy at 127.0.0.1, which injects the real key. The key never touches your process.

Production

Requires ELDING_REFRESH_TOKEN and ELDING_SET_ID. apiKey is a deploy token. Requests go through elding.app/api/proxy, which injects the real key server-side. The key never touches your process.

Fallback

No proxy active, no deploy token. The SDK fetches the raw key from the vault and returns it as apiKey. The key enters memory. Not recommended for production.
In both the development and production modes, the API key is injected at the proxy level — your application code, your logs, and your AI agent never see it.

Parameters


Return value

configure() always returns Promise<{ apiKey, baseURL, defaultHeaders }>. Spread directly into the provider constructor — it picks up exactly what it needs.

Provider examples

OpenAI

Anthropic

Mistral / Together AI / any OpenAI-compatible API

Custom fetch

Destructure the result and pass all three fields:
Always spread defaultHeaders before your own headers. They carry the proxy routing tokens — without them, the request won’t reach the right provider in development.

Production setup

Add two environment variables to your deployment platform (Vercel, Railway, Fly.io, etc.):
No code change required. configure() reads these automatically.
The deploy token is scoped to a single set and locked to the provider host. If it leaks, an attacker can only call that one API endpoint — they never see the actual key. You can revoke it instantly from the dashboard.

Security model

configure() is the only function you need. The key is never a string in your code.