Python · requests
Use Backfire from Python
Python makes outbound calls from scripts, notebooks, Celery workers and Lambdas. Routing them through the relay means one credential and one response shape everywhere, including in throwaway scripts.
Notes for this client
- requests, httpx or urllib — all fine, because the relay takes ordinary JSON.
- Set the key from the environment; do not commit it into notebooks.
- Pass a client timeout as well as timeout_ms, so a stalled relay never hangs your process.
- Parsed JSON upstream bodies arrive in envelope["body"]["json"].
Working example
python
import os, requests
res = requests.post(
"https://backfireapi.base44.app/functions/forward",
headers={
"Authorization": f"Bearer {os.environ['BACKFIRE_KEY']}",
"Content-Type": "application/json",
},
json={
"url": "https://api.github.com/zen",
"method": "GET",
"timeout_ms": 8000,
},
timeout=30,
)
envelope = res.json()
if not envelope["ok"]:
raise RuntimeError(envelope["error"]["code"])
print(envelope["upstream"]["status"])
print(envelope["meta"]["trips_charged"], "trip")Questions about this
Other languages
Try it with 5,000 free trips.
No card, no subscription, and the balance never expires.

