Adding Models
This section explains the steps to add OpenAI models and configure the required access controls.Navigate to OpenAI Models in AI Gateway

OpenAI Accounts page
Configure Account

Configure Account - enter name and API key
Select Models

Models Selection - pick models and test credentials
Set Access Control

Access Control - configure manager and user permissions
Inference
After adding the models, you can perform inference using an OpenAI-compatible API via the Playground or by integrating with your own application.
Code Snippet panel showing Base URL, Model ID, and API Key
Supported APIs
Once your OpenAI provider account is configured, the following API surfaces are available through the gateway. The table below summarizes each endpoint alongside platform feature support (tracing, cost tracking).- ✅ Supported by Provider and Truefoundry
- Supported by Provider, but not by Truefoundry
- Provider does not support this feature
Chat Completions
Chat Completions
Streaming
Streaming
stream=True to start streaming responses and iterate over delta chunks. You may defensively check that chunk.choices is non-empty and delta.content is not None as some provider chunks (role deltas, finish markers) have no content.Request parameters
Request parameters
temperature, max_tokens, top_p, frequency_penalty, presence_penalty, and stop fine-tune generation behaviour.temperature is not supported on o-series reasoning models.Function calling / tools
Function calling / tools
tool_calls back as a tool role message, then request the final response. Use tool_choice to force the model to call a specific tool when you need deterministic behaviour, and defensively unwrap tool_calls since the model may still return content instead of a tool call on some prompts.Vision (multimodal input)
Vision (multimodal input)
image_url content part. The URL can be a public HTTP URL or an inline data:image/...;base64,... URI.PDF document input
PDF document input
file content type with base64 encoding.Response format (structured outputs)
Response format (structured outputs)
response_format. Two modes:- JSON object —
{"type": "json_object"}— valid JSON, no schema. Include “respond in JSON” in the prompt. - JSON schema —
{"type": "json_schema", ...}— strict schema conformance. Set all properties inrequired.
Reasoning models (o-series)
Reasoning models (o-series)
response.usage. Some request parameters like temperature are not supported on these models.Prompt caching
Prompt caching
gpt-4o and newer models. Pass an optional prompt_cache_key parameter to improve cache hit rates when requests share common prefixes. Cached tokens appear in usage.prompt_tokens_details.cached_tokens.Embeddings
Embeddings
text-embedding-3-small, text-embedding-3-large, text-embedding-ada-002. See the OpenAI embeddings guide for dimension and pricing details.Responses API
Responses API
retrieve, delete, and multimodal inputs. Full docs: Responses API.Image Generation
Image Generation
client.images.generate. The response contains either b64_json or url depending on the model and request parameters — handle both. Full docs: Image Generation.gpt-image-1, dall-e-2, dall-e-3.Image Edit
Image Edit
client.images.edit. Same models as image generation, with size constraints: gpt-image-1 accepts PNG/WebP/JPG up to 50 MB and up to 16 input images, while dall-e-2 requires a single square PNG ≤ 4 MB. Full docs: Image Edit.Image Variation
Image Variation
create_variation (dall-e-2 only — deprecated)The original variation API accepted an image and returned creative variations. It required a square PNG ≤ 4 MB and only worked with dall-e-2.
Full docs: Image Variation.images.edit with variation prompt (gpt-image-1)The recommended replacement is to use images.edit with a variation-style prompt. This works with current models and produces similar results.Text-to-Speech
Text-to-Speech
with_streaming_response.create(...) to stream the response body directly to a file or an AsyncIterator. Full docs: Text-to-Speech.gpt-4o-mini-tts, tts-1, tts-1-hd. Supported voices include alloy, echo, fable, onyx, nova, shimmer. See the OpenAI TTS guide for the full list of voices and audio formats.Speech-to-Text
Speech-to-Text
client.audio.transcriptions.create. Full docs: Audio Transcription.whisper-1, gpt-4o-transcribe, gpt-4o-mini-transcribe.Audio Translation
Audio Translation
client.audio.translations.create. Same whisper-1 model as transcription; the response is always English. Full docs: Audio Translation.The example below generates a short French TTS sample inline and translates it back to English so the demo is self-contained — text ↔ translated text round-trip with no external audio file.Batch API
Batch API
Files API
Files API
Moderation
Moderation
client.moderations.create. Routes through the regular client (no x-tfy-provider-name header needed). Full docs: Moderation API.omni-moderation-latest (multi-modal — text + image, recommended) and text-moderation-latest (legacy, text-only).Fine-tuning
Fine-tuning
Realtime API
Realtime API
- The host is the bare gateway host — no
/api/llmsuffix. - The OpenAI provider-account name is encoded in the URL path, not in the model name. The model passed to
client.realtime.connect(model=...)is the bare upstream OpenAI name (e.g.gpt-4o-realtime-preview).
AsyncOpenAI from openai[realtime], which handles the WebSocket framing and event schema for you. Full docs: Realtime API.output_modalities: ["audio"], add an audio.input.turn_detection block, and stream PCM chunks through connection.input_audio_buffer.append. See the OpenAI realtime audio reference for a complete sounddevice-based example — it works against the gateway unchanged, just point websocket_base_url at wss://{host}/live/openai-main.Regional Endpoints
OpenAI offers data residency controls that let you configure the region where your data is stored and, in some regions, processed. When data residency is enabled on your OpenAI account, you must use a region-specific domain prefix for API requests instead of the defaultapi.openai.com.
When adding an OpenAI account in TrueFoundry AI Gateway, set the Base URL to the appropriate regional endpoint for your OpenAI project.

Enable Advanced Fields to Set Base URL