bởi Kai

Express backend API for OpenAI chat completions with two configurable model slots (GPT-5.3 and GPT-5.4). Routes chat requests to gpt-4o or gpt-4o-mini with full parameter control (temperature, max_tokens, top_p, penalties). Includes health checks, model introspection endpoints, and structured error handling. Built in TypeScript with CORS support and environment-based configuration.
TetreesAI backend is a lightweight Express server that exposes OpenAI chat completions through two configurable model slots (GPT-5.3 and GPT-5.4). Built with TypeScript, it provides a clean REST API for chat interactions with optional sampling parameters, health checks, and model introspection.
gpt-4o, GPT-5.4 defaults to gpt-4o-mini)/api/health endpoint for service status and /api/models endpoint to inspect configured slots| Layer | Technology |
|---|---|
| Runtime | Node.js |
| Language | TypeScript |
| Framework | Express |
| AI Provider | OpenAI API (chat completions) |
| Environment | dotenv |
| CORS | cors middleware |
| Dev Tooling | ts-node / nodemon |
npm install
npm run build
npm start
The server listens on port 9035 by default.
npm run dev
Runs with hot-reload. The server restarts automatically on file changes.
| Variable | Required | Default | Description |
|---|---|---|---|
PORT | No | 9035 | HTTP server port |
OPENAI_API_KEY | Yes | — | OpenAI API key for chat completions |
GPT53_MODEL | No | gpt-4o | Model ID for GPT-5.3 slot |
GPT54_MODEL | No | gpt-4o-mini | Model ID for GPT-5.4 slot |
Create a .env file:
PORT=9035
OPENAI_API_KEY=sk-...
GPT53_MODEL=gpt-4o
GPT54_MODEL=gpt-4o-mini
All successful responses follow { "success": true, ... }. All errors follow { "success": false, "error": { "message": "...", "code": "..." } }.
Returns server status and UTC timestamp.
Response:
{
"status": "ok",
"timestamp": "2024-11-15T08:32:10.452Z"
}
Returns configured model slots with descriptions and endpoints.
Response:
{
"success": true,
"data": {
"models": [
{
"slot": "gpt53",
"model": "gpt-4o",
"description": "GPT-4o — high-capability model (slot 5.3)",
"endpoints": ["/api/chat/gpt53"]
},
{
"slot": "gpt54",
"model": "gpt-4o-mini",
"description": "GPT-4o — high-capability model (slot 5.4, gpt-4o)",
"endpoints": ["/api/chat/gpt54"]
}
]
}
}
Chat completion using GPT-5.3 slot (defaults to gpt-4o).
Request Body:
{
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Explain Tetris scoring." }
],
"temperature": 0.7,
"max_tokens": 256,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0
}
| Field | Type | Required | Description |
|---|---|---|---|
messages | array | Yes | Non-empty array of { role, content } objects. Role must be "system", "user", or "assistant" |
temperature | number | No | Sampling temperature (0–2) |
max_tokens | number | No | Maximum tokens to generate |
top_p | number | No | Nucleus sampling probability (0–1) |
frequency_penalty | number | No | Frequency penalty (-2 to 2) |
presence_penalty | number | No | Presence penalty (-2 to 2) |
Response:
{
"success": true,
"data": {
"id": "chatcmpl-abc123xyz",
"object": "chat.completion",
"created": 1731660730,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "In Tetris, players earn points by clearing horizontal lines..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 32,
"completion_tokens": 47,
"total_tokens": 79
}
}
}
Chat completion using GPT-5.4 slot (defaults to gpt-4o-mini). Optimised for fast, cost-efficient responses.
Request Body: Same structure as /api/chat/gpt53
Response: Same structure as /api/chat/gpt53
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 dbfc7e317b6d6365…
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.
25 đánh giá
Saved me a ton of time. Picked up "OpenAI(GPT) API caller Module Plugin" for a client subscription flow — TypeScript types are actually accurate, no fighting the compiler. Already using it in production.
Dropped it into my stack and it just worked. As someone who ships these all day, the code is readable and the structure makes sense.
Dropped it into my stack and it just worked. Used this SaaS starter to ship my subscription flow and it cut days off the build. Exactly as described.
This is a keeper. Dropped this SaaS starter straight into the subscription flow; examples matched the actual API, which is rare. Five stars, would recommend to my team.
Rock solid so far. Dropped this SaaS starter straight into the subscription flow; docs were clear enough that I never had to open an issue. Highly recommend.
Saved me a ton of time. Picked up "OpenAI(GPT) API caller Module Plugin" for a client subscription flow — No spaghetti — the folder layout is sane. No regrets.
Shipped with this same week. Used this SaaS starter to ship my subscription flow and it cut days off the build. Already using it in production.
This is a keeper. Used "OpenAI(GPT) API caller Module Plugin" to ship my subscription flow and it cut days off the build. Five stars, would recommend to my team.
Better than I expected. Picked up this SaaS starter for a client subscription flow — Zero mystery dependencies, everything is documented. Already using it in production.
Genuinely impressed. As someone who ships these all day, no spaghetti — the folder layout is sane. Would buy from this seller again.
Sign in to join the discussion
Loading discussion…