Skip to main content

AI Gateway

The AI Gateway provides a unified, vendor-agnostic API for accessing AI models across 12 providers. With 302 certified models (as of February 2026), you can access chat completions, multimodal (vision), embeddings, text-to-speech, speech-to-text, image generation, video generation, and music generation through a single consistent interface.

Key Features

  • Unified API: Single interface for all providers (OpenAI, Anthropic, Google, Mistral, Cohere, Grok, DeepSeek, ElevenLabs, Stability AI, Black Forest Labs, Runway, Luma, plus custom/vLLM/Kubernetes for self-hosted)
  • SDK Compatible: Drop-in replacement for OpenAI SDK - requests via the /v1/ prefix automatically enable OpenAI compatibility mode (strips provider and provider_response fields from responses)
  • Multi-Modal Support: Text, vision (image input), audio (TTS/STT), video, and music generation. Vision Language Models (GPT-4o, GPT-5, Claude 3+, Gemini 2.0+, Pixtral, etc.) are classified as multimodal type with vision capability
  • Certified Models: Models are loaded from static JSON certification data on gateway startup
  • Guardrails: Input and output guardrails with content filtering, PII detection, and prompt injection protection (applied on completions endpoint)
  • Consistent Error Handling: Standardized error responses across all providers
  • Usage Tracking: Token counting, latency monitoring, and cost tracking
  • Organization Scoping: Multi-tenant isolation via X-Organization-ID header on model management endpoints

Authentication

API requests require the X-User-Id header for user identification. Context headers (X-App-Id, X-Workflow-Id, or X-Workspace-Id) are required for TTS, STT, and generation endpoints but are optional for chat and completion endpoints (used for analytics tracking when provided).

Required Headers

HeaderRequiredDescription
X-User-IdYesAuthenticated user's ID
X-Organization-IDRecommendedOrganization ID for multi-tenant resource isolation (required for model CRUD and fine-tuning)
X-App-IdConditionalApp ID (required for TTS/STT/Generations, optional for chat/completions)
X-Workflow-IdConditionalWorkflow ID (alternative to X-App-Id)
X-Workspace-IdConditionalWorkspace ID (alternative to X-App-Id)
X-OpenAI-CompatOptionalSet to true for strict OpenAI SDK compatibility (removes provider and provider_response fields). Automatically enabled when using /v1/ prefix
Content-TypeYesapplication/json for most endpoints

Note: For TTS, STT, and generation endpoints, at least one of X-App-Id, X-Workflow-Id, or X-Workspace-Id must be provided. For chat/completions/embeddings, these headers are optional but recommended for analytics.

OpenAI Compatibility Mode

The gateway supports two path prefixes:

  • /v1/ - Automatically enables OpenAI SDK compatibility mode (removes provider and provider_response fields from responses)
  • /api/v1/ - Standard gateway format with full response data including provider metadata

You can also enable compatibility mode explicitly on /api/v1/ routes by setting the X-OpenAI-Compat: true header.

Example Request

curl -X POST https://ai-gateway.strongly.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-User-Id: your-user-id" \
-H "X-Organization-ID: your-org-id" \
-d '{
"model": "507f1f77bcf86cd799439011",
"messages": [{"role": "user", "content": "Hello!"}]
}'

The model field should contain the Strongly-generated model ID from your configured models.

Model ID Format

When calling the AI Gateway, you must use the Strongly-generated model ID - the unique identifier assigned when a model is added to your account. This is a MongoDB ObjectId (24-character hex string).

Why use Strongly IDs?

  • The same vendor model (e.g., GPT-4o) can be added multiple times with different API keys
  • Each instance has a unique Strongly ID for proper isolation and billing
  • Enables multi-tenancy where users manage their own model configurations

Getting Model IDs:

  • When you add a model via the platform, you receive its unique ID
  • Use the /v1/models endpoint to list available models and their IDs
  • Model IDs are returned in the _id field

Example model ID: 507f1f77bcf86cd799439011

Quick Start

Chat Completion

// modelId is the Strongly-generated ID from your configured models
const modelId = '507f1f77bcf86cd799439011';

const response = await fetch('https://ai-gateway.strongly.ai/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-User-Id': userId,
'X-App-Id': appId // optional for chat, used for analytics
},
body: JSON.stringify({
model: modelId,
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'What is the capital of France?' }
],
max_tokens: 1000,
temperature: 0.7
})
});

const data = await response.json();
console.log(data.choices[0].message.content);

Text-to-Speech

// ttsModelId is the Strongly-generated ID for your TTS model
const ttsModelId = '507f1f77bcf86cd799439012';

const response = await fetch('https://ai-gateway.strongly.ai/v1/audio/speech', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-User-Id': userId,
'X-App-Id': appId // required for TTS
},
body: JSON.stringify({
model: ttsModelId,
input: 'Hello, welcome to Strongly AI!',
voice: 'alloy',
response_format: 'mp3'
})
});

// Response is streaming audio
const audioBlob = await response.blob();

Image Generation

// imageModelId is the Strongly-generated ID for your image model
const imageModelId = '507f1f77bcf86cd799439013';

const response = await fetch('https://ai-gateway.strongly.ai/v1/generations/images', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-User-Id': userId,
'X-App-Id': appId // required for generations
},
body: JSON.stringify({
model: imageModelId,
prompt: 'A beautiful sunset over mountains',
size: '1024x1024',
quality: 'hd'
})
});

const data = await response.json();
console.log(data.data[0].url);

API Endpoints Overview

EndpointMethodDescription
/v1/modelsGETList all available models
/v1/models/{model_id}GETGet model details
/v1/modelsPOSTCreate a new model
/v1/models/{model_id}PUTUpdate a model
/v1/models/{model_id}DELETEDelete a model
/v1/models/providersGETList providers with capabilities
/v1/models/keysPOSTCreate an API key
/v1/models/keysGETList API keys
/v1/models/keys/{key_id}GETGet API key details
/v1/models/keys/{key_id}DELETEDelete an API key
/v1/models/keys/{key_id}/deactivatePOSTDeactivate an API key
/v1/chat/completionsPOSTChat completion
/v1/completionsPOSTText completion
/v1/embeddingsPOSTGenerate embeddings
/v1/audio/speechPOSTText-to-speech
/v1/audio/speech/voicesGETList available TTS voices
/v1/audio/speech/modelsGETList TTS models
/v1/audio/transcriptionsPOSTSpeech-to-text
/v1/audio/translationsPOSTAudio translation
/v1/audio/transcriptions/modelsGETList STT models
/v1/audio/transcriptions/languagesGETList supported STT languages
/v1/generationsPOSTUnified generation (image/video/music)
/v1/generationsGETList generation jobs
/v1/generations/imagesPOSTImage generation
/v1/generations/videosPOSTVideo generation
/v1/generations/musicPOSTMusic generation
/v1/generations/{job_id}GETGet generation job status
/v1/generations/{job_id}DELETECancel generation job
/v1/generations/modelsGETList generation models
/v1/generations/models/{model_id}/operations/{operation_id}GETGet provider operation status

See API Endpoints for complete documentation.

Supported Capabilities

CapabilityProviders
Multimodal (Vision)OpenAI (GPT-4o/4.1/5+, o1/o3/o4), Anthropic (Claude 3+), Google (Gemini 1.5+/2.0+/2.5), Mistral (Pixtral, Large, Medium, Small), Cohere (Aya Vision, Command-A Vision), Grok (Vision)
Chat/CompletionsOpenAI, Google, Mistral, Cohere, Grok, DeepSeek
EmbeddingsOpenAI, Google, Mistral, Cohere
Text-to-SpeechOpenAI, ElevenLabs, Google
Speech-to-TextOpenAI, Mistral
Image GenerationOpenAI, Google, Stability AI, Black Forest Labs, Grok
Video GenerationGoogle, Runway, Luma
Music GenerationElevenLabs
RerankingCohere

Error Handling

The gateway uses a standard error format. Errors are returned as:

{
"detail": "The model '507f1f77bcf86cd799439011' not found. Please ensure the model is configured in your account."
}

For custom error types (authentication, validation), the format includes structured fields:

{
"detail": {
"message": "X-User-Id header is required",
"error_code": "missing_user_id"
}
}

Common error codes:

  • missing_user_id - X-User-Id header not provided (HTTP 401)
  • model_not_found - Requested model doesn't exist or is inactive (HTTP 404)
  • validation_error - Invalid request parameters or missing context headers (HTTP 400)
  • rate_limit_exceeded - Too many requests (HTTP 429, includes Retry-After header)
  • provider_error - Upstream provider returned an error (HTTP 500/502)
  • Guardrail violations - Request blocked by input/output guardrails (HTTP 400)

Next Steps