Bypass Gemini generateContent
Native protocol and authentication
Use an XHub public model name and virtual key with the matching Bypass deployment. XHub maps the model and injects deployment credentials, preserves native fields and enforces access and billing. Bypass does not run the standard pre-call text guardrail chain. Send Authorization: Bearer $XHUB_API_KEY. Model availability depends on configured deployments. The URL specifies the model. The model path also registers :streamGenerateContent and :countTokens. Administrators configure the Gemini upstream address and credentials.
Overview
Gemini / Vertex
Gemini / Vertex
Behavior
URL-encode the public model name in the path. Also supports :streamGenerateContent and :countTokens. Vertex uses /vertex/v1/models/{model} with the same operation suffixes. Provider OAuth credentials stay in deployment settings.
Endpoint and authentication
POST /bypass/gemini/v1beta/models/YOUR_MODEL_NAME:generateContentUse an XHub API key: Authorization: Bearer . Do not use upstream provider credentials as gateway keys.
Use the gateway root Base URL shown in the playground, without appending /v1; send requests to the full endpoint path above.
Request example
curl "$XHUB_BASE_URL/bypass/gemini/v1beta/models/YOUR_MODEL_NAME:generateContent" \
-H "Authorization: Bearer $XHUB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"contents":[{"role":"user","parts":[{"text":"Hello, introduce yourself."}]}]}'Request parameters
| Field | Type | Description |
|---|---|---|
| contents | object[] · required | role and parts with text or supported media. |
| generationConfig / tools | object / array | Generation settings and tool declarations. |
Success response
{
"candidates": [
{
"content": {
"role": "model",
"parts": [
{
"text": "Hello!"
}
]
}
}
],
"usageMetadata": {
"promptTokenCount": 10,
"candidatesTokenCount": 5
}
}| Field | Type |
|---|---|
| candidates | object[] |
| candidates[].content | object |
| candidates[].content.role | string |
| candidates[].content.parts | object[] |
| candidates[].content.parts[].text | string |
| usageMetadata | object |
| usageMetadata.promptTokenCount | number |
| usageMetadata.candidatesTokenCount | number |
Errors and troubleshooting
| HTTP | Meaning |
|---|---|
| 400 | Invalid request. Check JSON, parameters and query. |
| 401 | Missing or invalid XHub credential. |
| 403 | Permission denied. Check model scope or policy. |
| 429 | Limit exceeded. Inspect response details and Retry-After. |