Skip to content

Overview

DeepintShield is Google GenAI API-compatible: point your existing Google GenAI SDK at the DeepintShield endpoint and your requests, responses, and errors work unchanged.

You keep your Google GenAI SDK-based architecture while gaining DeepintShield features like governance, load balancing, semantic caching, and multi-provider support.

Endpoint: /genai


Install with the GenAI extra:

Terminal window
pip install "deepintshield[genai]"
from deepintshield import DeepintShield
shield = DeepintShield(virtual_key="sk-bf-your-virtual-key")
client = shield.genai() # pre-wired google.genai.Client
response = client.models.generate_content(
model="gemini-2.5-flash",
contents="Hello!",
)
print(response.text)

Use multiple providers through the same GenAI SDK format by prefixing model names with the provider:

from google import genai
from google.genai.types import HttpOptions
client = genai.Client(
api_key="sk-bf-your-virtual-key",
http_options=HttpOptions(
base_url="https://app.deepintshield.com/genai",
headers={"x-bf-vk": "sk-bf-your-virtual-key"},
),
)
# Google Vertex models (default)
vertex_response = client.models.generate_content(
model="gemini-2.5-flash",
contents="Hello from Gemini!"
)
# OpenAI models via GenAI SDK format
openai_response = client.models.generate_content(
model="openai/gpt-4o-mini",
contents="Hello from OpenAI!"
)
# Anthropic models via GenAI SDK format
anthropic_response = client.models.generate_content(
model="anthropic/claude-3-5-sonnet",
contents="Hello from Claude!"
)
# Azure models
azure_response = client.models.generate_content(
model="azure/gpt-4o",
contents="Hello from Azure!"
)
# Local Ollama models
ollama_response = client.models.generate_content(
model="ollama/llama3.1:8b",
contents="Hello from Ollama!"
)

Pass custom headers required by DeepintShield plugins (like governance, telemetry, etc.):

from google import genai
from google.genai.types import HttpOptions
# Configure client with custom headers
client = genai.Client(
api_key="dummy-key",
http_options=HttpOptions(
base_url="https://app.deepintshield.com/genai",
headers={
"x-bf-vk": "vk_12345", # Virtual key for governance
}
)
)
response = client.models.generate_content(
model="gemini-2.5-flash",
contents="Hello with custom headers!"
)

Pass API keys directly in requests to bypass DeepintShield’s load balancing. You can pass any provider’s API key (OpenAI, Anthropic, Mistral, etc.) since DeepintShield only looks for Authorization, x-api-key and x-goog-api-key headers. This requires the Allow Direct API keys option to be enabled in DeepintShield configuration.

Learn more: See Key Management for enabling direct API key usage.

from google import genai
from google.genai.types import HttpOptions
# Pass different provider keys per request using headers
client = genai.Client(
api_key="gemini-key",
http_options=HttpOptions(base_url="https://app.deepintshield.com/genai")
)
# Use Gemini key directly
gemini_response = client.models.generate_content(
model="gemini-2.5-flash",
contents="Hello Gemini!"
)
# Use Anthropic key for Claude models
anthropic_response = client.models.generate_content(
model="anthropic/claude-3-5-sonnet",
contents="Hello Claude!",
request_options={
"headers": {"x-api-key": "your-anthropic-api-key"}
}
)
# Use OpenAI key for GPT models
openai_response = client.models.generate_content(
model="openai/gpt-4o-mini",
contents="Hello GPT!",
request_options={
"headers": {"Authorization": "Bearer sk-your-openai-key"}
}
)

Set thinkingConfig.thinkingBudget to -1 to request dynamic thinking. The effect depends on the model you target:

  • Gemini: dynamic thinking is used natively.
  • Anthropic, Bedrock, Cohere: maps to the minimum reasoning budget (1024 tokens).
  • OpenAI: maps to medium reasoning effort.
response = client.models.generate_content(
model="gemini-2.5-flash",
contents="Complex reasoning task",
config={
"thinking_config": {
"include_thoughts": True,
"thinking_budget": -1 # Dynamic thinking
}
}
)

The Google GenAI integration supports all features that are available in both the Google GenAI SDK and DeepintShield core functionality. If the Google GenAI SDK supports a feature and DeepintShield supports it, the integration will work seamlessly.