POST/v1beta/models/{model}:generateContent

Generate content (Gemini)

Google's generateContent. Every model in the catalog is callable here, not only Gemini. Both camelCase and snake_case field names are accepted.

Refused with a 400: cachedContent, Google server tools (googleSearch, codeExecution, urlContext), File API handles, candidateCount other than 1, and non-text responseModalities. safetySettings, labels and seed are dropped and named in x-experiential-ignored-parameters.

Authentication: Bearer API key in the Authorization header

Path parameters

  • modelstringrequired

    A model slug.

Request body

  • contentsarray<object>required

    Turns of parts: text, inlineData, public fileData URLs, functionCall, functionResponse.

  • systemInstructionobject
  • toolsarray<object>

    functionDeclarations only; Google server tools are refused.

  • toolConfigobject
  • generationConfigobject

    Sampling, maxOutputTokens, stopSequences, responseSchema or responseJsonSchema, thinkingConfig.

  • providerobject

    OpenRouter's routing-preference object, resolved against the model's own provider routes. Only tightens, never loosens, your organization's policy.

    provider
    • zdrboolean

      true serves only zero-data-retention routes for this request, or refuses with a 403 naming the excluded providers.

    • onlyarray<string>

      Keep only these providers.

    • ignorearray<string>

      Drop these providers.

    • orderarray<string>

      Try these providers first, in order; the rest stay as fallbacks.

    • allow_fallbacksboolean

      false with order serves only the listed providers; without order, only the first eligible route.

Responses

  • 200

    One GenerateContentResponse.

    Response
    • candidatesarray<object>
    • usageMetadataany

      Google's usage plus Experiential's cost and is_byok.

      usageMetadata
      • promptTokenCountinteger
      • candidatesTokenCountinteger
      • totalTokenCountinteger
      • thoughtsTokenCountinteger
      • cachedContentTokenCountinteger
      • costnumber

        USD actually charged to your credits for this request, as a float (promotions and plan discounts already applied). 0 on your own provider key.

      • is_byokboolean

        True when the request ran on your own provider key, which the platform never charges.

      • cost_detailsobject

        Present only in two cases: upstream_inference_cost (USD, your own key: the provider's list charge to you) or list_cost (USD, a platform-funded call charged below list: what it would have cost).

        cost_details
        • upstream_inference_costnumber
        • list_costnumber
    • responseIdstring
    • modelVersionstring
    • providerstring

      Experiential extension. The provider that served this request.

  • 400

    Invalid request, in the Google envelope.

    Response
    • errorobject
      error
      • codeinteger

        The HTTP status.

      • messagestring
      • statusstring

        For example INVALID_ARGUMENT, UNAUTHENTICATED, RESOURCE_EXHAUSTED.

      • detailsarray<object>
  • 401

    The key is missing or invalid.

    Response
    • errorobject
      error
      • codeinteger

        The HTTP status.

      • messagestring
      • statusstring

        For example INVALID_ARGUMENT, UNAUTHENTICATED, RESOURCE_EXHAUSTED.

      • detailsarray<object>
  • 429

    Rate limited or out of credits. RetryInfo carries the wait when retrying helps.

    Response
    • errorobject
      error
      • codeinteger

        The HTTP status.

      • messagestring
      • statusstring

        For example INVALID_ARGUMENT, UNAUTHENTICATED, RESOURCE_EXHAUSTED.

      • detailsarray<object>

Request

curl https://api.experientiallabs.ai/v1beta/models/gpt-6-luna:generateContent \
  -H "x-goog-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contents": [{"role": "user", "parts": [{"text": "Say hi."}]}]}'

Response

{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "Hi!"
          }
        ]
      },
      "finishReason": "STOP",
      "index": 0
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 3,
    "candidatesTokenCount": 2,
    "totalTokenCount": 5,
    "cost": 0.0000013,
    "is_byok": false
  },
  "responseId": "resp_0b7e4f2a9c1d46e8b3a5f7c9e1d2b4a6",
  "modelVersion": "gpt-6-luna",
  "provider": "openai"
}

https://api.experientiallabs.ai/v1beta/models/gpt-6-luna:generateContent