> ## Documentation Index
> Fetch the complete documentation index at: https://gccai.heqingsong.uk/llms.txt
> Use this file to discover all available pages before exploring further.

# Formato nativo de Gemini

>  - Llame a los modelos Gemini utilizando el formato nativo de la API de Google
- Modo de procesamiento síncrono con respuesta en tiempo real
- Parámetros mínimos para empezar rápidamente 

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://gccai.heqingsong.uk/v1beta/models/gemini-2.5-pro:generateContent \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
    "contents": [
      {
        "role": "user",
        "parts": [
          {
            "text": "Hello, please introduce yourself"
          }
        ]
      }
    ]
  }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://gccai.heqingsong.uk/v1beta/models/gemini-2.5-pro:generateContent"

  payload = {
      "contents": [
          {
              "role": "user",
              "parts": [
                  {
                      "text": "Hello, please introduce yourself"
                  }
              ]
          }
      ]
  }

  headers = {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
  }

  response = requests.post(url, json=payload, headers=headers)

  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const url = "https://gccai.heqingsong.uk/v1beta/models/gemini-2.5-pro:generateContent";

  const payload = {
    contents: [
      {
        role: "user",
        parts: [
          {
            text: "Hello, please introduce yourself"
          }
        ]
      }
    ]
  };

  const headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
  };

  fetch(url, {
    method: "POST",
    headers: headers,
    body: JSON.stringify(payload)
  })
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error));
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "io/ioutil"
      "net/http"
  )

  func main() {
      url := "https://gccai.heqingsong.uk/v1beta/models/gemini-2.5-pro:generateContent"

      payload := map[string]interface{}{
          "contents": []map[string]interface{}{
              {
                  "role": "user",
                  "parts": []map[string]interface{}{
                      {
                          "text": "Hello, please introduce yourself",
                      },
                  },
              },
          },
      }

      jsonData, _ := json.Marshal(payload)

      req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
      req.Header.Set("Authorization", "Bearer <token>")
      req.Header.Set("Content-Type", "application/json")

      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          panic(err)
      }
      defer resp.Body.Close()

      body, _ := ioutil.ReadAll(resp.Body)
      fmt.Println(string(body))
  }
  ```

  ```java Java theme={null}
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;
  import java.net.URI;

  public class Main {
      public static void main(String[] args) throws Exception {
          String url = "https://gccai.heqingsong.uk/v1beta/models/gemini-2.5-pro:generateContent";

          String payload = """
          {
            "contents": [
              {
                "role": "user",
                "parts": [
                  {
                    "text": "Hello, please introduce yourself"
                  }
                ]
              }
            ]
          }
          """;

          HttpClient client = HttpClient.newHttpClient();
          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create(url))
              .header("Authorization", "Bearer <token>")
              .header("Content-Type", "application/json")
              .POST(HttpRequest.BodyPublishers.ofString(payload))
              .build();

          HttpResponse<String> response = client.send(request,
              HttpResponse.BodyHandlers.ofString());

          System.out.println(response.body());
      }
  }
  ```

  ```php PHP theme={null}
  <?php

  $url = "https://gccai.heqingsong.uk/v1beta/models/gemini-2.5-pro:generateContent";

  $payload = [
      "contents" => [
          [
              "role" => "user",
              "parts" => [
                  [
                      "text" => "Hello, please introduce yourself"
                  ]
              ]
          ]
      ]
  ];

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      "Authorization: Bearer <token>",
      "Content-Type: application/json"
  ]);

  $response = curl_exec($ch);
  curl_close($ch);

  echo $response;
  ?>
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'json'
  require 'uri'

  url = URI("https://gccai.heqingsong.uk/v1beta/models/gemini-2.5-pro:generateContent")

  payload = {
    contents: [
      {
        role: "user",
        parts: [
          {
            text: "Hello, please introduce yourself"
          }
        ]
      }
    ]
  }

  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(url)
  request["Authorization"] = "Bearer <token>"
  request["Content-Type"] = "application/json"
  request.body = payload.to_json

  response = http.request(request)
  puts response.body
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": 200,
    "data": {
      "candidates": [
        {
          "content": {
            "role": "model",
            "parts": [
              {
                "text": "Hello! I'm pleased to introduce myself.\n\nI am a large language model, trained and developed by Google..."
              }
            ]
          },
          "finishReason": "STOP",
          "index": 0,
          "safetyRatings": [
            {
              "category": "HARM_CATEGORY_HATE_SPEECH",
              "probability": "NEGLIGIBLE"
            }
          ]
        }
      ],
      "promptFeedback": {
        "safetyRatings": [
          {
            "category": "HARM_CATEGORY_HATE_SPEECH",
            "probability": "NEGLIGIBLE"
          }
        ]
      ]
    },
    "usageMetadata": {
      "promptTokenCount": 4,
      "candidatesTokenCount": 611,
      "totalTokenCount": 2422,
      "thoughtsTokenCount": 1807,
      "promptTokensDetails": [
        {
          "modality": "TEXT",
          "tokenCount": 4
        }
      ]
    }
  }
  ```

  ```json 400 theme={null}
  {
    "error": {
      "code": 400,
      "message": "Invalid request parameters",
      "status": "INVALID_ARGUMENT"
    }
  }
  ```

  ```json 401 theme={null}
  {
    "error": {
      "code": 401,
      "message": "Authentication failed, please check your API Key",
      "status": "UNAUTHENTICATED"
    }
  }
  ```

  ```json 402 theme={null}
  {
    "error": {
      "code": 402,
      "message": "Insufficient balance, please recharge",
      "status": "PAYMENT_REQUIRED"
    }
  }
  ```

  ```json 403 theme={null}
  {
    "error": {
      "code": 403,
      "message": "Access denied",
      "status": "PERMISSION_DENIED"
    }
  }
  ```

  ```json 404 theme={null}
  {
    "error": {
      "code": 404,
      "message": "Model not found",
      "status": "NOT_FOUND"
    }
  }
  ```

  ```json 429 theme={null}
  {
    "error": {
      "code": 429,
      "message": "Rate limit exceeded, please try again later",
      "status": "RESOURCE_EXHAUSTED"
    }
  }
  ```

  ```json 500 theme={null}
  {
    "error": {
      "code": 500,
      "message": "Internal server error",
      "status": "INTERNAL"
    }
  }
  ```

  ```json 502 theme={null}
  {
    "error": {
      "code": 502,
      "message": "Bad gateway, service temporarily unavailable",
      "status": "BAD_GATEWAY"
    }
  }
  ```

  ```json 503 theme={null}
  {
    "error": {
      "code": 503,
      "message": "Service temporarily unavailable",
      "status": "UNAVAILABLE"
    }
  }
  ```
</ResponseExample>

## Autorizaciones

<ParamField header="Authorization" type="string" required>
  Todos los endpoints de la API requieren autenticación mediante Bearer Token

  Obtenga su API Key:

  Visite la [página de gestión de API Keys](https://gccai.heqingsong.uk/keys) para obtener su API Key

  Añádala al encabezado de la solicitud:

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## Parámetros de ruta

<ParamField path="model" type="string" required>
  Nombre del modelo

  Los ejemplos utilizan `gemini-2.5-pro`, que puede reemplazar por otros modelos Gemini admitidos:

  * `gemini-3.5-flash` - Gemini 3.5 Flash
  * `gemini-3.1-pro-preview` - Gemini 3.1 Pro Preview
  * `gemini-3-pro-preview` - Gemini 3 Pro Preview
  * `gemini-2.5-pro` - Gemini 2.5 Pro
</ParamField>

<ParamField path="method" type="enum<string>" required>
  Método de generación (recomendado: `generateContent` para empezar rápidamente):

  * `generateContent`: Espera la respuesta completa y la devuelve de una sola vez
  * `streamGenerateContent`: Respuesta en streaming, devuelve el contenido por fragmentos

  Opciones disponibles: `generateContent`, `streamGenerateContent`
</ParamField>

## Body

<ParamField body="contents" type="array" required>
  Lista de contenidos de la conversación

  Se requiere un mínimo de 1 mensaje

  <Expandable title="Estructura del objeto contents">
    <ParamField body="role" type="string" required>
      Tipo de rol:

      * `user`: Mensaje del usuario
      * `model`: Respuesta del modelo (utilizado en el historial de conversación)
    </ParamField>

    <ParamField body="parts" type="array" required>
      Partes del contenido del mensaje

      <Expandable title="Estructura del objeto parts">
        <ParamField body="text" type="string">
          Contenido de texto
        </ParamField>

        <ParamField body="inlineData" type="object">
          Datos en línea (para entrada multimodal)

          <Expandable title="Propiedades de inlineData">
            <ParamField body="mimeType" type="string">
              Tipo MIME, por ejemplo `image/jpeg`, `image/png`
            </ParamField>

            <ParamField body="data" type="string">
              Datos codificados en Base64
            </ParamField>
          </Expandable>
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>

  Ejemplo:

  ```json theme={null}
  [
    {
      "role": "user",
      "parts": [{ "text": "Hello, please introduce yourself" }]
    }
  ]
  ```
</ParamField>

<ParamField body="generationConfig" type="object">
  Configuración de generación (opcional)

  <Expandable title="Propiedades de generationConfig">
    <ParamField body="temperature" type="number">
      Controla la aleatoriedad de la salida, rango 0.0-2.0

      * Los valores más bajos hacen la salida más determinística
      * Los valores más altos hacen la salida más aleatoria

      Valor por defecto: 1.0
    </ParamField>

    <ParamField body="maxOutputTokens" type="integer">
      Número máximo de tokens a generar

      Los distintos modelos tienen límites máximos diferentes
    </ParamField>

    <ParamField body="topP" type="number">
      Parámetro de muestreo por núcleo (nucleus sampling), rango 0.0-1.0

      Controla la masa de probabilidad considerada durante el muestreo
    </ParamField>

    <ParamField body="topK" type="integer">
      Parámetro de muestreo Top-K

      Muestrea solo los K tokens más probables en cada paso
    </ParamField>

    <ParamField body="stopSequences" type="array">
      Lista de secuencias de parada

      Detiene la generación cuando se encuentran estas secuencias
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="safetySettings" type="array">
  Configuraciones de seguridad (opcional)

  <Expandable title="Estructura del objeto safetySettings">
    <ParamField body="category" type="string">
      Categoría de seguridad:

      * `HARM_CATEGORY_HATE_SPEECH`: Discurso de odio
      * `HARM_CATEGORY_DANGEROUS_CONTENT`: Contenido peligroso
      * `HARM_CATEGORY_HARASSMENT`: Acoso
      * `HARM_CATEGORY_SEXUALLY_EXPLICIT`: Contenido sexualmente explícito
    </ParamField>

    <ParamField body="threshold" type="string">
      Nivel de umbral:

      * `BLOCK_NONE`: No bloquear
      * `BLOCK_ONLY_HIGH`: Bloquear solo riesgo alto
      * `BLOCK_MEDIUM_AND_ABOVE`: Bloquear riesgo medio y superior
      * `BLOCK_LOW_AND_ABOVE`: Bloquear riesgo bajo y superior
    </ParamField>
  </Expandable>
</ParamField>

## Respuesta

<ResponseField name="candidates" type="array">
  Lista de respuestas candidatas

  <Expandable title="Estructura del objeto candidates">
    <ResponseField name="content" type="object">
      Contenido generado

      <Expandable title="Propiedades de content">
        <ResponseField name="role" type="string">
          Rol, normalmente `model`
        </ResponseField>

        <ResponseField name="parts" type="array">
          Lista de partes del contenido

          <Expandable title="Objeto parts">
            <ResponseField name="text" type="string">
              Contenido textual generado
            </ResponseField>
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="finishReason" type="string">
      Motivo de finalización:

      * `STOP`: Finalización normal
      * `MAX_TOKENS`: Se alcanzó el límite máximo de tokens
      * `SAFETY`: Se detuvo por motivos de seguridad
      * `RECITATION`: Se detuvo por recitación
      * `OTHER`: Otros motivos
    </ResponseField>

    <ResponseField name="index" type="integer">
      Índice de la respuesta candidata
    </ResponseField>

    <ResponseField name="safetyRatings" type="array">
      Lista de calificaciones de seguridad

      <Expandable title="Objeto safetyRatings">
        <ResponseField name="category" type="string">
          Categoría de seguridad
        </ResponseField>

        <ResponseField name="probability" type="string">
          Nivel de probabilidad: `NEGLIGIBLE`, `LOW`, `MEDIUM`, `HIGH`
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="promptFeedback" type="object">
  Información de retroalimentación del prompt

  <Expandable title="Propiedades de promptFeedback">
    <ResponseField name="safetyRatings" type="array">
      Calificaciones de seguridad del prompt
    </ResponseField>

    <ResponseField name="blockReason" type="string">
      Motivo de bloqueo (si el prompt fue bloqueado)
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="usageMetadata" type="object">
  Estadísticas de uso

  <Expandable title="Propiedades de usageMetadata">
    <ResponseField name="promptTokenCount" type="integer">
      Número de tokens del prompt
    </ResponseField>

    <ResponseField name="candidatesTokenCount" type="integer">
      Número de tokens en las respuestas candidatas
    </ResponseField>

    <ResponseField name="totalTokenCount" type="integer">
      Número total de tokens consumidos
    </ResponseField>

    <ResponseField name="thoughtsTokenCount" type="integer">
      Número de tokens utilizados para razonamiento (si aplica)
    </ResponseField>

    <ResponseField name="promptTokensDetails" type="array">
      Detalles de los tokens del prompt

      <Expandable title="Objeto promptTokensDetails">
        <ResponseField name="modality" type="string">
          Tipo de modalidad: `TEXT`, `IMAGE`, etc.
        </ResponseField>

        <ResponseField name="tokenCount" type="integer">
          Número de tokens de esta modalidad
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>
