GenAI Integration

Count tokens (Gemini format)

Counts tokens using Google Gemini API format.

POST
/genai/v1beta/models/{model}:countTokens
AuthorizationBearer <token>

Bearer token authentication. Use your MPilot virtual-key JWT or admin JWT. Virtual keys (prefixed with sk-bf-) can also be passed here.

In: header

Path Parameters

modelstring

Model name with action (e.g., gemini-pro:countTokens)

contents?array<GeminiContent>
generateContentRequest?GeminiGenerationRequest

Response Body

curl -X POST "https://loading/{AI_GATEWAY_URL}/genai/v1beta/models/string:countTokens" \  -H "Content-Type: application/json" \  -d '{}'
{
  "totalTokens": 0,
  "cachedContentTokenCount": 0,
  "promptTokensDetails": [
    {
      "modality": "string",
      "tokenCount": 0
    }
  ],
  "cacheTokensDetails": [
    {
      "modality": "string",
      "tokenCount": 0
    }
  ]
}
{
  "error": {
    "code": 0,
    "message": "string",
    "status": "string",
    "details": [
      {
        "@type": "string",
        "fieldViolations": [
          {
            "description": "string"
          }
        ]
      }
    ]
  }
}
{
  "error": {
    "code": 0,
    "message": "string",
    "status": "string",
    "details": [
      {
        "@type": "string",
        "fieldViolations": [
          {
            "description": "string"
          }
        ]
      }
    ]
  }
}
On this page

On this page

No Headings