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 /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/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. |