> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.fabricgateway.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.fabricgateway.ai/_mcp/server.

# Connect OpenAI

> Target URL, credentials, supported endpoints, and model names for an OpenAI connection.

The OpenAI connection sends requests to the OpenAI API with your organization's OpenAI API key. Clients call the route with the OpenAI API format, and the gateway forwards each request to OpenAI unchanged, apart from the credentials. This topic lists what's specific to OpenAI. For the setup steps, see [Connect an LLM provider](/configure/connections/llm-providers).

## Target URL

Use `https://api.openai.com`. The gateway adds the endpoint path, such as `/v1/chat/completions`, to the target URL. If you enter `https://api.openai.com/v1`, the gateway doesn't repeat the `/v1`.

## Credentials

Enter an OpenAI API key when you set up credentials. The gateway sends it to OpenAI as `Authorization: Bearer <key>` and replaces any `Authorization` header that the client sent. Callers authenticate to the gateway with their gateway key in `fg-api-key`, and the gateway removes that header before it forwards the request.

Headers such as `OpenAI-Organization` and `OpenAI-Project` reach OpenAI unchanged.

## Supported endpoints

| Method | Path                       | Notes               |
| ------ | -------------------------- | ------------------- |
| `POST` | `/v1/chat/completions`     | Supports streaming. |
| `POST` | `/v1/responses`            | Supports streaming. |
| `POST` | `/v1/embeddings`           |                     |
| `GET`  | `/v1/models`               |                     |
| `POST` | `/v1/audio/transcriptions` | Multipart upload.   |
| `POST` | `/v1/audio/speech`         |                     |
| `POST` | `/v1/images/generations`   |                     |
| `POST` | `/v1/moderations`          |                     |

A request to a path that isn't on this list gets `404`. The gateway doesn't translate between API formats, so an Anthropic Messages request to an OpenAI route fails.

## Model names

The gateway sends the `model` field exactly as the client wrote it, for example `gpt-4o-mini`. If the connection restricts models, the name must match an entry on the list exactly. For details, see [Restrict model and tool access](/configure/access-and-limits/model-access).

For streamed chat completions, OpenAI reports token usage only when the request sets `"stream_options": {"include_usage": true}`. Without it, the gateway has no token counts for the request, so analytics and token limits don't count it.

## Example

```bash
curl "BASE_URL/v1/chat/completions" \
  -H "fg-api-key: GATEWAY_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{ "role": "user", "content": "Hello" }]
  }'
```

Replace `BASE_URL` with the route's base URL and `GATEWAY_KEY` with your gateway key. For how to find both, see [Authenticate and send a request](/use/authenticate).

## Next steps

* [Call a route with the OpenAI-compatible API](/use/llm/openai-compatible)
* [Fail over across providers](/configure/routing/failover)
* [Restrict model and tool access](/configure/access-and-limits/model-access)