Gemini Compatibility Guide
Use the Google Gemini API format with Ask Sage — powered by Vertex AI
Table of Contents
Instance-Specific Base URL: The base URL shown reflects the instance at chat.asksage.ai. The api. prefix and path suffix stay the same across deployments — only the instance segment in the middle changes based on which Ask Sage instance you are logging into. Always use the instance approved by your organization and applicable regulatory requirements, and match the base URL to the instance you authenticate against.
What’s New?
Ask Sage now supports the Google Gemini API format, making it easy to:
Generate Content
The main endpoint for generating content using Gemini models. Requests are routed to Google Vertex AI with automatic regional failover.
YOUR_API_KEY in the x-access-tokens header. Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
x-access-tokens | string (header) | Required | Authentication: YOUR_API_KEY |
model | string (URL path) | Required | Gemini model — see naming formats below |
contents | array | Required | Array of content objects with role (user/model) and parts (text/inlineData/functionCall/functionResponse) |
systemInstruction | object | Optional | System-level instructions — object with role and parts fields |
generationConfig | object | Optional | temperature, topP, topK, maxOutputTokens, candidateCount, stopSequences, responseMimeType, responseSchema |
tools | array | Optional | Array of tool objects containing functionDeclarations for function calling |
safetySettings | array | Optional | Safety filter configuration per category |
Model Naming Formats
The model URL path supports multiple naming formats:
- Simple names:
flash,pro - Standard:
gemini-2.5-pro,gemini-2.5-flash - Preview versions:
gemini-2.5-pro-preview-05-06,gemini-2.5-flash-preview-04-17 - With prefix:
models/gemini-2.5-pro - Vertex format:
publishers/google/models/gemini-2.5-pro
Response
| Status | Description |
|---|---|
200 Success | Returns candidates (with content, finishReason, safetyRatings), usageMetadata (promptTokenCount, candidatesTokenCount, totalTokenCount), and modelVersion |
400 Error | Invalid request format or parameters |
401 Error | Authentication failure — invalid or missing API key |
429 Error | Rate limit exceeded — automatic regional failover will be attempted |
Example: Basic Text Generation
curl -X POST 'https://api.asksage.ai/server/google/v1beta/models/gemini-2.5-flash:generateContent' \
-H 'x-access-tokens: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"contents": [
{
"role": "user",
"parts": [{"text": "What is Ask Sage?"}]
}
]
}'Example: Multi-Turn Conversation with System Instruction
curl -X POST 'https://api.asksage.ai/server/google/v1beta/models/gemini-2.5-pro:generateContent' \
-H 'x-access-tokens: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"systemInstruction": {
"role": "user",
"parts": [{"text": "You are a helpful cybersecurity assistant."}]
},
"contents": [
{"role": "user", "parts": [{"text": "What is zero trust architecture?"}]},
{"role": "model", "parts": [{"text": "Zero trust is a security framework that requires all users to be authenticated and authorized before accessing resources."}]},
{"role": "user", "parts": [{"text": "How does it apply to cloud environments?"}]}
],
"generationConfig": {
"temperature": 0.3,
"maxOutputTokens": 2048
}
}'Example: Function Calling
functionDeclarations within the tools array for function calling. curl -X POST 'https://api.asksage.ai/server/google/v1beta/models/gemini-2.5-flash:generateContent' \
-H 'x-access-tokens: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"contents": [
{"role": "user", "parts": [{"text": "What'\''s the weather like in San Francisco?"}]}
],
"tools": [
{
"functionDeclarations": [
{
"name": "get_weather",
"description": "Get the current weather in a location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
},
"required": ["location"]
}
}
]
}
]
}'Example: Structured JSON Output
curl -X POST 'https://api.asksage.ai/server/google/v1beta/models/gemini-2.5-flash:generateContent' \
-H 'x-access-tokens: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"contents": [
{"role": "user", "parts": [{"text": "List three cloud security best practices"}]}
],
"generationConfig": {
"responseMimeType": "application/json",
"responseSchema": {
"type": "object",
"properties": {
"practices": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"description": {"type": "string"}
}
}
}
}
}
}
}'Available Models
| Model | Provider | Capability |
|---|---|---|
gemini-2.5-flash | Google Vertex AI | Default — fast and efficient for most tasks |
gemini-2.5-pro | Google Vertex AI | Most capable — complex reasoning and analysis |
us-central1, us-east1, us-east4, us-east5, us-south1, us-west1, us-west4) for high availability on rate-limit or capacity errors. How It Works
Ask Sage's google/v1/* endpoints follow the Google Gemini API specification, making integration seamless.
- Your application sends a request to
https://api.asksage.ai/server/google/v1beta/models/{model}:generateContent - Ask Sage validates your authentication token
- The model name is resolved and the request is routed to Google Vertex AI
- If a region hits rate limits, the request automatically retries in the next available region
- The response is returned in standard Gemini API format
https://api.asksage.ai/server/google/v1beta) with x-access-tokens header authentication. Role Mapping
Ask Sage automatically handles role normalization for convenience:
| Input Role | Mapped To | Notes |
|---|---|---|
user | user | No change |
model | model | No change |
assistant | model | Automatically mapped for OpenAI compatibility |
system | systemInstruction | Extracted and merged into the system instruction field |