Class GenerateContentRequest
- Namespace
- GenerativeAI.Types
- Assembly
- GenerativeAI.dll
Request to generate content.
public class GenerateContentRequest : IContentsRequest
- Inheritance
-
GenerateContentRequest
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
GenerateContentRequest()
Represents a request to generate content. This class contains parameters required to define the specifics of content generation, including inputs, tools, configurations, and safety constraints.
public GenerateContentRequest()
GenerateContentRequest(Content)
Represents a request to generate content. This class enables the definition of content generation specifics through properties such as the content details, tools, tool configurations, safety settings, and system instructions. Optional configurations allow customization and adaptation of the generation process.
public GenerateContentRequest(Content content)
Parameters
contentContent
GenerateContentRequest(List<Content>, List<Tool>?, ToolConfig?, List<SafetySetting>?, Content?, GenerationConfig?, string?)
Represents a request used to generate content. This class includes properties like content, tools, configurations, safety settings, and instructions required for the content generation process.
public GenerateContentRequest(List<Content> contents, List<Tool>? tools = null, ToolConfig? toolConfig = null, List<SafetySetting>? safetySettings = null, Content? systemInstruction = null, GenerationConfig? generationConfig = null, string? cachedContent = null)
Parameters
contentsList<Content>toolsList<Tool>toolConfigToolConfigsafetySettingsList<SafetySetting>systemInstructionContentgenerationConfigGenerationConfigcachedContentstring
Properties
CachedContent
Optional. The name of the content
cached to use as context
to serve the prediction. Format: cachedContents/{cachedContent}
[JsonPropertyName("cachedContent")]
public string? CachedContent { get; set; }
Property Value
Contents
Required. The content of the current conversation with the model. For single-turn queries, this is a single instance. For multi-turn queries like chat, this is a repeated field that contains the conversation history and the latest request.
[JsonPropertyName("contents")]
public List<Content> Contents { get; set; }
Property Value
ContinuationToken
Base64-encoded token from Candidate.ContinuationToken; resumes a response that ended with FinishReason CONTINUATION.
[JsonPropertyName("continuationToken")]
public string? ContinuationToken { get; set; }
Property Value
GenerationConfig
Optional. Configuration options for model generation and outputs.
[JsonPropertyName("generationConfig")]
public GenerationConfig? GenerationConfig { get; set; }
Property Value
Labels
User-defined labels attached to the request, for example for billing breakdowns.
[JsonPropertyName("labels")]
public Dictionary<string, string>? Labels { get; set; }
Property Value
ModelArmorConfig
Model Armor templates for sanitizing the prompt and response. Vertex AI only.
[JsonPropertyName("modelArmorConfig")]
public ModelArmorConfig? ModelArmorConfig { get; set; }
Property Value
OutputConfig
Where to write generated output. Vertex AI only.
[JsonPropertyName("outputConfig")]
public GenerationOutputConfig? OutputConfig { get; set; }
Property Value
SafetySettings
Optional. A list of unique SafetySetting instances for blocking unsafe content. This will be enforced on the GenerateContentRequest.Contents and GenerateContentResponse.Candidates. There should not be more than one setting for each SafetyCategory type. The API will block any contents and responses that fail to meet the thresholds set by these settings. This list overrides the default settings for each SafetyCategory specified in the SafetySettings. If there is no SafetySetting for a given SafetyCategory provided in the list, the API will use the default safety setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_HARASSMENT, HARM_CATEGORY_CIVIC_INTEGRITY are supported. Refer to the guide for detailed information on available safety settings. Also refer to the Safety guidance to learn how to incorporate safety considerations in your AI applications.
[JsonPropertyName("safetySettings")]
public List<SafetySetting>? SafetySettings { get; set; }
Property Value
ServiceTier
Processing tier for the request; see ServiceTiers for values (standard, flex, priority).
[JsonPropertyName("serviceTier")]
public string? ServiceTier { get; set; }
Property Value
Store
Whether Google may store the request and response (Gemini API only). New paid-tier projects store requests by default; set false to opt out.
[JsonPropertyName("store")]
public bool? Store { get; set; }
Property Value
- bool?
SystemInstruction
Optional. Developer set system instruction(s). Currently, text only.
[JsonPropertyName("systemInstruction")]
public Content? SystemInstruction { get; set; }
Property Value
ToolConfig
Optional. Tool configuration for any Tool specified in the request. Refer to the Function calling guide for a usage example.
[JsonPropertyName("toolConfig")]
public ToolConfig? ToolConfig { get; set; }
Property Value
Tools
Optional. A list of Tools the Model may use to generate the next response.
A Tool is a piece of code that enables the system to interact with external systems
to perform an action, or set of actions, outside of knowledge and scope of the Model.
Supported Tools are Function and codeExecution. Refer to the
Function calling and the
Code execution guides to learn more.
[JsonPropertyName("tools")]
public List<Tool>? Tools { get; set; }