Integrations›HTTP Proxy (Any)
HTTP Proxy Integration
The most universal way to integrate AgentSecrets into any codebase—regardless of language or framework—is by routing your standard API calls through the AgentSecrets local proxy.
The proxy runs locally on http://localhost:8765 and acts as a transport-layer injector.
Standard Request Format
To route a request through the proxy, you modify three parts of your standard HTTP call:
- Change the actual request URL to
http://localhost:8765/proxy. - Provide the destination URL in the
X-AS-Target-URLheader. - Provide the key reference in an injection header (e.g.,
X-AS-Inject-Bearer).
Client Code Examples
cURL
curl -X POST http://localhost:8765/proxy \ -H "X-AS-Target-URL: https://api.stripe.com/v1/charges" \ -H "X-AS-Inject-Bearer: STRIPE_KEY" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "amount=2000¤cy=usd"
Python (Requests)
import requests response = requests.post( "http://localhost:8765/proxy", headers={ "X-AS-Target-URL": "https://api.stripe.com/v1/charges", "X-AS-Inject-Bearer": "STRIPE_KEY", "Content-Type": "application/x-www-form-urlencoded" }, data={"amount": 2000, "currency": "usd"} ) print(response.json())
Node.js (Fetch)
const response = await fetch("http://localhost:8765/proxy", { method: "POST", headers: { "X-AS-Target-URL": "https://api.stripe.com/v1/charges", "X-AS-Inject-Bearer": "STRIPE_KEY", "Content-Type": "application/x-www-form-urlencoded" }, body: new URLSearchParams({ amount: 2000, currency: "usd" }) }); const data = await response.json();
Go (net/http)
package main import ( "net/http" "strings" ) func main() { body := strings.NewReader("amount=2000¤cy=usd") req, _ := http.NewRequest("POST", "http://localhost:8765/proxy", body) req.Header.Set("X-AS-Target-URL", "https://api.stripe.com/v1/charges") req.Header.Set("X-AS-Inject-Bearer", "STRIPE_KEY") req.Header.Set("Content-Type", "application/x-www-form-urlencoded") client := &http.Client{} resp, _ := client.Do(req) // Process response... }
Customizing Injection
AgentSecrets supports multiple injection methods depending on what the upstream API expects. See the Injection Styles Reference for details on:
X-AS-Inject-Header: <HeaderName> <KeyName>(Custom header injection)X-AS-Inject-Query: <ParamName> <KeyName>(URL query parameter injection)X-AS-Inject-Basic: <Username> <PasswordKey>(Basic authentication)
Was this helpful?
Thanks for your feedback!
Your feedback helps us improve the platform.