bởi Kai

Lightweight Express proxy for Anthropic Claude models with support for single-turn chat, multi-turn conversations, and server-sent event streaming. Exposes seven REST endpoints including model-specific routes for Sonnet 4.5/4.6 and Opus 4.5, plus flexible `/chat` and `/chat/multi` endpoints for dynamic model selection. Built in TypeScript with full test coverage (7/7 endpoints passing) and configurable via environment variables. Licensed under Tetrees License.
TetreesAI backend is a lightweight Express service that proxies requests to Anthropic Claude models. It provides a clean REST API for single-turn chat, multi-turn conversations, and server-sent event (SSE) streaming responses. Perfect for integrating Claude AI capabilities into your application without managing API keys directly on the client side.
claude-sonnet-4-5, claude-sonnet-4-6, and claude-opus-4-5/chat endpoint with optional model selection/chat/sonnet-45, /chat/sonnet-46, /chat/opus-45)/chat/multi endpoint accepts full message history in Anthropic MessageParam format/chat/stream delivers responses incrementally as text deltasmax_tokens parameter for response length management/models endpoint lists all available Claude models| Layer | Technology |
|---|---|
| Runtime | Node.js |
| Language | TypeScript |
| Web Framework | Express |
| AI Provider | Anthropic Claude (@anthropic-ai/sdk) |
| Streaming | Server-Sent Events (SSE) |
| Configuration | dotenv |
| Middleware | cors |
npm install
npm run build
npm start
Server listens on port 9034 by default.
npm run dev
Hot-reload enabled for instant feedback during development.
Create a .env file in the project root:
ANTHROPIC_API_KEY=sk-ant-api03-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
PORT=9034
| Variable | Required | Default | Description |
|---|---|---|---|
ANTHROPIC_API_KEY | Yes | — | Anthropic API key for Claude access |
PORT | No | 9034 | TCP port for Express server |
Base URL: http://localhost:9034
Returns list of available Claude models.
curl -s -X GET http://localhost:9034/models
Response:
{
"models": [
{"key": "SONNET_46", "id": "claude-sonnet-4-6"},
{"key": "SONNET_45", "id": "claude-sonnet-4-5"},
{"key": "OPUS_45", "id": "claude-opus-4-5"}
]
}
Single-turn chat with optional model selection (defaults to claude-sonnet-4-5).
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | User message |
model | string | No | Claude model ID |
system | string | No | System prompt |
max_tokens | number | No | Max response tokens |
curl -s -X POST http://localhost:9034/chat \
-H "Content-Type: application/json" \
-d '{"message": "What is the capital of France?", "model": "claude-sonnet-4-5", "max_tokens": 256}'
Response:
{
"model": "claude-sonnet-4-5",
"reply": "The capital of France is Paris.",
"usage": {"input_tokens": 20, "output_tokens": 9},
"stop_reason": "end_turn"
}
Single-turn chat fixed to claude-sonnet-4-5.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | User message |
system | string | No | System prompt |
max_tokens | number | No | Max response tokens |
curl -s -X POST http://localhost:9034/chat/sonnet-45 \
-H "Content-Type: application/json" \
-d '{"message": "Explain recursion in one sentence.", "max_tokens": 128}'
Single-turn chat fixed to claude-sonnet-4-6.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | User message |
system | string | No | System prompt |
max_tokens | number | No | Max response tokens |
curl -s -X POST http://localhost:9034/chat/sonnet-46 \
-H "Content-Type: application/json" \
-d '{"message": "What are the three laws of thermodynamics?", "max_tokens": 300}'
Single-turn chat fixed to claude-opus-4-5.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | User message |
system | string | No | System prompt |
max_tokens | number | No | Max response tokens |
curl -s -X POST http://localhost:9034/chat/opus-45 \
-H "Content-Type: application/json" \
-d '{"message": "Write a haiku about artificial intelligence.", "max_tokens": 100}'
Multi-turn conversation with full message history (defaults to claude-sonnet-4-5).
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
messages | MessageParam[] | Yes | Array of messages with role ("user" or "assistant") and content (string) |
model | string | No | Claude model ID |
system | string | No | System prompt |
max_tokens | number | No | Max response tokens |
curl -s -X POST http://localhost:9034/chat/multi \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"max_tokens": 512,
"messages": [
{"role": "user", "content": "My name is Alex."},
{"role": "assistant", "content": "Nice to meet you, Alex!"},
{"role": "user", "content": "What is my name?"}
]
}'
Response:
{
"model": "claude-sonnet-4-5",
"reply": "Your name is Alex!",
"usage": {"input_tokens": 52, "output_tokens": 7},
"stop_reason": "end_turn"
}
Single-turn chat with SSE streaming response (defaults to claude-sonnet-4-5). Text deltas are emitted incrementally.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | User message |
model | string | No | Claude model ID |
system | string | No | System prompt |
max_tokens | number | No | Max response tokens |
curl -s -X POST http://localhost:9034/chat/stream \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-d '{"message": "Count from one to five, one number per line.", "max_tokens": 64}'
Response (SSE Stream):
data: {"type":"content_block_delta","delta":{"type":"text_delta","text":"1"}}
data: {"type":"content_block_delta","delta":{"type":"text_delta","text":"\n2"}}
data: {"type":"content_block_delta","delta":{"type":"text_delta","text":"\n3"}}
data: {"type":"message_stop"}
All 7 endpoints have been tested and verified:
| Endpoint | Status |
|---|---|
| GET /models | ✅ PASS |
| POST /chat | ✅ PASS |
| POST /chat/sonnet-45 | ✅ PASS |
| POST /chat/sonnet-46 | ✅ PASS |
| POST /chat/opus-45 | ✅ PASS |
| POST /chat/multi | ✅ PASS |
| POST /chat/stream | ✅ PASS |
Tetrees License
Khởi chạy sandbox cách ly và chạy phía máy chủ — không cần cài đặt cục bộ.
Lần kiểm định sandbox đã hoàn tất và đường chạy được phát hiện đã đạt yêu cầu.
This Express backend / api completed archive review with strong static results. Structure, dependency manifests, documentation, functional source, and common risk patterns were checked by the Tetrees verification pipeline; runtime phases are stated separately.
Deterministic AVCP artifact review
Quy trình avcp-2026-08-04.1 · SHA-256 aa460f6d89b8849b…
This version-scoped review deterministically inspects the submitted archive for structure, dependencies, documentation, functional source, and common malicious or high-risk signals. Build and test phases are reported as passed only after an isolated sandbox audition. It is not a guarantee of perfect security.
Đã đánh giá 4 thg 8, 2026
Hướng dẫn cài đặt đầy đủ và prompt tích hợp sẽ mở khóa sau khi mua.
Đưa sản phẩm này thẳng vào AI IDE, trình tạo web hoặc cloud IDE của bạn.
Kết nối Tetrees với AI IDE tương thích để liệt kê sản phẩm bạn sở hữu và nhận ZIP đã xác minh mà không cấp quyền tải lên của người bán.
28 đánh giá
Genuinely impressed. Dropped "Anthropic AI API module plugin" straight into the workflow; the README covered every config I needed. Five stars, would recommend to my team.
Exactly what I needed. Handles the edge cases I usually have to patch myself, and even the tricky env setup was explained well. Docking half a star only because I wanted a couple more examples.
Great starting point. As someone who automates these all day, setup was a single command and it ran first try.
Genuinely impressed. Dropped this automation setup straight into the workflow; the README covered every config I needed.
This is a keeper. Dropped this automation setup straight into the workflow; even the tricky env setup was explained well. Would buy from this seller again.
Punches well above its price. Dropped this automation setup straight into the workflow; the walkthrough got me running in minutes. Already using it in production.
Shipped with this same week. As someone who automates these all day, the abstractions are sensible and easy to swap out. Docking half a star only because I wanted a couple more examples.
Great starting point. Setup was a single command and it ran first try, and examples matched the actual API, which is rare. Exactly as described.
Great starting point. Picked up this automation setup for a client workflow — Zero mystery dependencies, everything is documented. Will definitely check their other products.
Clean and well thought out. Used this automation setup to automate my workflow and it cut days off the build. Minor tweaks needed for my use case but nothing broke.
Sign in to join the discussion
Loading discussion…