AiCredits
API Performance

How Singapore Hosting Improves Latency for Global AI API Access

Singapore's cables and peering cut round-trip time for APAC AI API calls. Measure TTFT yourself, reuse connections, and pick the right region for global apps.

Published 2026-10-22 Updated 2026-10-22 7 min

Singapore Is a Routing Decision, Not a Buzzword

If you call an LLM API from Jakarta, Bengaluru, Sydney or Seoul, a large share of the perceived slowness is often not the model — it is the round trip. Every request completes DNS, a TCP handshake and a TLS handshake before a single token is generated, and each of those costs one or more round trips to the API edge. Shorten the network path and you shorten all of them at once.

Singapore earns its role here for concrete reasons: it is one of Asia-Pacific's densest subsea-cable landing points, it hosts major cloud regions and a busy internet exchange, and it sits close to Southeast Asia, India, Australia and East Asia on the cable map. An API edge in Singapore terminates APAC connections with fewer hops and less jitter than an edge in Virginia or Frankfurt.

Be honest about the limits, though. Singapore is not magically faster for everyone. For a user base in Brazil, Portugal or the US Midwest, an endpoint in Frankfurt or Virginia will usually win on pure round-trip time. The useful question is not "which region is best" but "which region is best for the majority of my traffic, and what does the tail look like for everyone else?"

Distance is a design constraint, not a bug. You cannot remove it — but you can stop paying for it on every single request.

Latency in an LLM Call Is Three Separate Numbers

  • Handshake time — DNS, TCP and TLS. A fixed cost per new connection; connection reuse removes almost all of it.

  • Time to first token (TTFT) — queueing plus prompt prefill. Grows with prompt length and with how busy the serving fleet is.

  • Decode time — tokens per second multiplied by output length. This is where long answers actually get slow.

  • Tail latency — p95 and p99, not the average. Users remember the one slow request, not the median.

Optimising the wrong number wastes effort. A large cut in handshake time means nothing if your p95 is dominated by a 1,500-token output. Measure before you tune.

Measure It Yourself Before You Trust Any Claim

import socket
import ssl
import statistics
import time

from openai import OpenAI

API_KEY = 'YOUR_AICREDITS_KEY'
HOST = 'api.aicreditsapi.com'

client = OpenAI(api_key=API_KEY, base_url=f'https://{HOST}/v1')


def handshake_ms(rounds=5):
    dns, tcp, tls = [], [], []
    for _ in range(rounds):
        t0 = time.perf_counter()
        info = socket.getaddrinfo(HOST, 443, proto=socket.IPPROTO_TCP)[0]
        t1 = time.perf_counter()
        sock = socket.create_connection(info[4], timeout=10)
        t2 = time.perf_counter()
        secure = ssl.create_default_context().wrap_socket(sock, server_hostname=HOST)
        t3 = time.perf_counter()
        secure.close()
        dns.append((t1 - t0) * 1000)
        tcp.append((t2 - t1) * 1000)
        tls.append((t3 - t2) * 1000)
    for name, series in (('dns', dns), ('tcp', tcp), ('tls', tls)):
        print(f'{name}: median {statistics.median(series):.1f} ms')


def ttft_ms(rounds=5):
    first, total = [], []
    for _ in range(rounds):
        t0 = time.perf_counter()
        stream = client.chat.completions.create(
            model='deepseek-v4-flash',
            messages=[{'role': 'user', 'content': 'Reply with the single word: ok'}],
            max_tokens=8,
            temperature=0,
            stream=True,
        )
        t_first = None
        for chunk in stream:
            if chunk.choices and chunk.choices[0].delta.content and t_first is None:
                t_first = time.perf_counter()
        t_end = time.perf_counter()
        first.append(((t_first or t_end) - t0) * 1000)
        total.append((t_end - t0) * 1000)
    print(f'ttft: median {statistics.median(first):.0f} ms')
    print(f'total: median {statistics.median(total):.0f} ms')


handshake_ms()
ttft_ms()

Run this from the region where your backend lives, then from a machine near your users if you can. Compare the handshake numbers against TTFT: on a short prompt with a reused connection, TTFT should be the bulk of the wall time, and handshake should be noise. If handshake is not noise, that is your first fix.

The Cheapest Latency Win Is Connection Reuse

The OpenAI SDK wraps httpx, which keeps connections alive by default — but only if the client object stays alive too. Two patterns destroy that win: constructing a new OpenAI client inside the request handler, and running in serverless containers that start cold for every invocation. Both make you pay the full handshake on every call.

import asyncio
import time

from openai import AsyncOpenAI

client = AsyncOpenAI(
    api_key='YOUR_AICREDITS_KEY',
    base_url='https://api.aicreditsapi.com/v1',
    timeout=30.0,
    max_retries=2,
)


async def call(i: int) -> float:
    t0 = time.perf_counter()
    await client.chat.completions.create(
        model='deepseek-v4-flash',
        messages=[{'role': 'user', 'content': f'Answer with ok ({i})'}],
        max_tokens=8,
        temperature=0,
    )
    return (time.perf_counter() - t0) * 1000


async def main():
    await call(-1)  # warm the connection pool so the handshake is not measured
    latencies = sorted(await asyncio.gather(*(call(i) for i in range(20))))
    n = len(latencies)
    p95 = latencies[min(n - 1, int(n * 0.95))]
    print(f'p50={latencies[n // 2]:.0f} ms  p95={p95:.0f} ms')


asyncio.run(main())

Notice the warm-up call: without it, your first measurement absorbs the handshake and inflates the p50. Notice also the explicit timeout and retry budget. A stalled request is worse than a fast failure, because it holds a connection and the user's attention at the same time.

Matching Region to User Base

Where most of your users areWhat a Singapore edge gives youWatch out for
Southeast Asia, India, AustraliaShort cable paths, dense regional peering, low jitterVery little — this is the sweet spot
East Asia (Japan, Korea, nearby)Comparable round-trip time to a Tokyo edge, often better than EU or USCross-border routing varies by carrier; test both
US and CanadaWorkable, but a US edge usually wins on handshake and TTFTAdded distance — keep payloads small and connections warm
EuropeUsually behind Frankfurt or Amsterdam on pure round-trip timeFine for batch jobs, weaker for interactive chat

For interactive chat with a genuinely global audience, the honest answer is usually a regional edge plus a warm connection pool from each backend region. If you cannot do that, put the edge where your largest cohort lives and optimise the tail for everyone else — streaming, shorter outputs and connection reuse travel well.

A Practical Checklist

  • Stream responses. Total completion time barely changes; perceived time drops sharply because the user sees tokens instead of a spinner.

  • Use deepseek-v4-flash on latency-sensitive paths and reserve deepseek-v4-pro for tasks where quality matters more than speed.

  • Cap max_tokens. Decode time scales with output length, and most "slow API" complaints are really long answers.

  • Create the client once at module or app scope, never per request.

  • Track p50 and p95 separately, and optimise the p95 if you care about the user experience.

  • Set an explicit timeout and let the SDK's retries absorb transient failures instead of letting calls hang.

  • Keep prompt prefixes stable where possible — repeated prefixes hit the cache, which is cheaper and faster than reprocessing them.

Where AiCredits Fits

AiCredits serves its API from Singapore at the OpenAI-compatible base URL used above, so an APAC backend gets a short path with no code changes beyond the endpoint and key. Billing works with an international card or PayPal — no Chinese phone number or bank account needed — and current rates are listed at aicreditsapi.com/pricing. Both deepseek-v4-flash and deepseek-v4-pro are available; flash is the sensible default, pro is there when a task genuinely needs the stronger model.

If you are benchmarking code you also have to maintain, the linting tools on the same account are a reasonable first pass — per-request client construction and unbounded max_tokens are exactly the kind of thing a linter catches before it reaches production.

FAQ

Does Singapore hosting help if my users are in Europe or the US?

Usually not for pure round-trip time — a Frankfurt or Virginia edge will be closer. Singapore helps most when your backend or your user base is in APAC. If you serve both, keep a warm client near each cohort and accept that the distant one pays a small fixed penalty on handshake and TTFT.

Is streaming actually faster?

Total completion time is roughly unchanged. Streaming changes when the first token arrives, which is what users perceive as speed. On a long answer the perceived difference is large.

Why is my first request always slow?

You are paying DNS, TCP and TLS setup that later requests reuse. Make one warm-up call at startup and construct the SDK client once rather than inside the handler.

Do I need a Chinese phone number to use DeepSeek models?

Not through AiCredits. Sign-up and billing work with an international card or PayPal, no Chinese phone or bank account required.

Which model should I benchmark against?

deepseek-v4-flash for most latency work. Switch to deepseek-v4-pro only for workloads that need the stronger model, and re-measure — output length, not the model name, usually drives your tail.

Try Lint in 2 seconds

Wrote something? Paste it here for a free grammar check. No account needed.

More Tools →

Related Tools

💻Code Explainer

Was this article helpful?

| Share on X Reddit Copy link

服务器宕机了?别等用户告诉你

Wakeless 梦哨 帮你 30 秒监控网站 / API / SSL 证书,宕机秒级告警到邮箱、飞书、Slack。免费档 30 个监控,永久免费,无需信用卡。

免费开始监控 →
💬
反馈意见 / Feedback ×