Gemini native protocol integration
Choose a model declaring gemini in the public model catalog, then query GET /v1beta/models using your platform credential. Entries use models/{model} for name; supportedGenerationMethods describes generation methods. The list contains only models currently entitled and callable for your credential.
Pass an AICredits key as x-goog-api-key, or use Bearer authentication with a platform credential. Do not supply a Google key. Use the API origin without /v1; native requests use /v1beta.
#!/usr/bin/env bash
set -euo pipefail
: "${AICREDITS_API_KEY:?inject a platform key from a secure source}"
: "${API_BASE_URL:?set the data API origin without a protocol suffix}"
: "${MODEL:?choose an accessible Gemini model ID without models/}"
[[ "$MODEL" =~ ^[A-Za-z0-9_.-]{1,128}$ && "$MODEL" =~ [A-Za-z0-9_-] ]] || exit 1
curl --fail-with-body "${API_BASE_URL%/}/v1beta/models/${MODEL}:generateContent" \
-H "x-goog-api-key: ${AICREDITS_API_KEY}" \
-H 'Content-Type: application/json' \
--data '{"contents":[{"role":"user","parts":[{"text":"<YOUR_PROMPT>"}]}]}'For streaming, change the path to :streamGenerateContent?alt=sse and consume SSE events. Do not add the OpenAI-style stream field. Token counting uses :countTokens and returns totalTokens, rather than the Messages input_tokens field.
Official SDK
TypeScript, Swift, and Kotlin all expose listGeminiModels, getGeminiModel, generateGeminiContent, and countGeminiTokens; TypeScript also exposes streamGeminiContent. Native requests use contents / parts and Gemini parameters, rather than Chat messages.
const result = await gateway.generateGeminiContent(model, {
contents: [{ role: 'user', parts: [{ text: '<YOUR_PROMPT>' }] }],
})A Gemini model may also declare Chat or Messages compatibility. Those endpoints require their corresponding request formats. Capabilities, tools, and output limits depend on the public catalog and selected protocol. See the official SDK guide and streaming guide.