Skip to content
中文

Generate content

POST/google/v1beta/models/{modelsId}:generateContent● Supported

Official Gemini API docs ↗

Request parameters

  • modelstringrequired

    path: Required. The name of the Model to use for generating the completion. Format: models/{model}.

  • contentsarrayrequired◐ Partially supported

    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.

    Multi-turn text, images and tool round trips work, including URL-safe base64 images. Inline audio/wav, text/plain and fileData URLs return 400.

    Expand sub-fields (2)
    • partsarrayoptional

      Ordered Parts that constitute a single message. Parts may have different MIME types.

      Expand sub-fields (16)
      • audioTranscriptionobjectoptional

        Optional. Audio (input or output) transcription. This is only set when this Part contains audio data.

      • codeExecutionResultobjectoptional

        Result of executing the ExecutableCode.

      • executableCodeobjectoptional

        Code generated by the model that is meant to be executed.

      • fileDataobjectoptional○ Unsupported

        URI based data.

        Tested HTTPS, gs, Files API and YouTube URLs all return 400.

      • functionCallobjectoptional

        A predicted FunctionCall returned from the model that contains a string representing the FunctionDeclaration.name with the arguments and their values.

      • functionResponseobjectoptional

        The result output of a FunctionCall that contains a string representing the FunctionDeclaration.name and a structured JSON object containing any output from the function is used as context to the model.

      • inlineDataobjectoptional◐ Partially supported

        Inline media bytes.

        image/png works, including URL-safe base64; audio/wav and text/plain return 400. PDF effects are unobservable.

      • mediaProcessingstringoptional

        Optional. How the model processes this part's media for understanding. Only meaningful for video parts (inline_data or file_data with video mime). Non-video parts ignore this field.

        values AGENTICMEDIA_PROCESSING_UNSPECIFIEDSTATIC
      • mediaResolutionobjectoptional

        Optional. Media resolution for the input media.

      • partMetadataobjectoptional

        Custom metadata associated with the Part. Agents using genai.Part as content representation may need to keep track of the additional information. For example it can be name of a file/source from which the Part originates or a way to multiplex multiple Part streams.

      • textstringoptional

        Inline text.

      • thoughtbooleanoptional

        Optional. Indicates if the part is thought from the model.

      • thoughtSignaturestringoptional

        Optional. An opaque signature for the thought so it can be reused in subsequent requests.

      • toolCallobjectoptional

        Server-side tool call. This field is populated when the model predicts a tool invocation that should be executed on the server. The client is expected to echo this message back to the API.

      • toolResponseobjectoptional

        The output from a server-side ToolCall execution. This field is populated by the client with the results of executing the corresponding ToolCall.

      • videoMetadataobjectoptional

        Optional. Video metadata. The metadata should only be specified while the video data is presented in inline_data or file_data.

    • rolestringoptional

      Optional. The producer of the content. Must be either 'user' or 'model'. Useful to set for multi-turn conversations, otherwise can be left blank or unset.

  • systemInstructionobjectoptional

    Optional. Developer set system instruction(s). Currently, text only.

    Verified to take effect.

    Expand sub-fields (2)
    • partsarrayoptional

      Ordered Parts that constitute a single message. Parts may have different MIME types.

    • rolestringoptional

      Optional. The producer of the content. Must be either 'user' or 'model'. Useful to set for multi-turn conversations, otherwise can be left blank or unset.

  • generationConfigobjectoptional

    Optional. Configuration options for model generation and outputs.

    Expand sub-fields (25)
    • _responseJsonSchemaanyoptional○ Currently ignored

      Optional. Output schema of the generated response. This is an alternative to response_schema that accepts JSON Schema. If set, response_schema must be omitted, but response_mime_type is required. While the full JSON Schema may be sent, not all features are supported. Specifically, only the following properties are supported: - $id - $defs - $ref - $anchor - type - format - title - description - enum (for strings and numbers) - items - prefixItems - minItems - maxItems - minimum - maximum - anyOf - oneOf (interpreted the same as anyOf) - properties - additionalProperties - required The non-standard propertyOrdering property may also be set. Cyclic references are unrolled to a limited degree and, as such, may only be used within non-required properties. (Nullable properties are not sufficient.) If $ref is set on a sub-schema, no other properties, except for than those starting as a $, may be set. Deprecated. Use response_format instead.

      Accepted but currently has no effect. Use responseJsonSchema instead.

    • audioTranscriptionConfigobjectoptional○ Currently ignored

      Optional. Config for audio transcription (speech recognition).

      Accepted but currently has no effect. Tested text models do not apply this option.

    • candidateCountintegeroptional◐ Partially supported

      Optional. Number of generated responses to return. If unset, this will default to 1. Please note that this doesn't work for previous generation models (Gemini 1.0 family)

      Multiple candidates work in non-streaming requests; streaming with 2 returns 400.

    • enableAffectiveDialogbooleanoptional○ Currently ignored

      Optional. If enabled, the model will detect emotions and adapt its responses accordingly.

      Accepted but currently has no effect. Tested text models do not apply this option.

    • enableEnhancedCivicAnswersbooleanoptional○ Unsupported

      Optional. Enables enhanced civic answers. It may not be available for all models.

      Passing this to the tested text models returns 400.

    • frequencyPenaltynumberoptional◐ Partially supported

      Optional. Frequency penalty applied to the next token's logprobs, multiplied by the number of times each token has been seen in the respponse so far. A positive penalty will discourage the use of tokens that have already been used, proportional to the number of times the token has been used: The more a token is used, the more difficult it is for the model to use that token again increasing the vocabulary of responses. Caution: A negative penalty will encourage the model to reuse tokens proportional to the number of times the token has been used. Small negative values will reduce the vocabulary of a response. Larger negative values will cause the model to start repeating a common token until it hits the max_output_tokens limit.

      An occasional effect was observed on gemini-2.5-flash; ignored on gemini-2.5-flash-lite. 2.0 may return 400.

    • imageConfigobjectoptional○ Unsupported

      Optional. Config for image generation. An error will be returned if this field is set for models that don't support these config options.

      Passing this to the tested text models returns 400.

    • logprobsintegeroptional

      Optional. Only valid if response_logprobs=True. This sets the number of top logprobs, including the chosen candidate, to return at each decoding step in the Candidate.logprobs_result. The number must be in the range of [0, 20].

      Verified to take effect.

    • maxOutputTokensintegeroptional◐ Partially supported

      Optional. The maximum number of tokens to include in a response candidate. Note: The default value varies by model, see the Model.output_token_limit attribute of the Model returned from the getModel function.

      Limits output budget including thinking; very small budgets may return only thinking or error, and gemini-3.5-flash may truncate early.

    • mediaResolutionstringoptional

      Optional. If specified, the media resolution specified will be used.

      LOW/MEDIUM/HIGH change image token usage on gemini-2.5-flash.

      values MEDIA_RESOLUTION_HIGHMEDIA_RESOLUTION_LOWMEDIA_RESOLUTION_MEDIUMMEDIA_RESOLUTION_UNSPECIFIED
    • presencePenaltynumberoptional○ Currently ignored

      Optional. Presence penalty applied to the next token's logprobs if the token has already been seen in the response. This penalty is binary on/off and not dependant on the number of times the token is used (after the first). Use frequency_penalty for a penalty that increases with each use. A positive penalty will discourage the use of tokens that have already been used in the response, increasing the vocabulary. A negative penalty will encourage the use of tokens that have already been used in the response, decreasing the vocabulary.

      Accepted but currently has no effect. Outputs did not change on gemini-2.5-flash or gemini-2.5-flash-lite.

    • responseFormatobjectoptional○ Currently ignored

      Optional. Configuration for the response output format. Allows specifying output configuration per modality (text, audio, image) in a flat structure.

      Accepted but currently has no effect. Tested text models do not apply this option.

    • responseJsonSchemaanyoptional◐ Partially supported

      Optional. An internal detail. Use responseJsonSchema rather than this field.

      Works on the 2.5 models; 3.5 may truncate with insufficient budget. Cannot be combined with responseSchema.

    • responseLogprobsbooleanoptional

      Optional. If true, export the logprobs results in response.

      Verified to take effect.

    • responseMimeTypestringoptional◐ Partially supported

      Optional. MIME type of the generated candidate text. Supported MIME types are: text/plain: (default) Text output. application/json: JSON response in the response candidates. text/x.enum: ENUM as a string response in the response candidates. Refer to the docs for a list of all supported text MIME types.

      application/json works on the 2.5 models; 3.5 may return non-JSON. text/x.enum works on flash-lite.

    • responseModalitiesarrayoptional◐ Partially supported

      Optional. The requested modalities of the response. Represents the set of modalities that the model can return, and should be expected in the response. This is an exact match to the modalities of the response. A model may have multiple combinations of supported modalities. If the requested modalities do not match any of the supported combinations, an error will be returned. An empty list is equivalent to requesting only text.

      Tested text models support TEXT; AUDIO returns 400 and IMAGE errors.

    • responseSchemaobjectoptional◐ Partially supported

      Optional. Output schema of the generated candidate text. Schemas must be a subset of the OpenAPI schema and can be objects, primitives or arrays. If set, a compatible response_mime_type must also be set. Compatible MIME types: application/json: Schema for JSON response. Refer to the JSON text generation guide for more details. Deprecated. Use response_format instead.

      JSON constraints work on the 2.5 models; 3.5 may truncate with insufficient budget. Requires the matching responseMimeType.

    • seedintegeroptional◐ Partially supported

      Optional. Seed used in decoding. If not set, the request uses a randomly generated seed.

      Reproducible on gemini-2.5-flash-lite; accepted but currently ignored on gemini-2.5-flash.

    • speechConfigobjectoptional○ Currently ignored

      Optional. The speech generation config.

      Accepted but currently has no effect. Tested text models do not apply this option.

    • stopSequencesarrayoptional

      Optional. The set of character sequences (up to 5) that will stop output generation. If specified, the API will stop at the first appearance of a stop_sequence. The stop sequence will not be included as part of the response.

      Works on gemini-2.5-flash and gemini-2.5-flash-lite; at most five sequences.

    • temperaturenumberoptional◐ Partially supported

      Optional. Controls the randomness of the output. Note: The default value varies by model, see the Model.temperature attribute of the Model returned from the getModel function. Values can range from [0.0, 2.0].

      An effect was observed on gemini-2.5-flash-lite; sampling effects on gemini-2.5-flash are unobservable.

    • thinkingConfigobjectoptional

      Optional. Config for thinking features. An error will be returned if this field is set for models that don't support thinking.

      Expand sub-fields (3)
      • includeThoughtsbooleanoptional◐ Partially supported

        Indicates whether to include thoughts in the response. If true, thoughts are returned only when available.

        true/false controls returned thinking when thinking is enabled. Passing it alone to flash-lite with thinking disabled by default returns 400.

      • thinkingBudgetintegeroptional

        The number of thoughts tokens that the model should generate.

        Zero disables thinking; positive values control the budget and -1 is automatic. Out-of-range values return 400.

      • thinkingLevelstringoptional◐ Partially supported

        Optional. Controls the maximum depth of the model's internal reasoning process before it produces a response. The default value is model-dependent. Refer to the Thinking levels guide for more details. Recommended for Gemini 3 or later models. Use with earlier models results in an error.

        gemini-3.5-flash supports MINIMAL/LOW/MEDIUM/HIGH; using it on the 2.5 models returns 400.

        values HIGHLOWMEDIUMMINIMALTHINKING_LEVEL_UNSPECIFIED
    • topKintegeroptional○ Currently ignored

      Accepted but not effective; sampling does not use topK.

      Accepted but currently has no effect. gemini-2.5-flash-lite still returns different outputs with topK=1; effects on gemini-2.5-flash are unobservable.

    • topPnumberoptional

      Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and Top-p (nucleus) sampling. Tokens are sorted based on their assigned probabilities so that only the most likely tokens are considered. Top-k sampling directly limits the maximum number of tokens to consider, while Nucleus sampling limits the number of tokens based on the cumulative probability. Note: The default value varies by Model and is specified by theModel.top_p attribute returned from the getModel function. An empty top_k attribute indicates that the model doesn't apply top-k sampling and doesn't allow setting top_k on requests.

      Verified on gemini-2.5-flash and gemini-2.5-flash-lite.

    • translationConfigobjectoptional○ Currently ignored

      Optional. Config for translation.

      Accepted but currently has no effect. Tested text models do not apply this option.

  • toolsarrayoptional

    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 code_execution. Refer to the Function calling and the Code execution guides to learn more.

    Expand sub-fields (9)
    • codeExecutionobjectoptional○ Unsupported

      Optional. Enables the model to execute code as part of generation.

      Tested requests return 502; currently unavailable.

    • computerUseobjectoptional○ Unsupported

      Optional. Tool to support the model interacting directly with the computer. If enabled, it automatically populates computer-use specific Function Declarations.

      Tested gemini-2.5-flash requests return 400.

    • fileSearchobjectoptional○ Unsupported

      Optional. FileSearch tool type. Tool to retrieve knowledge from Semantic Retrieval corpora.

      Tested gemini-2.5-flash requests return 400.

    • functionDeclarationsarrayoptional

      Optional. A list of FunctionDeclarations available to the model that can be used for function calling. The model or system does not execute the function. Instead the defined function may be returned as a FunctionCall with arguments to the client side for execution. The model may decide to call a subset of these functions by populating FunctionCall in the response. The next conversation turn may contain a FunctionResponse with the Content.role "function" generation context for the next model turn.

      Expand sub-fields (7)
      • behaviorstringoptional○ Currently ignored

        Optional. Specifies the function Behavior. Currently only supported by the BidiGenerateContent method.

        Accepted but currently has no effect.

        values BLOCKINGNON_BLOCKINGUNSPECIFIED
      • descriptionstringoptional

        Required. A brief description of the function.

      • namestringoptional

        Required. The name of the function. Must be a-z, A-Z, 0-9, or contain underscores, colons, dots, and dashes, with a maximum length of 128.

      • parametersobjectoptional

        Optional. Describes the parameters to this function. Reflects the Open API 3.03 Parameter Object string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter.

        Verified to take effect.

      • parametersJsonSchemaanyoptional

        Optional. Describes the parameters to the function in JSON Schema format. The schema must describe an object where the properties are the parameters to the function. For example: { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer" } }, "additionalProperties": false, "required": ["name", "age"], "propertyOrdering": ["name", "age"] } This field is mutually exclusive with parameters.

        Verified to take effect.

      • responseobjectoptional○ Currently ignored

        Optional. Describes the output from this function in JSON Schema format. Reflects the Open API 3.03 Response Object. The Schema defines the type used for the response value of the function.

        Accepted but currently has no effect.

      • responseJsonSchemaanyoptional

        Optional. Describes the output from this function in JSON Schema format. The value specified by the schema is the response value of the function. This field is mutually exclusive with response.

    • googleMapsobjectoptional

      Optional. Tool that allows grounding the model's response with geospatial context related to the user's query.

    • googleSearchobjectoptional

      Optional. GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google.

      gemini-2.5-flash returns groundingMetadata.

    • googleSearchRetrievalobjectoptional○ Unsupported

      Optional. Retrieval tool that is powered by Google search.

      Tested gemini-2.5-flash requests return 400.

    • mcpServersarrayoptional○ Unsupported

      Optional. MCP Servers to connect to.

      Tested gemini-2.5-flash requests return 400.

    • urlContextobjectoptional

      Optional. Tool to support URL context retrieval.

  • toolConfigobjectoptional

    Optional. Tool configuration for any Tool specified in the request. Refer to the Function calling guide for a usage example.

    Expand sub-fields (3)
    • functionCallingConfigobjectoptional

      Optional. Function calling config.

      Expand sub-fields (2)
      • allowedFunctionNamesarrayoptional

        Optional. A set of function names that, when provided, limits the functions the model will call. This should only be set when the Mode is ANY or VALIDATED. Function names should match [FunctionDeclaration.name]. When set, model will predict a function call from only allowed function names.

        Verified to take effect.

      • modestringoptional◐ Partially supported

        Optional. Specifies the mode in which function calling should execute. If unspecified, the default value will be set to AUTO.

        ANY/AUTO/VALIDATED work; NONE occasionally still called tools on flash-lite, then worked on retest.

        values ANYAUTOMODE_UNSPECIFIEDNONEVALIDATED
    • includeServerSideToolInvocationsbooleanoptional

      Optional. If true, the API response will include the server-side tool calls and responses within the Content message. This allows clients to observe the server's tool interactions.

    • retrievalConfigobjectoptional

      Optional. Retrieval config.

  • safetySettingsarrayoptional

    Accepted but not effective; safety settings never block or alter responses.

    Expand sub-fields (2)
    • categorystringoptional

      Required. The category for this setting.

      values HARM_CATEGORY_CIVIC_INTEGRITYHARM_CATEGORY_DANGEROUSHARM_CATEGORY_DANGEROUS_CONTENTHARM_CATEGORY_DEROGATORYHARM_CATEGORY_HARASSMENTHARM_CATEGORY_HATE_SPEECHHARM_CATEGORY_JAILBREAKHARM_CATEGORY_MEDICALHARM_CATEGORY_SEXUALHARM_CATEGORY_SEXUALLY_EXPLICITHARM_CATEGORY_TOXICITYHARM_CATEGORY_UNSPECIFIEDHARM_CATEGORY_VIOLENCE
    • thresholdstringoptional

      Required. Controls the probability threshold at which harm is blocked.

      values BLOCK_LOW_AND_ABOVEBLOCK_MEDIUM_AND_ABOVEBLOCK_NONEBLOCK_ONLY_HIGHHARM_BLOCK_THRESHOLD_UNSPECIFIEDOFF
  • cachedContentstringoptional○ Unsupported

    Cached content is not supported on this platform; passing it returns a 400 in Google's error format.

    Passing it returns 400; cached-content references are not supported.

  • labelsobjectoptional

    Accepted but not effective; labels are not stored and do not affect request processing.

  • modelstringoptional○ Currently ignored

    Required. The name of the Model to use for generating the completion. Format: models/{model}.

    Accepted but currently has no effect. The model in the URL path takes precedence.

  • More parameters (2)
    • serviceTierstringoptional

      Accepted but not effective; every request is served at the platform's current service tier.

      values flexprioritystandardunspecified
    • storebooleanoptional

      Optional. Configures the logging behavior for a given request. If set, it takes precedence over the project-level logging config.

Returns

200

Forced tool use in toolConfig (functionCallingConfig mode ANY, including allowedFunctionNames) is forwarded unchanged on thinking models too — the same as the native Gemini API, so whether it is accepted is up to the upstream model; if the upstream answers 400, the error keeps the Google format and carries the upstream code and status.

Errors follow the Gemini API format — see error codes

Request

curl
curl https://api.deepraxis.com/google/v1beta/models/gemini-2.5-flash:generateContent \
  -H "x-goog-api-key: $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contents":[{"role":"user","parts":[{"text":"你好"}]}]}'
Python
from google import genai
from google.genai import types

client = genai.Client(
    api_key="$PRAXIS_API_KEY",
    http_options=types.HttpOptions(base_url="https://api.deepraxis.com/google"),
)

resp = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="你好",
)
print(resp.text)
TypeScript
import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({
  apiKey: "$PRAXIS_API_KEY",
  httpOptions: { baseUrl: "https://api.deepraxis.com/google" },
});

const resp = await ai.models.generateContent({
  model: "gemini-2.5-flash",
  contents: "你好",
});
console.log(resp.text);

Response 200

{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "你好!很高兴见到你 😊\n\n有什么我可以帮你的吗?无论是问题解答、写作、翻译、编程,还是只是想聊聊天,我都很乐意陪你一起。"
          }
        ]
      },
      "finishReason": "STOP",
      "index": 0
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 31,
    "candidatesTokenCount": 36,
    "totalTokenCount": 91,
    "thoughtsTokenCount": 24
  },
  "modelVersion": "deepseek-flash",
  "responseId": "a8d2bb98-4025-40a7-aa04-0d441078e43a"
}

Response

HTTP 200

Successful response

application/json

Name Type Description
candidates array<object> Candidate responses from the model.
candidates[].avgLogprobs number Output only. Average log probability score of the candidate.
candidates[].citationMetadata object Output only. Citation information for model-generated candidate. This field may be populated with recitation information for any text included in the content. These are passages that are "recited" from copyrighted material in the foundational LLM's training data.
candidates[].content object Output only. Generated content returned from the model.
candidates[].finishMessage string Optional. Output only. Details the reason why the model stopped generating tokens. This is populated only when finish_reason is set.
candidates[].finishReason string Optional. Output only. The reason why the model stopped generating tokens. If empty, the model has not stopped generating tokens.
candidates[].groundingAttributions array<object> Output only. Attribution information for sources that contributed to a grounded answer. This field is populated for GenerateAnswer calls.
candidates[].groundingMetadata object Output only. Grounding metadata for the candidate. This field is populated for GenerateContent calls.
candidates[].index integer Output only. Index of the candidate in the list of response candidates.
candidates[].logprobsResult object Output only. Log-likelihood scores for the response tokens and top tokens
candidates[].safetyRatings array<object> List of ratings for the safety of a response candidate. There is at most one rating per category.
candidates[].tokenCount integer Output only. Token count for this candidate.
candidates[].urlContextMetadata object Output only. Metadata related to url context retrieval tool.
modelStatus object Output only. The current model status of this model.
modelStatus.message string A message explaining the model status.
modelStatus.modelStage string The stage of the underlying model.
modelStatus.retirementTime string The time at which the model will be retired.
modelVersion string Output only. The model version used to generate the response.
promptFeedback object Returns the prompt's feedback related to the content filters.
promptFeedback.blockReason string Optional. If set, the prompt was blocked and no candidates are returned. Rephrase the prompt.
promptFeedback.safetyRatings array<object> Ratings for safety of the prompt. There is at most one rating per category.
responseId string Output only. response_id is used to identify each response.
usageMetadata object Output only. Metadata on the generation requests' token usage.
usageMetadata.cacheTokensDetails array<object> Output only. List of modalities of the cached content in the request input.
usageMetadata.cachedContentTokenCount integer Number of tokens in the cached part of the prompt (the cached content)
usageMetadata.candidatesTokenCount integer Total number of tokens across all the generated response candidates.
usageMetadata.candidatesTokensDetails array<object> Output only. List of modalities that were returned in the response.
usageMetadata.promptTokenCount integer Number of tokens in the prompt. When cached_content is set, this is still the total effective prompt size meaning this includes the number of tokens in the cached content.
usageMetadata.promptTokensDetails array<object> Output only. List of modalities that were processed in the request input.
usageMetadata.serviceTier string Output only. Service tier of the request.
usageMetadata.thoughtsTokenCount integer Output only. Number of tokens of thoughts for thinking models.
usageMetadata.toolUsePromptTokenCount integer Output only. Number of tokens present in tool-use prompt(s).
usageMetadata.toolUsePromptTokensDetails array<object> Output only. List of modalities that were processed for tool-use request inputs.
usageMetadata.totalTokenCount integer Total token count for the generation request (prompt + thoughts + response candidates).