First call through the gateway
This guide covers the development gateway. Use the development gateway base URL and your Inferock key for requests.
Before you begin
Complete account and provider-key setup. The selected provider needs a configured key, and the request needs a valid Inferock key.
| Replacement | Value to supply |
|---|---|
GATEWAY_BASE_URL | Open Settings → Inferock keys and select Copy beside Gateway base URL. If that row is missing, follow Support and contact. |
INFEROCK_KEY | The Inferock key issued after activation. |
REQUEST_ID | A unique identifier you choose for this request and later match in Calls. |
| Model | The model used in this request example. |
1. Prepare the request
This example selects the provider explicitly in the request header. Use the Inferock key in the Bearer header. The gateway also accepts that key in x-inferock-api-key or x-api-key.
GET /v1/models lists only the models Inferock serves for your account, including the managed model for Inferock Serve. For Inferock Watch, which uses your own provider keys, an empty list is expected; use your provider's model ID in requests.
For POST /v1/chat/completions, an explicit x-governance-provider header takes precedence over the model name. Without that header, claude-* selects Anthropic and gemini-* selects Gemini. OpenAI model families such as gpt-*, chatgpt-*, o1 and o3-* select OpenAI. OpenAI fine-tuned IDs beginning with ft:gpt- or ft:o1 through ft:o9 also select OpenAI, including ft:gpt-4o-mini-2024-07-18:org::abc.
An unknown model ID that the gateway cannot resolve to a provider returns HTTP 400. Send x-governance-provider with the intended provider, such as x-governance-provider: openai for your OpenAI model. For example, a headerless request with model: "unknown-model" returns:
{"error":"Cannot resolve provider from model; supply x-governance-provider explicitly"}
Set the gateway base URL and your Inferock key, then choose a request ID:
export GATEWAY_BASE_URL='paste-the-gateway-base-url-shown-at-activation' # Under First proxied call, shown with your Inferock key.
export INFEROCK_KEY='your-issued-key'
export REQUEST_ID='your-unique-request-id'
The example requests the Chat Completions route and supplies a model and a short synthetic message:
curl "${GATEWAY_BASE_URL}/v1/chat/completions" \
-H "Authorization: Bearer ${INFEROCK_KEY}" \
-H 'Content-Type: application/json' \
-H 'x-governance-provider: openai' \
-H "x-request-id: ${REQUEST_ID}" \
-d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Reply only OK."}]}'
Python SDK
As an alternative to curl, install the OpenAI Python SDK with pip install openai, then send the same request:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["INFEROCK_KEY"],
base_url=f"{os.environ['GATEWAY_BASE_URL']}/v1",
default_headers={
"x-governance-provider": "openai",
"x-request-id": os.environ["REQUEST_ID"],
},
max_retries=0,
)
completion = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Reply only OK."}],
)
print(completion.choices[0].message.content)
Node.js SDK
As an alternative to curl, install the OpenAI JavaScript SDK with npm install openai, save the example as an .mjs file, then send the same request:
import OpenAI from "openai";
for (const name of ["GATEWAY_BASE_URL", "INFEROCK_KEY", "REQUEST_ID"]) {
if (!process.env[name]) {
throw new Error(`Set ${name} before running this example.`);
}
}
const client = new OpenAI({
apiKey: process.env.INFEROCK_KEY,
baseURL: `${process.env.GATEWAY_BASE_URL}/v1`,
defaultHeaders: {
"x-governance-provider": "openai",
"x-request-id": process.env.REQUEST_ID,
},
maxRetries: 0,
});
const completion = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "Reply only OK." }],
});
console.log(completion.choices[0].message.content);
Do not substitute the dashboard URL for the gateway base URL.
Gateway request
Successful provider response
2. Read the response
For the OpenAI examples in this guide, the gateway preserves the upstream HTTP status and provider response content for successful non-streaming and streaming calls. It does not replace the result with an Inferock-specific measurement envelope.
3. Find the measured call
After an actual provider result, the gateway emits a measurement event. Open Calls and match the value you set in REQUEST_ID. Open the call details to confirm the same request ID.
When a request fails
| Response | Meaning | What to check |
|---|---|---|
401 — Missing Inferock API key | The request has no Inferock key. | Supply the issued Inferock key in an accepted header. |
401 — Invalid Inferock API key | The supplied Inferock key is invalid. | Check that the header contains the Inferock key issued for the account. |
400 — Cannot resolve provider from model; supply x-governance-provider explicitly | The model ID does not identify a recognized provider family. | Send x-governance-provider with the intended provider, for example openai. |
404 — provider_key_not_configured | The selected provider has no configured account key. The error object carries this code and the message No provider key configured for tenant and provider. | Connect that provider's key in account setup. |
500 | The authentication service is unavailable. | Retry once. If it repeats, stop retrying and follow Support and contact. Do not replace a valid key. |
502 | The provider-key service is unavailable. | Retry once. If it repeats, stop retrying and follow Support and contact. Do not reconnect the provider key. |
413 or 429 | A payload, rate, quota or spend limit rejected the request. | Follow Limits. |
402 — insufficient_balance | Review your prepaid balance and recovery options. | Limits |
If you still need help, email support@inferock.ai; we respond within one business day.
Other request routes
The proxy also exposes native POST /v1/responses and POST /v1/messages. This guide covers the Chat Completions example; it is not the complete ingress reference.
