Skip to navigation

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.

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

MethodPathNotes
POST/v1/chat/completionsSupports streaming.
POST/v1/responsesSupports streaming.
POST/v1/embeddings
GET/v1/models
POST/v1/audio/transcriptionsMultipart 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.

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

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.

Next steps