Documentation
Aperture proxies AI API calls through Singapore for lower latency in Asia-Pacific. It's OpenAI-compatible — just change your base_url.
Quick Start
Replace your provider's base URL with your Aperture endpoint. Everything else stays the same.
Step 1 — Get your API key
Create a free account to receive your sg-... key instantly.
client = OpenAI(
api_key="sg-xxxxxxxxxxxxxxxxxxxx",
base_url="https://aperture-ai.run/proxy/openai/v1"
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
const client = new OpenAI({
apiKey: 'sg-xxxxxxxxxxxxxxxxxxxx',
baseURL: 'https://aperture-ai.run/proxy/openai/v1',
});
const response = await client.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(response.choices[0].message.content);
-H "Content-Type: application/json" \
-H "Authorization: Bearer sg-xxxxxxxxxxxxxxxxxxxx" \
-d '{"model":"gpt-4o","messages":[{"role":"user","content":"Hello!"}]}'
Authentication
Pass your Aperture API key as a Bearer token in the Authorization header. Your upstream provider keys are stored securely on our server — never exposed to clients.
If VALID_API_KEYS is empty in the server's .env, authentication is disabled (development mode). Always set API keys in production.
Providers
Aperture currently supports three AI providers. Use the path prefix to route to the correct upstream.
https://aperture-ai.run/proxy/{provider}/v1/...
GET /health
Public health check endpoint. No authentication required. Used by load balancers and uptime monitors.
curl https://aperture-ai.run/health
# Response 200
{
"status": "ok",
"region": "Singapore",
"ts": 1748956800000
}
GET /targets
List all active proxy providers. No authentication required.
{
"targets": ["openai", "anthropic", "aliyun"]
}
GET /api/stats
Returns live usage statistics. Used by the dashboard. Requires authentication if keys are configured.
{
"totalRequests": 42891,
"cacheHitRate": "68.3%",
"cachedKeys": 1204,
"redisConnected": true,
"uptime": "3d 14h 22m",
"targets": ["openai", "anthropic", "aliyun"],
"cacheTTL": 300,
"rateLimitMax": 100,
"rateLimitWindow": 60000
}
* /proxy/:target/*
Forward any request to the configured upstream. Supports all HTTP methods: GET, POST, PUT, DELETE, PATCH.
Response headers include:
X-Cache: MISS # fetched from upstream
Response Caching
GET requests are automatically cached in Redis using a hash of the request path + query. When the same request is made again within the TTL window, the cached response is returned instantly — no upstream API call, no cost.
CACHE_TTL=300 # seconds. Set 0 to disable caching.
Cache TTL by plan:
Rate Limiting
Distributed rate limiting is handled via Redis using a sliding window. When the limit is exceeded, the server responds with 429 Too Many Requests and a Retry-After header.
RATE_LIMIT_WINDOW_MS=60000 # 1-minute window
RATE_LIMIT_MAX=100 # max requests per window
Rate limits by plan:
Streaming
Streaming responses (Server-Sent Events) are fully supported. Set stream: true in your request body — Aperture forwards the stream transparently. Streamed responses are not cached.
model="gpt-4o",
messages=[{"role": "user", "content": "Tell me a story"}],
stream=True # streaming — works as-is
)
for chunk in response:
print(chunk.choices[0].delta.content, end="")
Python examples
Using Anthropic via Aperture:
client = anthropic.Anthropic(
api_key="sg-xxxxxxxxxxxxxxxxxxxx",
base_url="https://aperture-ai.run/proxy/anthropic"
)
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello, Claude!"}]
)
Node.js examples
Using Alibaba DashScope via the OpenAI-compatible endpoint:
const client = new OpenAI({
apiKey: 'sg-xxxxxxxxxxxxxxxxxxxx',
baseURL: 'https://aperture-ai.run/proxy/aliyun/v1',
});
const res = await client.chat.completions.create({
model: 'qwen-max',
messages: [{ role: 'user', content: '你好!' }],
});
cURL examples
Check your API key and provider status:
curl https://aperture-ai.run/health
# List providers
curl https://aperture-ai.run/targets
# Call GPT-4o
curl https://aperture-ai.run/proxy/openai/v1/chat/completions \
-H "Authorization: Bearer sg-xxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o","messages":[{"role":"user","content":"Hi!"}]}'
Questions? Email [email protected] · View pricing →