What is an integration?
Overview
Section titled “Overview”An integration is a protocol adapter that translates between DeepintShield’s unified API and provider-specific API formats. Each integration handles request transformation, response normalization, and error mapping between the external API contract and DeepintShield’s internal processing pipeline.
Integrations enable you to utilize DeepintShield’s features like governance, MCP tools, load balancing, semantic caching, multi-provider support, and more, all while preserving your existing SDK-based architecture. DeepintShield handles all the overhead of structure conversion, requiring only a single URL change to switch from direct provider APIs to DeepintShield’s gateway.
DeepintShield converts the request/response format of the provider API to the DeepintShield API format based on the integration used, so you don’t have to.
Quick Migration
Section titled “Quick Migration”Before (Direct Provider)
Section titled “Before (Direct Provider)”import openai
client = openai.OpenAI( api_key="your-openai-key")After (DeepintShield)
Section titled “After (DeepintShield)”import openai
client = openai.OpenAI( base_url="http://localhost:8080/openai", # Point to DeepintShield api_key="dummy-key" # Keys are handled in DeepintShield now)That’s it! Your application now benefits from DeepintShield’s features with no other changes.
Supported Integrations
Section titled “Supported Integrations”Provider-Prefixed Models
Section titled “Provider-Prefixed Models”Use multiple providers seamlessly by prefixing model names with the provider:
import openai
# Single client, multiple providersclient = openai.OpenAI( base_url="http://localhost:8080/openai", api_key="dummy" # API keys configured in DeepintShield)
# OpenAI modelsresponse1 = client.chat.completions.create( model="gpt-4o-mini", # (default OpenAI since it's OpenAI's SDK) messages=[{"role": "user", "content": "Hello!"}])import openai
# Anthropic models using OpenAI SDK formatresponse2 = client.chat.completions.create( model="anthropic/claude-3-sonnet-20240229", messages=[{"role": "user", "content": "Hello!"}])import openai
# Azure modelsresponse4 = client.chat.completions.create( model="azure/gpt-4o", messages=[{"role": "user", "content": "Hello!"}])import openai
# Google Vertex modelsresponse3 = client.chat.completions.create( model="vertex/gemini-pro", messages=[{"role": "user", "content": "Hello!"}])import openai
# Local Ollama modelsresponse5 = client.chat.completions.create( model="ollama/llama3.1:8b", messages=[{"role": "user", "content": "Hello!"}])Direct API Usage
Section titled “Direct API Usage”For custom HTTP clients or when you have existing provider-specific setup and want to use DeepintShield gateway without restructuring your codebase:
import requests
# Fully OpenAI compatible endpointresponse = requests.post( "http://localhost:8080/openai/v1/chat/completions", headers={ "Authorization": f"Bearer {openai_key}", "Content-Type": "application/json" }, json={ "model": "gpt-4o-mini", "messages": [{"role": "user", "content": "Hello!"}] })
# Fully Anthropic compatible endpointresponse = requests.post( "http://localhost:8080/anthropic/v1/messages", headers={ "Content-Type": "application/json", }, json={ "model": "claude-3-sonnet-20240229", "max_tokens": 1000, "messages": [{"role": "user", "content": "Hello!"}] })
# Fully Google GenAI compatible endpointresponse = requests.post( "http://localhost:8080/genai/v1beta/models/gemini-1.5-flash/generateContent", headers={ "Content-Type": "application/json", }, json={ "contents": [ {"parts": [{"text": "Hello!"}]} ], "generation_config": { "max_output_tokens": 1000, "temperature": 1 } })Listing Models
Section titled “Listing Models”All integrations support listing available models through their respective list models endpoints (e.g., /openai/v1/models, /anthropic/v1/models). By default, list models requests return models from all configured providers in DeepintShield.
Filtering by Provider
Section titled “Filtering by Provider”You can control which provider’s models to list using the x-bf-list-models-provider header:
import openai
client = openai.OpenAI( base_url="http://localhost:8080/openai", api_key="dummy-key")
# List models from all providers (default behavior)all_models = client.models.list()
# List models from a specific provider onlyopenai_models = client.models.list( extra_headers={ "x-bf-list-models-provider": "openai" })
anthropic_models = client.models.list( extra_headers={ "x-bf-list-models-provider": "anthropic" })import OpenAI from "openai";
const openai = new OpenAI({ baseURL: "http://localhost:8080/openai", apiKey: "dummy-key",});
// List models from all providers (default behavior)const allModels = await openai.models.list();
// List models from a specific provider onlyconst openaiModels = await openai.models.list({ headers: { "x-bf-list-models-provider": "openai", },});
const anthropicModels = await openai.models.list({ headers: { "x-bf-list-models-provider": "anthropic", },});# List models from all providers (default)curl http://localhost:8080/openai/v1/models
# List models from specific providercurl http://localhost:8080/openai/v1/models \ -H "x-bf-list-models-provider: openai"
# Explicitly request all providerscurl http://localhost:8080/openai/v1/models \ -H "x-bf-list-models-provider: all"Header Behavior
Section titled “Header Behavior”| Header Value | Behavior |
|---|---|
| Not set (default) | Lists models from all configured providers |
all | Lists models from all configured providers |
openai | Lists models from OpenAI provider only |
anthropic | Lists models from Anthropic provider only |
vertex | Lists models from Vertex AI provider only |
| Any valid provider | Lists models from that specific provider |
Response Fields
Section titled “Response Fields”When listing models from all providers, some provider-specific fields may be empty or contain default values if the information is not available from all providers. This is normal behavior as different providers expose different model metadata.
Migration Strategies
Section titled “Migration Strategies”Gradual Migration
Section titled “Gradual Migration”- Start with development - Test DeepintShield in dev environment
- Canary deployment - Route 5% of traffic through DeepintShield
- Feature-by-feature - Migrate specific endpoints gradually
- Full migration - Switch all traffic to DeepintShield
Blue-Green Migration
Section titled “Blue-Green Migration”import osimport random
# Route traffic based on feature flagdef get_base_url(provider: str) -> str: if os.getenv("USE_DEEPINTSHIELD", "false") == "true": return f"http://deepintshield:8080/{provider}" else: return f"https://api.{provider}.com"
# Gradual rolloutdef should_use_bifrost() -> bool: rollout_percentage = int(os.getenv("DEEPINTSHIELD_ROLLOUT", "0")) return random.randint(1, 100) <= rollout_percentageFeature Flag Integration
Section titled “Feature Flag Integration”# Using feature flags for safe migrationimport openaifrom feature_flags import get_flag
def create_client(): if get_flag("use_bifrost_openai"): base_url = "http://deepintshield:8080/openai" else: base_url = "https://api.openai.com"
return openai.OpenAI( base_url=base_url, api_key=os.getenv("OPENAI_API_KEY") )Next Steps
Section titled “Next Steps”- HTTP Transport Overview - Main HTTP transport guide
- Endpoints - Complete API reference
- Configuration - Provider setup and config