n4nAI

When to skip a gateway and call OpenAI directly

Head-to-head comparison of calling OpenAI directly versus using an LLM gateway, covering cost, latency, ergonomics, and when to skip middleware.

n4n Team4 min read909 words

Audio narration

Coming soon — every post will get a voice note here.

Most teams bolt an LLM gateway onto their stack by default, but that adds a network hop and a billing layer you might not need. The question of when to call OpenAI directly instead of routing through a proxy is fundamentally about control, failure modes, and whether you actually consume more than one model provider. If you only touch GPT-4o and have no plan to switch, the answer to when to call OpenAI directly is almost always “now.”

Capabilities

Calling OpenAI’s API gives you first-party access to the full feature set: fine-tuning jobs, the Assistants API, batch endpoints, and native embeddings. You get versioned beta endpoints the moment they ship. A gateway normalizes these behind an OpenAI-compatible surface, which means some bespoke endpoints get dropped or lag.

The flip side is multi-provider coverage. A gateway aggregates 240+ models behind one endpoint; OpenAI-only calls obviously don’t. For example, n4n.ai exposes a single OpenAI-compatible endpoint that addresses 240+ models and performs automatic fallback when a provider is rate-limited or degraded. That’s a capability you cannot replicate by pointing at api.openai.com.

If your system needs to route a prompt to Claude for long context and GPT-4o for code, a gateway earns its keep. If you don’t, you’re paying for abstraction you ignore.

Direct call:

from openai import OpenAI
client = OpenAI()
resp = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "ping"}]
)
print(resp.choices[0].message.content)

Same call via gateway (compatible):

from openai import OpenAI
client = OpenAI(base_url="https://api.n4n.ai/v1", api_key="<gw_key>")
resp = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "ping"}]
)

Price/cost model

OpenAI bills per token at published rates. No intermediary margin. You get a single invoice, granular usage dashboards, and committed-use discounts if you negotiate.

Gateways typically add a markup or charge a flat platform fee. Some, like n4n.ai, implement per-token usage metering so you can attribute cost across teams, but that metering is on top of the underlying provider cost. If you’re a startup watching burn, the markup can be the difference between profitability and not.

However, direct calls mean you manage your own rate limits and quota across providers if you later expand. Gateway billing consolidates that, but consolidation has a price.

Latency/throughput

Direct call path: your service → OpenAI edge. Typically 20–40 ms added network latency within same region, plus model inference time. No proxy parsing your JSON.

Gateway adds a middlebox: TLS termination, auth check, request transformation, and possibly model routing logic. Even a well-tuned gateway adds 10–30 ms. Under high throughput, connection pooling at the gateway can help if you’re coming from many ephemeral lambdas, but OpenAI’s own infrastructure already handles massive concurrency.

If you’re serving latency-sensitive chat with p99 targets under 300 ms, shaving the proxy is real. When to call OpenAI directly becomes clear when every millisecond counts and you have no multi-model requirement.

Ergonomics

OpenAI’s SDKs are best-in-class: typed clients for Python, TS, Go, Rust. Error messages map to HTTP semantics. You get streaming helpers, async support, and retries with backoff built in.

A gateway speaking the OpenAI protocol is a drop-in for the chat completions endpoint, but diverges on anything beyond. You lose strongly-typed access to provider-specific params unless the gateway forwards them. Honoring client routing directives and forwarding provider cache-control hints (something n4n.ai does) mitigates this, yet you still consult two sets of docs.

Example of cache hint passthrough via gateway:

{
  "model": "gpt-4o",
  "messages": [{"role": "user", "content": "repeat this: hello"}],
  "extra_headers": {"x-cache-control": "ttl=3600"}
}

Direct OpenAI supports similar headers natively but without cross-provider semantics.

Ecosystem

OpenAI’s ecosystem includes the Prompt Engineering guide, community forums, and third-party tools that assume direct API shapes. Many observability tools (LangSmith, Helicone) work by proxying OpenAI traffic; they also support gateways but with less depth.

Gateway ecosystem is about unification: one auth token, one base URL, centralized logging. If you’re building internal platform tooling for 50 engineers, that unification reduces onboarding. For a solo builder, it’s overhead.

Limits

Direct OpenAI limits: per-organization TPM/RPM tiers, regional availability, and no fallback if a model is temporarily unavailable. You implement your own retry/backoff; if OpenAI has an incident, you’re down.

from openai import OpenAI, RateLimitError
client = OpenAI()
try:
    resp = client.chat.completions.create(model="gpt-4o", messages=[{"role":"user","content":"hi"}])
except RateLimitError:
    # own backoff or failover logic
    raise

Gateway limits: you inherit the gateway’s uptime, its rate limits, and potential blind spots in error mapping. A gateway can mask provider errors as 502s, complicating debugging. Also, some gateways restrict which beta features pass through.

Comparison table

Dimension Call OpenAI directly Use a gateway (e.g., n4n.ai)
Capabilities Full first-party API, beta access Multi-model, fallback, unified routing
Price Provider rates only, no markup Provider cost + possible markup/metering
Latency Minimal hop, lowest p99 +10–30 ms proxy overhead
Ergonomics Official SDKs, native params OpenAI-compatible, some feature lag
Ecosystem Largest native tooling support Unified token/logging across models
Limits Hard per-org quotas, no failover Gateway dependency, error masking risk

Which to choose

Solo developer or single-model prototype: When to call OpenAI directly is now. You avoid extra billing, reduce latency, and use the best docs. There’s no second provider to justify the abstraction.

Production system with multi-model needs: If you route between OpenAI, Anthropic, and open-weight models for cost or quality, a gateway’s fallback and routing save you writing reconciliation code. The automatic fallback when a provider is degraded is the differentiator.

Latency-critical consumer app: Skip the gateway. Direct calls shave critical milliseconds and remove a failure point. When to call OpenAI directly is dictated by your p99 budget.

Enterprise with internal chargebacks: Gateway per-token metering simplifies cost allocation. But weigh the markup against building your own usage middleware.

Early-stage startup watching costs: Direct calls keep margin. Revisit when you need provider redundancy.

The decision isn’t ideological. When to call OpenAI directly is a function of whether the gateway’s cross-provider features offset its latency, cost, and complexity for your specific workload. If you never stray from one vendor, the proxy is pure tax.

Tagsopenaidirect-apillm-gateway

Written by

n4n Team

The team building n4n — a single OpenAI-compatible API in front of 240+ models, with automatic fallback, load balancing and pay-per-token metering.

More from n4n Team →

All n4n vs calling providers directly posts →