Request routing and redirects

How a request to the Consumption API gets to the supplier fulfilling your inference, and which clients need configuration to follow the routing redirect.

When you send a request to the Consumption API, we validate your balance and route the request to the supplier serving your purchased inference. The API responds with an HTTP 307 Temporary Redirect, and the Location header contains the supplier's endpoint URL.

Your HTTP client needs to follow the redirect and re-send the same HTTP method (POST), request body, and Authorization header to the redirect target. This is standard HTTP behavior defined in RFC 7231 Section 6.4.7arrow-up-right.

Most clients follow 307 by default

If you use any of these libraries, no configuration is needed. The redirect happens transparently:

  • Python requests

  • Python httpx (with default settings)

  • Node.js fetch

  • Node.js axios

  • Go net/http

  • OpenAI SDK (Python and Node)

  • Anthropic SDK (against the messages-beta host)

The 307 happens, the client follows it, the inference completes, and your code sees a normal 200 response with the model output. You don't see the redirect in application logs unless you specifically inspect HTTP traffic.

cURL needs -L

cURL doesn't follow redirects by default. Pass -L:

curl -L -X POST https://api.thegrid.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "Text-Prime", "messages": [{"role": "user", "content": "Hello"}]}'

Without -L, cURL returns the 307 response itself instead of following it through to the supplier. You see a 307 status, the Location header, an empty body, and your inference doesn't run.

Clients that need configuration

A few clients don't follow redirects by default, or have configurations that disable it:

  • httpx.Client(follow_redirects=False): explicitly disabled. Set follow_redirects=True or use the default.

  • urllib.request in Python: doesn't follow 307 for POST automatically. Use requests or httpx instead, or implement the follow manually.

  • Some hand-rolled HTTP clients in low-level languages.

  • Browser fetch with redirect: 'manual' or redirect: 'error'.

If your code receives a raw 307, the fix is on the client side: toggle redirect-following on.

Firewall and domain allowlisting

If your environment restricts outbound HTTP traffic (common for agent frameworks running in sandboxed environments and enterprise deployments behind a strict outbound allowlist), allowlist the redirect target domains in addition to api.thegrid.ai.

Currently, supplier inference is served from:

  • synapse.thegrid.ai

As more suppliers join, additional domains may appear here. This page maintains the current list, and we announce additions ahead of time. If your security review needs the canonical list, link to this page rather than hardcoding domains in policy.

307 is not an error

The 307 is our routing layer doing its job. We document it alongside error codes only because clients without redirect-following see it surface as a non-200 response. See Errors and rate limits for the full status code catalog.

Last updated

Was this helpful?