Proxy Gateway (Python, Go, n8n)
Language-Agnostic Observability
Overview
The AtlasBurn Proxy Gateway is a stateless edge service that sits transparently between your application and the upstream AI provider. You swap one base URL and add one header — every request is then captured by the Forensic Ledger, costed by the Cost Engine, and guarded by the Auto Kill Protocol, in any language or runtime.
Base URLs
| Provider | Replace | With |
|---|---|---|
| OpenAI | https://api.openai.com/v1 | https://proxy.atlasburn.com/openai/v1 |
| Anthropic | https://api.anthropic.com/v1 | https://proxy.atlasburn.com/anthropic/v1 |
| Google Gemini | https://generativelanguage.googleapis.com/v1beta | https://proxy.atlasburn.com/gemini/v1beta |
Python Integration
Use the official openai Python package and point it at the AtlasBurn Proxy. Pass your AtlasBurn API key via the AtlasBurn-API-Key header.
from openai import OpenAI
# Initialize the client pointing to AtlasBurn
client = OpenAI(
base_url="https://proxy.atlasburn.com/openai/v1",
api_key="sk-your-real-openai-key",
# Authenticate with AtlasBurn
default_headers={"AtlasBurn-API-Key": "abn_your_atlasburn_key"},
)
# Use the client normally!
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello world"}],
)n8n / HTTP Request (No-Code)
For tools like n8n, Make, or Zapier, configure your HTTP Request node like this:
- Set the URL to the AtlasBurn Proxy (e.g.
https://proxy.atlasburn.com/openai/v1/chat/completions). - Pass your normal Provider API Key in the
Authorizationheader (e.g.Bearer sk-...). - Add one custom header:
AtlasBurn-API-Key: abn_your_key.
POST https://proxy.atlasburn.com/openai/v1/chat/completions
Authorization: Bearer sk-your-real-openai-key
AtlasBurn-API-Key: abn_your_atlasburn_key
Content-Type: application/json
{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello from n8n"}]
}Go Example
A complete example that sends a real JSON body, supports streaming Server-Sent Events when stream: true, and otherwise parses the JSON response safely.
package main
import (
"bufio"
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"strings"
)
const (
proxyURL = "https://proxy.atlasburn.com/openai/v1/chat/completions"
openaiKey = "sk-your-real-openai-key"
atlasKey = "abn_your_atlasburn_key"
useStream = true
)
type ChatRequest struct {
Model string `json:"model"`
Messages []ChatMessage `json:"messages"`
Stream bool `json:"stream"`
}
type ChatMessage struct {
Role string `json:"role"`
Content string `json:"content"`
}
type ChatResponse struct {
Choices []struct {
Message ChatMessage `json:"message"`
} `json:"choices"`
}
func main() {
body, _ := json.Marshal(ChatRequest{
Model: "gpt-4o",
Messages: []ChatMessage{{Role: "user", Content: "Hello from Go"}},
Stream: useStream,
})
req, err := http.NewRequest("POST", proxyURL, bytes.NewBuffer(body))
if err != nil {
fmt.Fprintln(os.Stderr, "request build:", err)
return
}
req.Header.Set("Authorization", "Bearer "+openaiKey)
req.Header.Set("AtlasBurn-API-Key", atlasKey)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
fmt.Fprintln(os.Stderr, "request:", err)
return
}
defer resp.Body.Close()
if resp.StatusCode >= 400 {
msg, _ := io.ReadAll(resp.Body)
fmt.Fprintf(os.Stderr, "proxy error %d: %s\n", resp.StatusCode, msg)
return
}
// Streaming (SSE) path — provider responds with text/event-stream.
if strings.HasPrefix(resp.Header.Get("Content-Type"), "text/event-stream") {
scanner := bufio.NewScanner(resp.Body)
for scanner.Scan() {
line := scanner.Text()
if !strings.HasPrefix(line, "data: ") {
continue
}
payload := strings.TrimPrefix(line, "data: ")
if payload == "[DONE]" {
break
}
var chunk struct {
Choices []struct {
Delta struct {
Content string `json:"content"`
} `json:"delta"`
} `json:"choices"`
}
if err := json.Unmarshal([]byte(payload), &chunk); err != nil {
continue // skip malformed frame
}
if len(chunk.Choices) > 0 {
fmt.Print(chunk.Choices[0].Delta.Content)
}
}
fmt.Println()
return
}
// Non-streaming JSON path.
var parsed ChatResponse
if err := json.NewDecoder(resp.Body).Decode(&parsed); err != nil {
fmt.Fprintln(os.Stderr, "decode:", err)
return
}
if len(parsed.Choices) == 0 {
fmt.Println("(empty response)")
return
}
fmt.Println(parsed.Choices[0].Message.Content)
}Rust and LangChain (Python)
Both Rust HTTP clients and LangChain (Python) work the same way: point the provider endpoint at the AtlasBurn Proxy base URL and add the AtlasBurn-API-Keyheader. No SDK install, no monkey-patching.
Routing rules
- OpenAI / OpenAI-compatible:
https://proxy.atlasburn.com/openai/v1 - Anthropic:
https://proxy.atlasburn.com/anthropic/v1 - Google Gemini:
https://proxy.atlasburn.com/gemini/v1beta - Always send your real provider key in the provider's normal auth header (
Authorization: Bearer ...for OpenAI/Gemini,x-api-keyfor Anthropic). - Always add
AtlasBurn-API-Key: abn_...as an extra header.
Rust (reqwest)
use reqwest::Client;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let resp = client
.post("https://proxy.atlasburn.com/openai/v1/chat/completions")
.bearer_auth("sk-your-real-openai-key")
.header("AtlasBurn-API-Key", "abn_your_atlasburn_key")
.json(&json!({
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello from Rust"}]
}))
.send()
.await?
.json::<serde_json::Value>()
.await?;
println!("{}", resp["choices"][0]["message"]["content"]);
Ok(())
}LangChain (Python)
Pass base_url (and default_headers) when constructing the LLM. This works for ChatOpenAI, ChatAnthropic, and any OpenAI-compatible model.
from langchain_openai import ChatOpenAI
from langchain_anthropic import ChatAnthropic
# OpenAI via AtlasBurn Proxy
openai_llm = ChatOpenAI(
model="gpt-4o",
base_url="https://proxy.atlasburn.com/openai/v1",
api_key="sk-your-real-openai-key",
default_headers={"AtlasBurn-API-Key": "abn_your_atlasburn_key"},
)
# Anthropic via AtlasBurn Proxy
anthropic_llm = ChatAnthropic(
model="claude-3-5-sonnet-latest",
base_url="https://proxy.atlasburn.com/anthropic",
api_key="sk-ant-your-real-anthropic-key",
default_headers={"AtlasBurn-API-Key": "abn_your_atlasburn_key"},
)
print(openai_llm.invoke("Hello from LangChain").content)Security Guarantee
When to Use Proxy vs SDK
- Use the Proxy Gateway for Python, Go, Rust, Ruby, .NET, n8n, Make, Zapier, LangChain (Python), or any non-JS runtime.
- Use the JavaScript SDK for Node.js, Next.js, Vercel Edge, or browser apps where auto-detection of
globalThis.fetchis preferred.
Next Steps
- Proxy Gateway Troubleshooting — 401/403, unsupported endpoints, model routing
- Cost Engine — how spend is calculated
- Security — full security architecture
- Troubleshooting — common issues