> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/products/es/web-scraper-api/objetivos/llm-e-ia/gemini.md).

# Gemini

Extrae respuestas de Gemini enviando prompts y recibe datos analizados como JSON estructurado, texto plano o Markdown.

El `gemini` la fuente le permite enviar un prompt a Google **Gemini** y recibir una respuesta analizada y estructurada, incluidas las respuestas en texto plano y Markdown.

## Ejemplos de solicitud

Los siguientes ejemplos de código muestran cómo enviar un prompt a Gemini usando [**Push-Pull**](/products/es/web-scraper-api/integration-methods/push-pull.md).

{% tabs %}
{% tab title="cURL" %}

```bash
curl 'https://data.oxylabs.io/v1/queries' \
--user 'USERNAME:PASSWORD' \
-H 'Content-Type: application/json' \
-d '{
        "source": "gemini",
        "prompt": "best supplements for better sleep",
        "parse": true,
        "geo_location": "United States",
        "callback_url": "https://your-server.com/oxylabs-callback"
    }'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
from pprint import pprint

# Structure payload.
payload = {
    'source': 'gemini',
    'prompt': 'best supplements for better sleep',
    'parse': True,
    'geo_location': "United States",
    'callback_url': "https://your-server.com/oxylabs-callback"
}

# Get response.
response = requests.request(
    'POST',
    'https://data.oxylabs.io/v1/queries',
    auth=('USERNAME', 'PASSWORD'),
    json=payload,
)

# Print prettified response to stdout.
pprint(response.json())
```

{% endtab %}

{% tab title="Node.js" %}

```js
const https = require("https");

const username = "USERNAME";
const password = "PASSWORD";
const body = {
    source: "gemini",
    prompt: "best supplements for better sleep",
    parse: true,
    geo_location: "United States",
    callback_url: "https://your-server.com/oxylabs-callback"
};

const options = {
    hostname: "data.oxylabs.io",
    path: "/v1/queries",
    method: "POST",
    headers: {
        "Content-Type": "application/json",
        Authorization:
            "Basic " + Buffer.from(`${username}:${password}`).toString("base64"),
    },
};

const request = https.request(options, (response) => {
    let data = "";

    response.on("data", (chunk) => {
        data += chunk;
    });

    response.on("end", () => {
        const responseData = JSON.parse(data);
        console.log(JSON.stringify(responseData, null, 2));
    });
});

request.on("error", (error) => {
    console.error("Error:", error);
});

request.write(JSON.stringify(body));
request.end();
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$params = array(
    'source' => 'gemini',
    'prompt' => 'best supplements for better sleep',
    'parse' => true,
    'geo_location' => "United States",
    'callback_url' => "https://your-server.com/oxylabs-callback"
);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://data.oxylabs.io/v1/queries");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "USERNAME" . ":" . "PASSWORD");

$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
echo $result;

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);
```

{% endtab %}

{% tab title="Go" %}

```go
package main

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

func main() {
const Username = "USERNAME"
const Password = "PASSWORD"

payload := map[string]interface{}{
"source":       "gemini",
"prompt":       "best supplements for better sleep",
"parse":        true,
"geo_location": "United States",
"callback_url": "https://your-server.com/oxylabs-callback",
}

jsonValue, _ := json.Marshal(payload)

client := &http.Client{}
request, _ := http.NewRequest("POST",
"https://data.oxylabs.io/v1/queries",
bytes.NewBuffer(jsonValue),
)

request.SetBasicAuth(Username, Password)
response, _ := client.Do(request)

responseText, _ := ioutil.ReadAll(response.Body)
fmt.Println(string(responseText))
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;

namespace OxyApi
{
    class Program
    {
        static async Task Main()
        {
            const string Username = "USERNAME";
            const string Password = "PASSWORD";

            var parameters = new
            {
                source = "gemini",
                prompt = "best supplements for better sleep",
                parse = true,
                geo_location = "United States",
                callback_url = "https://your-server.com/oxylabs-callback"
            };

            var client = new HttpClient();

            Uri baseUri = new Uri("https://data.oxylabs.io");
            client.BaseAddress = baseUri;

            var requestMessage = new HttpRequestMessage(HttpMethod.Post, "/v1/queries");
            requestMessage.Content = JsonContent.Create(parameters);

            var authenticationString = $"{Username}:{Password}";
            var base64EncodedAuthenticationString = Convert.ToBase64String(System.Text.ASCIIEncoding.UTF8.GetBytes(authenticationString));
            requestMessage.Headers.Add("Authorization", "Basic " + base64EncodedAuthenticationString);

            var response = await client.SendAsync(requestMessage);
            var contents = await response.Content.ReadAsStringAsync();

            Console.WriteLine(contents);
        }
    }
}
```

{% endtab %}

{% tab title="Java" %}

```java
package org.example;

import okhttp3.*;
import org.json.JSONObject;

public class Main implements Runnable {
    private static final String AUTHORIZATION_HEADER = "Authorization";
    public static final String USERNAME = "USERNAME";
    public static final String PASSWORD = "PASSWORD";

    public void run() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("source", "gemini");
        jsonObject.put("prompt", "best supplements for better sleep");
        jsonObject.put("parse", true);
        jsonObject.put("geo_location", "United States");
        jsonObject.put("callback_url", "https://your-server.com/oxylabs-callback");

        Authenticator authenticator = (route, response) -> {
            String credential = Credentials.basic(USERNAME, PASSWORD);
            return response
                    .request()
                    .newBuilder()
                    .header(AUTHORIZATION_HEADER, credential)
                    .build();
        };

        var client = new OkHttpClient.Builder()
                .authenticator(authenticator)
                .build();

        var mediaType = MediaType.parse("application/json; charset=utf-8");
        var body = RequestBody.create(jsonObject.toString(), mediaType);
        var request = new Request.Builder()
                .url("https://data.oxylabs.io/v1/queries")
                .post(body)
                .build();

        try (var response = client.newCall(request).execute()) {
            if (response.body() != null) {
                try (var responseBody = response.body()) {
                    System.out.println(responseBody.string());
                }
            }
        } catch (Exception exception) {
            System.out.println("Error: " + exception.getMessage());
        }

        System.exit(0);
    }

    public static void main(String[] args) {
        new Thread(new Main()).start();
    }
}
```

{% endtab %}

{% tab title="JSON" %}

```json
{
    "source": "gemini",
    "prompt": "best supplements for better sleep",
    "parse": true,
    "geo_location": "United States",
    "callback_url": "https://your-server.com/oxylabs-callback"
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Nota:** El renderizado de JavaScript está habilitado de forma predeterminada para todas las fuentes LLM. No necesita incluir parámetros de renderizado en su carga útil de solicitud.
{% endhint %}

Al enviar un trabajo con [**Push-Pull**](/products/es/web-scraper-api/integration-methods/push-pull.md) el método de integración (incluidas [las consultas por lotes](/products/es/web-scraper-api/integration-methods/push-pull.md#batch-query)) devuelve el ID del trabajo inmediatamente – no el resultado. Una vez que el estado del trabajo sea `done`, recupere la respuesta analizada. Consulte [**el método de integración**](/products/es/web-scraper-api/integration-methods.md) en la página de LLMs and AI para ver el flujo completo de envío y recuperación.

### Parámetros de solicitud

Configuración básica y opciones de personalización para extraer datos de Gemini.

<table><thead><tr><th width="222">Parámetro</th><th width="350.3333333333333">Descripción</th><th>Valor predeterminado</th></tr></thead><tbody><tr><td><mark style="background-color:green;"><strong><code>source</code></strong></mark></td><td>Establece el objetivo del scraper. Usa <code>gemini</code>.</td><td>–</td></tr><tr><td><mark style="background-color:green;"><strong><code>prompt</code></strong></mark></td><td>El prompt o la pregunta que se enviará a Gemini. Hasta 8.000 caracteres.</td><td>–</td></tr><tr><td><code>callback_url</code></td><td><strong>Recomendado.</strong> URL donde entregamos una notificación una vez que el trabajo se completa. <a href="https://developers.oxylabs.io/products/web-scraper-api/integration-methods/push-pull"><strong>Más información</strong></a><strong>.</strong></td><td>–</td></tr><tr><td><code>parse</code></td><td>Establézcalo en <code>true</code> para datos JSON estructurados.</td><td><code>false</code></td></tr><tr><td><code>geo_location</code></td><td>Especifique un país desde el que enrutar la solicitud. <a href="/products/es/web-scraper-api/features/localization.md"><strong>Más información</strong></a>.</td><td>–</td></tr><tr><td><code>browser_instructions</code></td><td>Instrucciones personalizadas opcionales del navegador al renderizar JavaScript. <a href="/products/es/web-scraper-api/features/js-rendering-and-browser-control.md#browser-instructions"><strong>Más información</strong></a>.</td><td>–</td></tr></tbody></table>

&#x20;   \- parámetro obligatorio

## Datos estructurados

Una vez que el trabajo se recupera a través del endpoint de resultados Push-Pull, Web Scraper API es capaz de extraer un objeto JSON que contiene la salida de Gemini y ofrece datos estructurados sobre varios elementos de la página de resultados.

<details>

<summary><code>gemini</code> salida estructurada</summary>

```json
{
  "results": [
    {
      "job_id": "7470031540181837825",
      "status_code": 200,
      "url": "https://gemini.google.com/app/ca6b069d5af5c809",
      "content": {
        "prompt": "best supplements for better sleep",
        "response_text": "If you are tossing and turning, you are definitely not alone. The supplement aisle is packed with options promising to help you drift off, but they generally fall into a few different categories based on how they actually affect your body. Here...",
        "markdown_text": "If you are tossing and turning, you are definitely not alone. The supplement aisle is packed with options promising to help you drift off, but they generally fall into a few different categories based on how they actually affect your body.\n\n Here...",
        "citations": [
          {
            "title": "Hartford HealthCare",
            "url": "https://hartfordhealthcare.org/about-us/news-press/news-detail?articleId=66180",
            "text": "Can These 3 Supplements Really Improve Your Sleep? | Hartford HealthCare | CT",
            "description": "- Valerian root. This herbal sleep option likely works by acting on GABA receptors in the brain, just like magnesium. \"But it's not without side effects,\" says ..."
          },
          {
            "title": "BBC Good Food",
            "url": "https://www.bbcgoodfood.com/review/best-sleep-supplements#:~:text=It's%20easy%20to%20get%20enough,a%20role%20in%20sleep%20regulation.",
            "text": "The best sleep supplements 2026 – tried and tested - BBC Good Food",
            "description": "It's easy to get enough through diet, but if you are looking to supplement, the NRV is around 300mg, and look for magnesium glycinate which has been shown to ..."
          },
          {
            "title": "PMC - NIH",
            "url": "https://pmc.ncbi.nlm.nih.gov/articles/PMC11082867/#:~:text=Melatonin%20is%20a%20hormone%20produced,promotes%20relaxation%20and%20reduced%20alertness.",
            "text": "Current Evidence on Common Dietary Supplements for Sleep Quality - PMC - NIH",
            "description": "Melatonin is a hormone produced by the pineal gland in the brain and plays a critical role in regulation of the sleep-wake cycle. The pineal gland begins ..."
          },
          ...
        ],
        "additional_results": {
          "sources_results": [
            {
              "title": "Best Sleep Supplements 2026: Evidence-Ranked Picks for Deeper",
              "url": "https://www.bettervitals.com/learn/best-sleep-supplement-stack-2026"
            },
            {
              "title": "10 of the Best Natural Sleep Aids in 2026 - Healthline",
              "url": "https://www.healthline.com/nutrition/sleep-aids"
            },
            ...
          ]
        },
        "parse_status_code": 12000
      }
    }
  ]
}
```

</details>

{% hint style="warning" %}
La composición de la respuesta puede variar según si la consulta se realizó desde un **dispositivo de escritorio** o **móvil** dispositivo.
{% endhint %}

### Diccionario de datos de salida

Todos los destinos LLM devuelven el mismo sobre de nivel superior de `job` y `results[]` . Consulte [LLMs and AI](/api-reference/dedicated-scrapers/llm-and-ai-scrapers.md) para la referencia completa de metadatos.

La siguiente tabla muestra los campos específicos de Gemini de `results[].content` campos:

<table><thead><tr><th width="181.17578125">Nombre del campo</th><th width="427">Descripción</th><th>Tipo</th></tr></thead><tbody><tr><td><code>prompt</code></td><td>Prompt enviado.</td><td>cadena</td></tr><tr><td><code>raw_response</code></td><td>Respuesta en streaming sin procesar de Gemini, una línea por elemento.</td><td>arreglo de cadenas</td></tr><tr><td><code>response_text</code></td><td>Respuesta de texto plano de Gemini.</td><td>cadena</td></tr><tr><td><code>markdown_text</code></td><td>Respuesta completa en Markdown.</td><td>cadena</td></tr><tr><td><mark style="background-color:$warning;"><code>citations</code></mark></td><td>Citas de fuentes referenciadas en la respuesta. Cada objeto contiene <code>title</code>, <code>url</code>, <code>text</code>y <code>description</code>.</td><td>arreglo</td></tr><tr><td><mark style="background-color:$warning;"><code>additional_results</code></mark></td><td>Resultados de búsqueda adicionales. <code>sources_results</code> - lista de páginas web que Gemini consultó al responder (<code>title</code> y <code>url</code>).</td><td>objeto</td></tr><tr><td><code>parse_status_code</code></td><td><code>12000</code> – correcto. De lo contrario, el parser no pudo extraer algunos o todos los campos estructurados.</td><td>entero</td></tr><tr><td><mark style="background-color:$warning;"><code>model</code></mark></td><td>Modelo de IA utilizado para generar la respuesta.</td><td>cadena</td></tr></tbody></table>

&#x20;    – condicional, se devuelve solo cuando el contenido está en la respuesta del LLM.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.oxylabs.io/products/es/web-scraper-api/objetivos/llm-e-ia/gemini.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
