Skip to navigation

Authenticate and send a request

To send traffic through Fabric AI Gateway, you need two things: the base URL of a route and a gateway key from the route’s namespace. You send the gateway key in the fg-api-key request header. The gateway key authenticates you to the gateway. If your route uses JWT Auth instead, send the token that your identity provider issued in the Authorization header, as Bearer TOKEN. For details, see Authenticate requests with JWT Auth. You don’t send the provider’s API key, because the gateway adds it when it proxies the request. This topic shows you how to find the base URL and send a request to an OpenAI-compatible route and to an Anthropic route.

Prerequisites

Before you begin, make sure you have the following:

  • A gateway key from the namespace that holds the route. Ask your admin for one, or create one yourself in Credentials if your account allows it. For details, see Authenticate requests with Key Auth.
  • Postman or cURL, to send the request.

Treat gateway keys as secrets. Don’t share them in screenshots, recordings, or chat messages. If a key leaks, rotate it in Credentials, or ask your admin to rotate it.

Get the base URL

Each route has its own base URL. To copy it, in the console sidebar, select LLMs, select the Routes tab, find the route, and then select the Copy LLM base URL icon in its row. The copied URL doesn’t end in /v1. If the route’s only path is a wildcard, such as /openai/*, the copied URL keeps the trailing /*. Remove it before you append an endpoint. If you don’t have access to the console, ask your admin for the URL.

The route’s ⋯ menu also offers full URLs and ready-made cURL commands for its endpoints, such as Copy chat URL (POST) and Copy models cURL (GET).

The URL’s host is the data plane host for your organization. On a Postman-hosted data plane, the host is a subdomain of dp.fabricgateway.ai. Copy it from the console rather than typing it. If your organization runs its own data plane, the host is the one your admin set for it.

If your organization runs its own data plane, check that an admin has set its URL in Admin > Data plane. Until then, the copied URL starts with Postman’s hosted gateway address, https://dp.fabricgateway.ai, not your data plane’s host.

Send a request to an OpenAI-compatible route

To send a chat completion request, append /v1/chat/completions to the base URL. To send a request, choose Postman or cURL.

  1. Create a request with the method POST. For the URL, paste the base URL that you copied, followed by /v1/chat/completions.

  2. In the Headers tab, add fg-api-key with your gateway key as the value.

  3. In the Body tab, select raw and JSON, and then enter the following body:

    {
    "model": "gpt-4o-mini",
    "messages": [
    { "role": "user", "content": "Hello from Fabric Gateway!" }
    ]
    }
  4. Select Send.

A successful request returns 200 OK with a standard OpenAI chat completion: the name of the model that answered and the assistant’s reply.

Send a request to an Anthropic route

An Anthropic route accepts the Anthropic Messages API. To send a request, choose Postman or cURL.

  1. Create a request with the method POST. For the URL, paste the base URL of your Anthropic route, followed by /v1/messages.

  2. In the Headers tab, add the following request headers:

    KeyValue
    fg-api-keyYour gateway key.
    anthropic-version2023-06-01
  3. In the Body tab, select raw and JSON, and then enter the following body:

    {
    "model": "claude-sonnet-4-5",
    "max_tokens": 256,
    "messages": [
    { "role": "user", "content": "Hello world!" }
    ]
    }
  4. Select Send.

A successful request returns 200 OK. The response body contains an assistant message in the content array, with the name of the model that answered and token counts in the usage object. Your request doesn’t include the provider’s API key, because the gateway adds it.

Understand how your key picks a namespace

Your gateway key, not the URL, decides which namespace serves your request. A key works only in the namespace that issued it. The gateway handles each request in this order:

  1. It reads the fg-api-key header. With no key, the request goes to the Default namespace. With a known key, it goes to that key’s namespace. With a key that the gateway doesn’t know, the request stops with 401.
  2. It looks for a matching route among that namespace’s routes only. If nothing matches, you get 404.

A namespace has no URL form on the data plane. A path such as /finance-agent-demo/... is just the path that an admin gave a route. Only the fg-api-key header picks the namespace, so a key sent in Authorization or x-api-key doesn’t, and the request goes to the Default namespace.

The following table shows what you get:

What you sendWhat happens
No key, to a route in the Default namespace that uses Key AuthThe route matches, and Key Auth refuses the missing key with 401. A Default route with no authentication plugin accepts the request.
No key, to a route in another namespaceThe request goes to Default, which has no route at that path, so you get 404.
A key from namespace A, to a route in namespace AThe route matches, and the request continues.
A key from namespace A, to a route in the Default namespaceThe request goes to namespace A, which has no route at that path, so you get 404.
A key from namespace A, to a route in namespace BThe same: 404.
A key the gateway doesn’t know401, before any route is matched.
Two different key values in the headers on the route’s Key Auth headers list401 with conflicting credentials.
A key, before the data plane has received its first configuration503 with service unavailable. Retry the request.
No key, before the data plane has received its first configuration404, because the data plane has no routes yet. Retry the request later.

One exception: an LLM route in the Default namespace that has a model router can also serve other namespaces. For details, see Serve every namespace from a Default route.

A URL that you open in a browser can’t send the fg-api-key header, so it always lands in the Default namespace. To test a route outside Default, use a copied cURL command or an HTTP client that sends the header.

If the request fails

If the request returns 401 Unauthorized, see Troubleshoot authentication errors.

Next steps