content___part

content___part is a cursor rule for Cursor from altaidevorg/rules-for-ai. It costs 26 tokens per session (3,162 once invoked), scanned A, original, MIT.

A reference rule explaining the Content and Part data structures used to send conversational and multimodal information to Google's Generative AI APIs. Content represents a message or turn, while Part represents pieces such as text, images, or tool results.

In plain words
What is it for?
Use it when building Gemini requests that include conversation roles, text, images, function calls, or other pieces of model input and output.
Why use it?
It clarifies how to structure requests and responses when a conversation contains more than plain text, such as an image and a question in the same turn.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it when building Gemini requests that include conversation roles, text, images, function calls, or other pieces of model input and output.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/altaidevorg/rules-for-ai/content___part
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/altaidevorg/rules-for-ai

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for content___part

README.md
[![agentmods](https://agentmods.dev/badge/rules/altaidevorg/rules-for-ai/content___part/github.svg)](https://agentmods.dev/rules/altaidevorg/rules-for-ai/content___part)
Your own site
<a href="https://agentmods.dev/rules/altaidevorg/rules-for-ai/content___part"><img src="https://agentmods.dev/badge/rules/altaidevorg/rules-for-ai/content___part/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for content___part

Your own site · 80×15
<a href="https://agentmods.dev/rules/altaidevorg/rules-for-ai/content___part"><img src="https://agentmods.dev/badge/rules/altaidevorg/rules-for-ai/content___part.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 26 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,162 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00026 $0.03162
Opus 5.5 $0.00010 $0.01265
Sonnet 5.5 $0.00005 $0.00632
Haiku 4.5 $0.00003 $0.00316

Measured 2mo ago against content hash b6471dd48041, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

content___part scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

examples/google-genai/content___part.mdc · 276 lines

How it starts

The opening of the file, as written. The whole thing — 276 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Chapter 2: Content / Part

In Chapter 1: Client, we learned how to configure the Client to connect to Google's Generative AI APIs. Now that we have a connection, we need to understand how to structure the data we send and receive. This chapter introduces the fundamental data structures for communication: Content and Part.

Motivation and Use Case

Generative models, especially multi-modal ones like Gemini, process information in structured turns. A conversation isn't just a flat string; it involves roles (who is speaking?), different types of data (text, images, function calls/results), and potentially multiple pieces of data within a single turn.

The Content and Part objects provide this necessary structure. Content represents a single message or turn in the conversation, while Part represents individual pieces of data within that turn. This allows for rich interactions beyond simple text prompts.

Central Use Case: Imagine you want to ask a Gemini model to describe an image you provide. You can't just pass a raw image; you need to structure the request clearly indicating the text prompt ("What is in this image?") and the image data itself, both belonging to the 'user' role in a single turn.

# Assuming 'client' is configured as shown in Chapter 1
from google.genai import types
import PIL.Image

# Load an image (replace with your image loading logic)
try:
    img = PIL.Image.open('path/to/your/image.jpg')
except FileNotFoundError:
    print("Please replace 'path/to/your/image.jpg' with an actual image file.")
    exit() # Or handle appropriately

# Explicitly construct Content and Part objects
image_part = types.Part.from_image(img) # Helper to create image part
text_part = types.Part.from_text("Describe this image.")

# Create a Content object for the user's turn
user_content = types.Content(
    role='user',
    parts=[text_part, image_part] # Multi-modal input
)

# Send the structured content to the model
response = client.models.generate_content(
    model='gemini-1.5-flash', # Use an appropriate multi-modal model
    contents=[user_content] # Pass a list of Content objects
)

print(response.text)

This example shows how Content (with role='user') groups multiple Part objects (text_part, image_part) to form a single, multi-modal message turn.

Read the full file on GitHub · 276 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 276 lines · 26 tokens per session scan A b6471dd48041

Subscribe to this mod's changes

content___part is a cursor rule published in the GitHub repository altaidevorg/rules-for-ai (2 stars, last pushed 1y ago), licensed MIT. It adds 26 tokens to every session and 3,162 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.