Free forever upstream lanes · OpenAI-compatible API
One API for text, vision, files, code, and deep thinking.
AI Route is the working gateway in this project. It uses only the two supplied Space-Z API origins, keeps their details server-side, and automatically continues through the other lane when one is busy or rate-limited.
Quickstart
Use the project origin plus /api/v1 as your OpenAI-compatible base URL. The gateway accepts the same chat-completions shape used by OpenAI SDKs and forwards the request to one of the two configured free-forever lanes.
model field reports the model that actually served the request.cURL
BASE_URL="https://your-gateway-origin/api/v1"
curl -N "$BASE_URL/chat/completions" \
-H "Content-Type: application/json" \
-d '{
"model": "auto",
"stream": true,
"messages": [{"role": "user", "content": "Explain TCP in one paragraph."}]
}'JavaScript with the OpenAI SDK
import OpenAI from "openai";
const ai = new OpenAI({
baseURL: "https://your-gateway-origin/api/v1",
apiKey: process.env.GATEWAY_API_KEY || "unused",
});
const answer = await ai.chat.completions.create({
model: "auto",
messages: [{ role: "user", content: "Write a haiku about APIs." }],
});
console.log(answer.choices[0].message.content);Capabilities
The gateway is intentionally a thin compatibility layer: it does not replace or invent an AI backend. It keeps the two supplied upstream APIs as the only providers and preserves their supported request fields and response formats.
JSON requests and responses work with SDKs, curl, fetch, and existing application code.
Set stream:true to receive standard chat.completion.chunk events and [DONE].
Set deep_think:true, or use the documented thinking alias, and the upstream returns reasoning when supported.
Send image URLs, data URLs, files, PDFs, or inline code through the upstream attachment formats.
Models and aliases
The live list below comes from GET /api/v1/models through this gateway. Model availability is controlled by the supplied upstreams, not by a separate provider account.
Recommended IDs
auto · automatic lane/model selection glm-4-plus · text and code glm-4.5v · image/file/video input deepseek-chat · compatibility alias if listed upstream gemini-2.5-pro · compatibility alias if accepted upstreamFor Gemini or DeepSeek IDs, use them only as aliases accepted by the provided Space-Z service. They are not direct calls to Google or DeepSeek, and their actual served model is returned by the upstream response.
Images, files, and code
Attachments are forwarded as JSON. Use a public URL or a data: URL for images and documents. Code can be sent inline through the convenience attachments array. The upstream practical attachment limit is approximately 8 MB.
Image or PDF via content parts
const response = await fetch(BASE_URL + "/chat/completions", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
model: "glm-4.5v",
messages: [{
role: "user",
content: [
{ type: "text", text: "Describe this image and list visible objects." },
{ type: "image_url", image_url: { url: "data:image/png;base64,..." } },
{ type: "file_url", file_url: { url: "https://example.com/report.pdf" } }
]
}]
})
});
const json = await response.json();Inline code attachment
{
"model": "glm-4-plus",
"messages": [{"role":"user","content":"Review this function for bugs."}],
"attachments": [{
"type": "code",
"name": "example.py",
"mime": "text/x-python",
"content": "def add(a, b):\\n return a - b"
}]
}Browser file-to-data-URL helper
const fileToDataUrl = (file) => new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => resolve(reader.result);
reader.onerror = reject;
reader.readAsDataURL(file);
});
const dataUrl = await fileToDataUrl(fileInput.files[0]);
// Put dataUrl in image_url.url or attachments[].dataUrl.Deep Think
Enable the upstream reasoning mode for multi-step math, code review, planning, and difficult analysis. The final answer remains in the normal message content; supported upstreams may also return reasoning content.
curl "$BASE_URL/chat/completions" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-4-plus",
"deep_think": true,
"messages": [{"role":"user","content":"Solve this step by step: 37 × 41."}]
}'Supported aliases include thinking: { "type": "enabled" } and enable_thinking: true, depending on the upstream route.
Rotation and failover
Each request starts on a health-aware round-robin lane. A 429 or transient upstream failure is recorded, the lane is cooled down, and the request continues through the other configured lane. Retries honor Retry-After and use bounded exponential backoff with jitter.
Operational endpoints
/healthUnauthenticated readiness and local gateway health.
/status?probe=1Lane counters, cooldowns, recent failures, and active routing cursor, with live upstream health probes.
/api/v1/modelsLive model list returned by the configured upstream lanes.
API reference
Use either the /api/v1 prefix shown below or the shorter /v1 alias. CORS is enabled for browser clients. Set the optional server-side GATEWAY_API_KEY to require a bearer token or X-API-Key.
/api/v1/chat/completionsOpenAI-compatible chat request. Required: non-empty messages. Optional: model, stream, deep_think, thinking, attachments, temperature, top_p, max_tokens.
/api/v1/responsesResponses API surface when supported by the selected upstream.
/api/v1/healthGateway health payload; not a direct provider health response.
/api/v1/modelsOpenAI list-shaped model discovery through the gateway.
Try the API
This console calls the gateway in this project. It does not call Google, DeepSeek, or any other provider directly.