Install
openclaw skills install gemini-citationConduct evidence-based research with exact, accurate APA citations using the Gemini API's 'scientific citation' (Google Search grounding) feature. Use when Xiaoyan (Research Assistant) or others need highly factual, cited research summaries, literature reviews, or exact evidence with inline APA citations tied to real web sources.
openclaw skills install gemini-citationThis skill leverages the Gemini API's Google Search Grounding feature to return heavily factual, exact evidence directly tied to search results, along with properly formatted APA inline and trailing citations. It guarantees that generated facts are grounded in live web references rather than model hallucinations.
You can use the provided script to query the Gemini API with search grounding enabled.
Ensure the GEMINI_API_KEY is set in your environment and the required dependencies are installed:
export GEMINI_API_KEY="your-api-key"
pip install -r requirements.txt
Or install manually:
pip install google-genai
Note: You can get your API key from Google AI Studio.
Execute the gemini_cite.py script with your research topic. The script automatically forces the Gemini API to use Google Search Grounding and requests strict APA formatting.
Recommended: Use gemini-2.5-flash for faster results:
python scripts/gemini_cite.py "Recent breakthroughs in solid-state battery technology" --model gemini-2.5-flash
Or use gemini-2.5-pro for more detailed responses:
python scripts/gemini_cite.py "Recent breakthroughs in solid-state battery technology" --model gemini-2.5-pro
To see structured JSON output containing the exact source titles and URIs used by the model:
python scripts/gemini_cite.py "Recent breakthroughs in solid-state battery technology" --format json
tools=[{"google_search": {}}]. This forces the model to fetch live information before generating a response.grounding_chunks from the Gemini API response metadata and displays the exact source URLs and titles that the model used, ensuring that you have an auditable list of sources alongside the generated APA citations.gemini_cite.py: A Python CLI tool that handles the Gemini API call, enables Google Search grounding, enforces APA citations, and parses the grounding metadata to output verifiable source links.If you prefer to write your own API scripts, the core pattern for enabling exact citations with google-genai is:
from google import genai
from google.genai import types
client = genai.Client(api_key=os.environ.get("GEMINI_API_KEY"))
response = client.models.generate_content(
model='gemini-2.5-flash', # Use flash for speed, or pro for detail
contents='Your research query here...',
config=types.GenerateContentConfig(
tools=[{"google_search": {}}]
)
)
# Access sources
for chunk in response.candidates[0].grounding_metadata.grounding_chunks:
print(chunk.web.title, chunk.web.uri)