Skip to content

programmerraja/LLMProxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LLMProxy

A simple proxy server for tracking LLM requests to see the raw requests and responses.

Usage

npm install
node main.js

Data Flow

Client
  │
  │  HTTP Request
  ▼
LLM Proxy (this server)
  │
  │  Forwarded Request
  ▼
Target LLM API (OpenAI / Anthropic / etc.)
  │
  │  HTTP Response
  ▼
LLM Proxy
  │
  ├── Saves request & response to logs/
  │
  └── Returns response to client

How to Use the Proxy

Basic Rule

Always include the target LLM base URL as a url query parameter

http://localhost:3000/<original-path>?url=<TARGET_LLM_BASE_URL>

Example: OpenAI Chat Completions

Original OpenAI Request

POST https://api.openai.com/v1/chat/completions

Via Proxy

POST http://localhost:3000/v1/chat/completions?url=https://api.openai.com

Example curl

curl http://localhost:3000/v1/chat/completions?url=https://api.openai.com \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4.1",
    "messages": [
      {"role": "user", "content": "Explain transformers"}
    ]
  }'

✔ The response is returned exactly as OpenAI sends it ✔ A full request/response log is saved to logs/


Example: Anthropic Messages API

POST http://localhost:3000/v1/messages?url=https://api.anthropic.com

All headers (API keys, version headers, etc.) are passed through unchanged.


Logging Format

Each log file contains:

{
  "timestamp": "2026-01-22T12:30:11.123Z",
  "request": {
    "method": "POST",
    "url": "https://api.openai.com/v1/chat/completions",
    "headers": { ... },
    "body": { ... }
  },
  "response": {
    "status": 200,
    "headers": { ... },
    "body": { ... }
  }
}

Request Body Handling

Content Type Stored As
application/json Parsed JSON
text/* UTF-8 string
Binary Base64 encoded

About

A simple proxy server for OpenAI and Gemini and all type of API call

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors