{"id":23214,"date":"2025-11-18T14:08:49","date_gmt":"2025-11-18T14:08:49","guid":{"rendered":"https:\/\/docs.dataforseo.com\/v3\/?page_id=23214"},"modified":"2026-04-01T14:51:06","modified_gmt":"2026-04-01T14:51:06","slug":"ai_optimization-gemini-llm_responses-task_post","status":"publish","type":"page","link":"https:\/\/docs.dataforseo.com\/v3\/ai_optimization-gemini-llm_responses-task_post\/","title":{"rendered":"ai_optimization\/gemini\/llm_responses\/task_post"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><p>[vc_row][vc_column][vc_column_text]<\/p>\n<h2 id=\"setting-serp-tasks\">Setting Gemini LLM Responses Tasks<\/h2>\n<p>\u200c<br \/>\nGemini LLM Responses endpoint allows you to retrieve structured responses from a specific Gemini model, based on the input parameters.<\/p>\n<p>This is the Standard method of data retrieval. If you don\u2019t need to receive data in real-time, this method is the best option for you. Set a task and retrieve the results when our system collects them. Execution time depends on the system workload.<\/p>\n<p>If your system requires delivering instant results, <a href=\"https:\/\/docs.dataforseo.com\/v3\/ai_optimization\/gemini\/llm_responses\/live\/\">the Live method<\/a> will be a better solution. This method doesn\u2019t require making separate POST and GET requests to the corresponding endpoints.<\/p>\n<p>Note that this endpoint requires making an automatic prepayment of $0.01 to execute the task. If the cost charged by the LLM is less than $0.01, the difference will be refunded to your account balance.<\/p>\n<p>[\/vc_column_text]    <div class=\"endpoint\">\n        <img decoding=\"async\" class=\"endpoint__icon\" src=\"https:\/\/docs.dataforseo.com\/v3\/wp-content\/themes\/dataforseo\/assets\/img\/icons\/checked-circle.svg\" alt=\"checked\">\n\n                    POST            <button class=\"btn-reset button-link copy-button\" data-href=\"https:\/\/api.dataforseo.com\/v3\/ai_optimization\/gemini\/llm_responses\/task_post\">\n                https:\/\/api.dataforseo.com\/v3\/ai_optimization\/gemini\/llm_responses\/task_post                <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\">\n                    <use href=\"https:\/\/docs.dataforseo.com\/v3\/wp-content\/themes\/dataforseo\/assets\/img\/icons\/sprite.svg#layers\"><\/use>\n                <\/svg>\n            <\/button>\n            <\/div>\n    \t<article class=\"info-card info-card--yellow\">\n\t\t<header class=\"info-card__header\">\n\t\t\t<div class=\"info-card__icon\">\n\t\t\t\t<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\">\n\t\t\t\t\t<use href=\"https:\/\/docs.dataforseo.com\/v3\/wp-content\/themes\/dataforseo\/assets\/img\/icons\/sprite.svg#label\"><\/use>\n\t\t\t\t<\/svg>\n\t\t\t<\/div>\n\t\t\t<div class=\"info-card__title\">Pricing<\/div>\n\t\t<\/header>\n\t\t<div class=\"info-card__content\">\n\t\t\t<p> Your account will be charged only for setting a task.<br \/>\nThe cost can be calculated on the <a title=\"Pricing\" href=\"https:\/\/dataforseo.com\/pricing\/ai-optimization\/llm-responses\" target=\"_blank\" rel=\"noopener noreferrer\">Pricing<\/a> page.<\/p>\n\t\t<\/div>\n\t<\/article>\n\t[vc_column_text]All POST data should be sent in the <a href=\"https:\/\/en.wikipedia.org\/wiki\/JSON\">JSON<\/a> format (UTF-8 encoding). Task setting is done using the POST method. When setting a task, you should send all task parameters in the task array of the generic POST array. You can send up to 2000 API calls per minute, with each POST call containing no more than 100 tasks. If your POST call contains over 100 tasks, the tasks over this limit will return the <code>40006<\/code> error. <\/p>\n<p>Tasks using the Standard method <strong>may take up to 72 hours to complete<\/strong>. If the task is not completed within this time, it is marked as failed, and the $0.01 advance is refunded. It is also important to note that if your account balance is negative, you will not receive the results even if the task is completed successfully.<\/p>\n<p>You can also retrieve the results of completed tasks using the unique task identifier <code>id<\/code>. Alternatively, we can send them to you as soon as they are ready if you specify the <code>postback_url<\/code>\u00a0or\u00a0<code>pingback_url<\/code> when setting a task. Note that if your server doesn&#8217;t respond within 10 seconds, the connection will be aborted by timeout, and the task will be transferred to the <a href=\"https:\/\/docs.dataforseo.com\/v3\/keywords_data\/google_ads\/search_volume\/tasks_ready\/?php\" target=\"_blank\" rel=\"noopener noreferrer\">tasks_ready<\/a> list. The error code and message depend on your server&#8217;s configuration.<\/p>\n<p>See <a href=\"https:\/\/dataforseo.com\/help-center\/pingbacks-postbacks-with-dataforseo-api\" target=\"_blank\" rel=\"noopener noreferrer\">Help Center<\/a> to learn more about using pingbacks and postbacks with DataForSEO APIs.<\/p>\n<p>Below you will find a detailed description of the fields you can use for setting a task.<\/p>\n<p><strong>Description of the fields for setting a task:<\/strong><\/p>\n<div class=\"dfs-doc-container dfs-doc-request\"><table><thead><tr><th>Field name<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr data-doc-id=\"user_prompt\"><td><code>user_prompt<\/code><\/td><td>string<\/td><td><p><em>prompt for the AI model<\/em><br><strong>required field<\/strong><br>the question or task you want to send to the AI model;<br>you can specify <strong>up to 500 characters<\/strong> in the <code>user_prompt<\/code> field<\/p><\/td><\/tr><tr data-doc-id=\"model_name\"><td><code>model_name<\/code><\/td><td>string<\/td><td><p><em>name of the AI model<\/em><br><strong>required field<\/strong><br><code>model_name<\/code >consists of the actual model name and version name;<br>if the basic model name is specified, its latest version will be set by default;<br>for example, if <code>gemini-1.5-pro<\/code> is specified, the <code>gemini-1.5-pro-002<\/code> will be set as <code>model_name<\/code> automatically;<br>you can receive the list of available LLM models by making a separate request to the <code><a href=\"https:\/\/api.dataforseo.com\/v3\/ai_optimization\/gemini\/llm_responses\/models\">https:\/\/api.dataforseo.com\/v3\/ai_optimization\/gemini\/llm_responses\/models<\/a><\/code><\/p><\/td><\/tr><tr data-doc-id=\"max_output_tokens\"><td><code>max_output_tokens<\/code><\/td><td>integer<\/td><td><p><em>maximum number of tokens in the AI response<\/em><br>optional field<br>minimum value: <code>1<\/code>;<br>maximum value: <code>4096<\/code>;<br>default value: <code>2048<\/code>;<br><strong>Note:<\/strong> if <code>web_search<\/code> is set to <code>true<\/code> or the reasoning model is specified in the request, the output token count may exceed the specified <code>max_output_tokens<\/code> limit<br><strong>Note #2:<\/strong> if <code>use_reasoning<\/code> is set to <code>true<\/code>, the minimum value for <code>max_output_tokens<\/code> is <code>1024<\/code><\/p><\/td><\/tr><tr data-doc-id=\"temperature\"><td><code>temperature<\/code><\/td><td>float<\/td><td><p><em>randomness of the AI response<\/em><br>optional field<br>higher values make output more diverse <br>lower values make output more focused<br>minimum value: <code>0<\/code><br>maximum value: <code>2<\/code><br>default value: <code>1.3<\/code><\/p><\/td><\/tr><tr data-doc-id=\"top_p\"><td><code>top_p<\/code><\/td><td>float<\/td><td><p><em>diversity of the AI response<\/em><br>optional field <br>controls diversity of the response by limiting token selection<br>minimum value: <code>0<\/code><br>maximum value: <code>1<\/code> <br>default value: <code>0.9<\/code><\/p><\/td><\/tr><tr data-doc-id=\"web_search\"><td><code>web_search<\/code><\/td><td>boolean<\/td><td><p><em>enable web search for current information<\/em><br>optional field<br>when enabled, the AI model can access and cite current web information;<br><strong>Note:<\/strong> refer to the <a href=\"https:\/\/docs.dataforseo.com\/v3\/ai_optimization\/gemini\/llm_responses\/models\/\">Models endpoint<\/a> for a list of models that support <code>web_search<\/code>; <br>default value: <code>false<\/code>;<br>The cost of the parameter can be calculated on the <a title=\"Gemini API Pricing\" href=\"https:\/\/ai.google.dev\/gemini-api\/docs\/pricing\" target=\"_blank\" rel=\"noopener noreferrer\">Pricing<\/a> page<\/p><\/td><\/tr><tr data-doc-id=\"system_message\"><td><code>system_message<\/code><\/td><td>string<\/td><td><p><em>instructions for the AI behavior<\/em><br>optional field<br>defines the AI's role, tone, or specific behavior <br>you can specify <strong>up to 500 characters<\/strong> in the <code>system_message<\/code> field<\/p><\/td><\/tr><tr data-doc-id=\"message_chain\"><td><code>message_chain<\/code><\/td><td>array<\/td><td><p><em>conversation history<\/em><br>optional field<br>array of message objects representing previous conversation turns;<br>each object must contain <code>role<\/code> and <code>message<\/code> parameters:<br><code>role<\/code> string with either <code>user<\/code> or <code>ai<\/code> role;<br><code>message<\/code> string with message content (max 500 characters);<br>you can specify <strong> the maximum of 10 message objects<\/strong> in the array;<br>example:<br><code>\"message_chain\": [{\"role\":\"user\",\"message\":\"Hello, what\u2019s up?\"},{\"role\":\"ai\",\"message\":\"Hello! I\u2019m doing well, thank you. How can I assist you today?\"}]<\/code><\/p><\/td><\/tr><tr data-doc-id=\"use_reasoning\"><td><code>use_reasoning<\/code><\/td><td>boolean<\/td><td><p><em>enable reasoning for the AI model<\/em><br>optional field<br>when enabled, the model will perform reasoning before generating a response<br>refer to the <a href=\"https:\/\/docs.dataforseo.com\/v3\/ai_optimization\/gemini\/llm_responses\/models\/\" target=\"_blank\">Models endpoint<\/a> for a list of models that support <code>reasoning<\/code><br>default value: <code>false<\/code><br><strong>Note:<\/strong> if set to <code>true<\/code>, the minimum value for <code>max_output_tokens<\/code> is <code>1024<\/code><br><strong>Note #2:<\/strong> for Gemini Pro models, the <code>use_reasoning<\/code> will automatically be set to <code>true<\/code><\/p><\/td><\/tr><tr data-doc-id=\"tag\"><td><code>tag<\/code><\/td><td>string<\/td><td><p><em>user-defined task identifier<\/em><br>optional field<br><em>the character limit is 255<\/em><br>you can use this parameter to identify the task and match it with the result<br>you will find the specified <code>tag<\/code> value in the <code>data<\/code> object of the response<\/p><\/td><\/tr><tr data-doc-id=\"postback_url\"><td><code>postback_url<\/code><\/td><td>string<\/td><td><p><em>URL for sending task results<\/em><br>optional field<br>once the task is completed, we will send a POST request with its results compressed in the <code>gzip<\/code> format to the <code>postback_url<\/code> you specified<br>you can use the \u2018$id\u2019 string as a <code>$id<\/code> variable and \u2018$tag\u2019 as urlencoded <code>$tag<\/code> variable. We will set the necessary values before sending the request.<br>example:<br><code><a href=\"http:\/\/your-server.com\/postbackscript?id=$id\">http:\/\/your-server.com\/postbackscript?id=$id<\/a><\/code><br><code><a href=\"http:\/\/your-server.com\/postbackscript?id=$id&amp;tag=$tag\">http:\/\/your-server.com\/postbackscript?id=$id&amp;tag=$tag<\/a><\/code><br><strong>Note:<\/strong> special character in <code>postback_url<\/code> will be urlencoded;<br>i.a., the <code>#<\/code> character will be encoded into <code>%23<\/code><p>learn more on our <a href=\"https:\/\/dataforseo.com\/help-center\/pingbacks-postbacks-with-dataforseo-api\" target=\"_blank\" rel=\"noopener noreferrer\">Help Center<\/a><\/p><\/td><\/tr><tr data-doc-id=\"pingback_url\"><td><code>pingback_url<\/code><\/td><td>string<\/td><td><p><em>notification URL of a completed task<\/em><br>optional field<br>when a task is completed we will notify you by GET request sent to the URL you have specified<br>you can use the \u2018$id\u2019 string as a <code>$id<\/code> variable and \u2018$tag\u2019 as urlencoded <code>$tag<\/code> variable. We will set the necessary values before sending the request<br>example:<br><code><a href=\"http:\/\/your-server.com\/pingscript?id=$id\">http:\/\/your-server.com\/pingscript?id=$id<\/a><\/code><br><code><a href=\"http:\/\/your-server.com\/pingscript?id=$id&amp;tag=$tag\">http:\/\/your-server.com\/pingscript?id=$id&amp;tag=$tag<\/a><\/code><br><strong>Note:<\/strong> special character in <code>pingback_url<\/code> will be urlencoded;<br>i.a., the <code>#<\/code> character will be encoded into <code>%23<\/code><p>learn more on our <a href=\"https:\/\/dataforseo.com\/help-center\/pingbacks-postbacks-with-dataforseo-api\" target=\"_blank\" rel=\"noopener noreferrer\">Help Center<\/a><\/p><\/td><\/tr><\/tbody><\/table><\/div><br \/>\n\u200c<\/p>\n<p>As a response of the API server, you will receive <a href=\"https:\/\/en.wikipedia.org\/wiki\/JSON\">JSON<\/a>-encoded data containing a <code>tasks<\/code> array with the information specific to the set tasks.<\/p>\n<p><strong>Description of the fields in the results array:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<table style=\"width: 77.3646%; height: 552px;\">\n<thead>\n<tr style=\"height: 24px;\">\n<th style=\"width: 38.423%; height: 24px;\">Field name<\/th>\n<th style=\"width: 1.25156%; height: 24px;\">Type<\/th>\n<th style=\"width: 61.7021%; height: 24px;\">Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"height: 48px;\">\n<td style=\"width: 24.3517%; height: 48px;\"><code>version<\/code><\/td>\n<td style=\"width: 6.19209%; height: 48px;\">string<\/td>\n<td style=\"width: 79.8065%; height: 48px;\"><em>the current version of the API<\/em><\/td>\n<\/tr>\n<tr style=\"height: 48px;\">\n<td style=\"width: 38.423%; height: 48px;\"><code>status_code<\/code><\/td>\n<td style=\"width: 1.75219%; height: 48px;\">integer<\/td>\n<td style=\"width: 61.2015%; height: 48px;\"><i>general status code<\/i><br \/>\nyou can find the full list of the response codes <a href=\"\/v3\/appendix\/errors\">here<\/a><br \/>\n<strong>Note:<\/strong> we strongly recommend designing a necessary system for handling related exceptional or error conditions<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\"><code>status_message<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">string<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>general informational message<\/em><br \/>\nyou can find the full list of general informational messages <a href=\"\/v3\/appendix\/errors\">here<\/a><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 38.423%; height: 24px;\"><code>time<\/code><\/td>\n<td style=\"width: 1.25156%; height: 24px;\">string<\/td>\n<td style=\"width: 61.7021%; height: 24px;\"><em>execution time, seconds<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 38.423%; height: 24px;\"><code>cost<\/code><\/td>\n<td style=\"width: 1.25156%; height: 24px;\">float<\/td>\n<td style=\"width: 61.7021%; height: 24px;\"><em>total tasks cost, USD<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 38.423%; height: 24px;\"><code>tasks_count<\/code><\/td>\n<td style=\"width: 1.25156%; height: 24px;\">integer<\/td>\n<td style=\"width: 61.7021%; height: 24px;\"><em>the number of tasks in the <strong><code>tasks<\/code><\/strong>array<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 38.423%; height: 24px;\"><code>tasks_error<\/code><\/td>\n<td style=\"width: 1.25156%; height: 24px;\">integer<\/td>\n<td style=\"width: 61.7021%; height: 24px;\"><em>the number of tasks in the <strong><code>tasks<\/code><\/strong> array returned with an error<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 38.423%; height: 24px;\"><strong><code>tasks<\/code><\/strong><\/td>\n<td style=\"width: 1.25156%; height: 24px;\">array<\/td>\n<td style=\"width: 61.7021%; height: 24px;\"><em>array of tasks<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 38.423%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 <code>id<\/code><\/td>\n<td style=\"width: 1.25156%; height: 24px;\">string<\/td>\n<td style=\"width: 61.7021%; height: 24px;\"><em>unique task identifier in our system<\/em><br \/>\n<strong>unique task identifier in the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Universally_unique_identifier\">UUID<\/a> format<\/strong><\/td>\n<\/tr>\n<tr style=\"height: 48px;\">\n<td style=\"width: 38.423%; height: 48px;\">\u00a0 \u00a0 \u00a0 \u00a0 <code>status_code<\/code><\/td>\n<td style=\"width: 1.25156%; height: 48px;\">integer<\/td>\n<td style=\"width: 61.7021%; height: 48px;\"><em>status code of the task <\/em><br \/>\ngenerated by DataForSEO; can be within the following range: 10000-60000<br \/>\nyou can find the full list of response codes <a href=\"\/v3\/appendix-errors\/\">here<\/a><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 38.423%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 <code>status_message<\/code><\/td>\n<td style=\"width: 1.25156%; height: 24px;\">string<\/td>\n<td style=\"width: 61.7021%; height: 24px;\"><em>informational message of the task<\/em><br \/>\nyou can find the full list of general informational messages <a href=\"\/v3\/appendix-errors\/\">here<\/a><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 38.423%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 <code>time<\/code><\/td>\n<td style=\"width: 1.25156%; height: 24px;\">string<\/td>\n<td style=\"width: 61.7021%; height: 24px;\"><em>execution time, seconds<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 38.423%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 <code>cost<\/code><\/td>\n<td style=\"width: 1.25156%; height: 24px;\">float<\/td>\n<td style=\"width: 61.7021%; height: 24px;\"><em>cost of the task, USD<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 38.423%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 <code>result_count<\/code><\/td>\n<td style=\"width: 1.25156%; height: 24px;\">integer<\/td>\n<td style=\"width: 61.7021%; height: 24px;\"><em>number of elements in the <code>result<\/code> array<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 38.423%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 <code>path<\/code><\/td>\n<td style=\"width: 1.25156%; height: 24px;\">array<\/td>\n<td style=\"width: 61.7021%; height: 24px;\"><em>URL path<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 38.423%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 <code>data<\/code><\/td>\n<td style=\"width: 1.25156%; height: 24px;\">object<\/td>\n<td style=\"width: 61.7021%; height: 24px;\"><em>contains the same parameters that you specified in the POST request<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 38.423%; height: 24px;\">\u00a0 \u00a0 <strong>\u00a0 \u00a0 <code>result<\/code><\/strong><\/td>\n<td style=\"width: 1.25156%; height: 24px;\">array<\/td>\n<td style=\"width: 61.7021%; height: 24px;\"><em>array of results<\/em><br \/>\nin this case, the value will be <code>null<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u200c\u200c[\/vc_column_text][\/vc_column][\/vc_row]<\/p>\n<blockquote><p>Instead of \u2018login\u2019 and \u2018password\u2019 use your credentials from https:\/\/app.dataforseo.com\/api-access<\/p><\/blockquote><div id=\"curl\" class=\"tab-content example__content\"><div class=\"example__code\"><pre><code class=\"language-bash hljs\"># Instead of &#039;login&#039; and &#039;password&#039; use your credentials from https:\/\/app.dataforseo.com\/api-access \r\nlogin=&quot;login&quot; \r\npassword=&quot;password&quot; \r\ncred=&quot;$(printf ${login}:${password} | base64)&quot; \r\ncurl --location --request POST &quot;https:\/\/api.dataforseo.com\/v3\/ai_optimization\/gemini\/llm_responses\/task_post&quot; \r\n--header &quot;Authorization: Basic ${cred}&quot;  \r\n--header &quot;Content-Type: application\/json&quot; \r\n--data-raw &#039;[\r\n  {\r\n    &quot;system_message&quot;: &quot;communicate as if we are in a business meeting&quot;,\r\n    &quot;message_chain&quot;: [\r\n      {\r\n        &quot;role&quot;: &quot;user&quot;,\r\n        &quot;message&quot;: &quot;Hello, what\u2019s up?&quot;\r\n      },\r\n      {\r\n        &quot;role&quot;: &quot;ai&quot;,\r\n        &quot;message&quot;: &quot;Hello! I\u2019m doing well, thank you. How can I assist you today? Are there any specific topics or projects you\u2019d like to discuss in our meeting?&quot;\r\n      }\r\n    ],\r\n    &quot;model_name&quot;: &quot;gemini-2.5-flash&quot;,\r\n    &quot;user_prompt&quot;: &quot;provide information on how relevant the amusement park business is in France now&quot;\r\n  }\r\n]&#039;<\/code><\/pre><\/div><\/div><div id=\"php\" class=\"tab-content example__content\"><div class=\"example__code\"><pre><code class=\"language-php hljs\">&lt;?php\r\n\r\n\/**\r\n * Method: POST\r\n * Endpoint: https:\/\/api.dataforseo.com\/v3\/ai_optimization\/gemini\/llm_responses\/task_post\r\n * @see https:\/\/docs.dataforseo.com\/v3\/ai_optimization\/gemini\/llm_responses\/task_post\r\n *\/\r\n\r\nrequire_once __DIR__ . &#039;\/..\/..\/..\/..\/..\/lib\/RestClient.php&#039;;\r\n$config = require __DIR__ . &#039;\/..\/..\/..\/..\/..\/lib\/config.php&#039;;\r\n\r\n$client = new RestClient($config[&#039;base_url&#039;], null, $config[&#039;login&#039;], $config[&#039;password&#039;]);\r\n\r\n$data = [\r\n    [\r\n        &#039;system_message&#039; =&gt; &#039;communicate as if we are in a business meeting&#039;,\r\n        &#039;message_chain&#039; =&gt; [\r\n            [\r\n                &#039;role&#039; =&gt;&#039;user&#039;,\r\n                &#039;message&#039; =&gt; &#039;Hello, what&#039;s up?&#039;,\r\n            ],\r\n            [\r\n                &#039;role&#039; =&gt; &#039;ai&#039;,\r\n                &#039;message&#039; =&gt;; &#039;Hello! I\u2019m doing well, thank you. How can I assist you today? Are there any specific topics or projects you\u2019d like to discuss in our meeting?&#039;,\r\n            ],\r\n        ],\r\n        &#039;model_name&#039; =&gt; &#039;gemini-2.5-flash&#039;,\r\n        &#039;user_prompt&#039; =&gt; &#039;provide information on how relevant the amusement park business is in France now&#039;,\r\n    ],\r\n];\r\ntry {\r\n    $result = $client-&gt;post(&#039;\/v3\/ai_optimization\/gemini\/llm_responses\/task_post&#039;, $data);\r\n    print_r($result);\r\n    \/\/ do something with post result\r\n} catch (RestClientException $e) {\r\n    printf(\r\n        &quot;HTTP code: %dnError code: %dnMessage: %snTrace: %sn&quot;,\r\n        $e-&gt;getHttpCode(),\r\n        $e-&gt;getCode(),\r\n        $e-&gt;getMessage(),\r\n        $e-&gt;getTraceAsString()\r\n    );\r\n}\r\n?&gt;<\/code><\/pre><\/div><\/div><div id=\"javascript\" class=\"tab-content example__content\"><div class=\"example__code\"><pre><code class=\"language-javascript hljs\">const post_array = [];\r\n\r\npost_array.push({\r\n  &quot;system_message&quot;: &quot;communicate as if we are in a business meeting&quot;,\r\n    &quot;message_chain&quot;: [\r\n      {\r\n        &quot;role&quot;: &quot;user&quot;,\r\n        &quot;message&quot;: &quot;Hello, what\u2019s up?&quot;\r\n      },\r\n      {\r\n        &quot;role&quot;: &quot;ai&quot;,\r\n        &quot;message&quot;: &quot;Hello! I\u2019m doing well, thank you. How can I assist you today? Are there any specific topics or projects you\u2019d like to discuss in our meeting?&quot;\r\n      }\r\n    ],\r\n    &quot;model_name&quot;: &quot;gemini-2.5-flash&quot;,\r\n    &quot;user_prompt&quot;: &quot;provide information on how relevant the amusement park business is in France now&quot;\r\n});\r\n\r\nconst axios = require(&#039;axios&#039;);\r\n\r\naxios({\r\n  method: &#039;post&#039;,\r\n  url: &#039;https:\/\/api.dataforseo.com\/v3\/ai_optimization\/gemini\/llm_responses\/task_post&#039;,\r\n  auth: {\r\n    username: &#039;login&#039;,\r\n    password: &#039;password&#039;\r\n  },\r\n  data: post_array,\r\n  headers: {\r\n    &#039;content-type&#039;: &#039;application\/json&#039;\r\n  }\r\n}).then(function (response) {\r\n  var result = response[&#039;data&#039;][&#039;tasks&#039;];\r\n  \/\/ Result data\r\n  console.log(result);\r\n}).catch(function (error) {\r\n  console.log(error);\r\n});<\/code><\/pre><\/div><\/div><div id=\"python\" class=\"tab-content example__content\"><div class=\"example__code\"><pre><code class=\"language-python hljs\">&quot;&quot;&quot;\r\nMethod: POST\r\nEndpoint: https:\/\/api.dataforseo.com\/v3\/ai_optimization\/gemini\/llm_responses\/task_post\r\n@see https:\/\/docs.dataforseo.com\/v3\/ai_optimization\/gemini\/llm_responses\/task_post\r\n&quot;&quot;&quot;\r\n\r\nimport sys\r\nimport os\r\nsys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), &#039;..\/..\/..\/..\/..\/&#039;)))\r\nfrom lib.client import RestClient\r\nfrom lib.config import username, password\r\nclient = RestClient(username, password)\r\n\r\npost_data = []\r\npost_data.append({\r\n        &#039;system_message&#039;: &#039;communicate as if we are in a business meeting&#039;,\r\n        &#039;message_chain&#039;: [\r\n            {\r\n                &#039;role&#039;: &#039;user&#039;,\r\n                &#039;message&#039;: &#039;Hello, what&#039;s up?&#039;\r\n            },\r\n            {\r\n                &#039;role&#039;: &#039;ai&#039;,\r\n                &#039;message&#039;: &#039;Hello! I\u2019m doing well, thank you. How can I assist you today? Are there any specific topics or projects you\u2019d like to discuss in our meeting?&#039;\r\n            }\r\n        ],\r\n        &#039;model_name&#039;: &#039;gemini-2.5-flash&#039;,\r\n        &#039;user_prompt&#039;: &#039;provide information on how relevant the amusement park business is in France now&#039;\r\n    })\r\ntry:\r\n    response = client.post(&#039;\/v3\/ai_optimization\/gemini\/llm_responses\/task_post&#039;, post_data)\r\n    print(response)\r\n    # do something with post result\r\nexcept Exception as e:\r\n    print(f&#039;An error occurred: {e}&#039;)<\/code><\/pre><\/div><\/div><div id=\"csharp\" class=\"tab-content example__content\"><div class=\"example__code\"><pre><code class=\"language-csharp hljs\">using System;\r\nusing System.Linq;\r\nusing System.Net.Http;\r\nusing System.Net.Http.Headers;\r\nusing System.Text;\r\nusing System.Collections.Generic;\r\nusing System.Threading.Tasks;\r\nusing Newtonsoft.Json;\r\nnamespace DataForSeoSdk;\r\n\r\npublic class AiOptimization\r\n{\r\n\r\n    private static readonly HttpClient _httpClient;\r\n    \r\n    static AiOptimization()\r\n    {\r\n        _httpClient = new HttpClient\r\n        {\r\n            BaseAddress = new Uri(&quot;https:\/\/api.dataforseo.com\/&quot;)\r\n        };\r\n        _httpClient.DefaultRequestHeaders.Authorization =\r\n            new AuthenticationHeaderValue(&quot;Basic&quot;, ApiConfig.Base64Auth);\r\n    }\r\n    \/\/\/ &lt;summary&gt;\r\n    \/\/\/ Method: POST\r\n    \/\/\/ Endpoint: https:\/\/api.dataforseo.com\/v3\/ai_optimization\/gemini\/llm_responses\/task_post\r\n    \/\/\/ &lt;\/summary&gt;\r\n    \/\/\/ &lt;see href=&quot;https:\/\/docs.dataforseo.com\/v3\/ai_optimization\/gemini\/llm_responses\/task_post&quot;\/&gt;\r\n    \r\n    public static async Task GeminiLlmResponsesTaskPost()\r\n    {\r\n        var postData = new List&lt;object&gt;();\r\n        \/\/ a simple way to set a task, the full list of possible parameters is available in documentation\r\n        postData.Add(new\r\n        {\r\n            system_message = &quot;communicate as if we are in a business meeting&quot;,\r\n            message_chain = new object[]\r\n            {\r\n                new\r\n                {\r\n                    role = &quot;user&quot;,\r\n                    message = &quot;Hello, what&#039;s up?&quot;\r\n                },\r\n                new\r\n                {\r\n                    role = &quot;ai&quot;,\r\n                    message = &quot;Hello! I\u2019m doing well, thank you. How can I assist you today? Are there any specific topics or projects you\u2019d like to discuss in our meeting?&quot;\r\n                }\r\n            },\r\n            max_output_tokens = 1024,\r\n            temperature = 0.3,\r\n            top_p = 0.5,\r\n            model_name = &quot;gemini-2.5-flash&quot;,\r\n            user_prompt = &quot;provide information on how relevant the amusement park business is in France now&quot;\r\n        });\r\n\r\n        var content = new StringContent(JsonConvert.SerializeObject(postData), Encoding.UTF8, &quot;application\/json&quot;);\r\n        using var response = await _httpClient.PostAsync(&quot;\/v3\/ai_optimization\/gemini\/llm_responses\/task_post&quot;, content);\r\n        var result = JsonConvert.DeserializeObject&lt;dynamic&gt;(await response.Content.ReadAsStringAsync());\r\n        \/\/ you can find the full list of the response codes here https:\/\/docs.dataforseo.com\/v3\/appendix\/errors\r\n        if (result.status_code == 20000)\r\n        {\r\n            \/\/ do something with result\r\n            Console.WriteLine(result);\r\n        }\r\n        else\r\n            Console.WriteLine($&quot;error. Code: {result.status_code} Message: {result.status_message}&quot;);\r\n    }<\/code><\/pre><\/div><\/div><blockquote><p>The above command returns JSON structured like this:<\/p><\/blockquote><div class=\"example example--json\"><div class=\"example__content\"><div class=\"example__code example__code-json\"><pre><code class=\"language-json hljs\">{\r\n  &quot;version&quot;: &quot;0.1.20250526&quot;,\r\n  &quot;status_code&quot;: 20000,\r\n  &quot;status_message&quot;: &quot;Ok.&quot;,\r\n  &quot;time&quot;: &quot;0.1071 sec.&quot;,\r\n  &quot;cost&quot;: 0.0102,\r\n  &quot;tasks_count&quot;: 1,\r\n  &quot;tasks_error&quot;: 0,\r\n  &quot;tasks&quot;: [\r\n    {\r\n      &quot;id&quot;: &quot;07151610-0696-0613-0000-b2366402ce99&quot;,\r\n      &quot;status_code&quot;: 20100,\r\n      &quot;status_message&quot;: &quot;Task Created.&quot;,\r\n      &quot;time&quot;: &quot;0.0146 sec.&quot;,\r\n      &quot;cost&quot;: 0.0102,\r\n      &quot;result_count&quot;: 0,\r\n      &quot;path&quot;: [\r\n        &quot;v3&quot;,\r\n        &quot;ai_optimization&quot;,\r\n        &quot;gemini&quot;,\r\n        &quot;llm_responses&quot;,\r\n        &quot;task_post&quot;\r\n      ],\r\n      &quot;data&quot;: {\r\n        &quot;api&quot;: &quot;ai_optimization&quot;,\r\n        &quot;function&quot;: &quot;llm_responses&quot;,\r\n        &quot;se&quot;: &quot;gemini&quot;,\r\n        &quot;system_message&quot;: &quot;communicate as if we are in a business meeting&quot;,\r\n        &quot;message_chain&quot;: [\r\n          {\r\n            &quot;role&quot;: &quot;user&quot;,\r\n            &quot;message&quot;: &quot;Hello, what&#039;s up?&quot;\r\n          },\r\n          {\r\n            &quot;role&quot;: &quot;ai&quot;,\r\n            &quot;message&quot;: &quot;Hello! I\u2019m doing well, thank you. How can I assist you today? Are there any specific topics or projects you\u2019d like to discuss in our meeting?&quot;\r\n          }\r\n        ],\r\n        &quot;model_name&quot;: &quot;gemini-2.5-flash&quot;,\r\n        &quot;user_prompt&quot;: &quot;provide information on how relevant the amusement park business is in France now&quot;\r\n      },\r\n      &quot;result&quot;: null\r\n    }\r\n  ]\r\n}<\/code><\/pre><\/div><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>[vc_row][vc_column][vc_column_text] Setting Gemini LLM Responses Tasks \u200c Gemini LLM Responses endpoint allows you to retrieve structured responses from a specific Gemini model, based on the input parameters. This is the Standard method of data retrieval. If you don\u2019t need to receive data in real-time, this method is the best option for you. Set a task [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"template.php","meta":{"apibase_doc_request_yaml":"parameters:\n  - name: user_prompt\n    type: string\n    description: |\n      <em>prompt for the AI model<\/em><br><strong>required field<\/strong><br>the question or task you want to send to the AI model;<br>you can specify <strong>up to 500 characters<\/strong> in the <code>user_prompt<\/code> field\n  - name: model_name\n    type: string\n    description: |\n      <em>name of the AI model<\/em><br><strong>required field<\/strong><br><code>model_name<\/code >consists of the actual model name and version name;<br>if the basic model name is specified, its latest version will be set by default;<br>for example, if <code>gemini-1.5-pro<\/code> is specified, the <code>gemini-1.5-pro-002<\/code> will be set as <code>model_name<\/code> automatically;<br>you can receive the list of available LLM models by making a separate request to the <code>https:\/\/api.dataforseo.com\/v3\/ai_optimization\/gemini\/llm_responses\/models<\/code>\n  - name: max_output_tokens\n    type: integer\n    description: |\n      <em>maximum number of tokens in the AI response<\/em><br>optional field<br>minimum value: <code>1<\/code>;<br>maximum value: <code>4096<\/code>;<br>default value: <code>2048<\/code>;<br><strong>Note:<\/strong> if <code>web_search<\/code> is set to <code>true<\/code> or the reasoning model is specified in the request, the output token count may exceed the specified <code>max_output_tokens<\/code> limit<br><strong>Note #2:<\/strong> if <code>use_reasoning<\/code> is set to <code>true<\/code>, the minimum value for <code>max_output_tokens<\/code> is <code>1024<\/code>\n  - name: temperature\n    type: float\n    description: |\n      <em>randomness of the AI response<\/em><br>optional field<br>higher values make output more diverse <br>lower values make output more focused<br>minimum value: <code>0<\/code><br>maximum value: <code>2<\/code><br>default value: <code>1.3<\/code>\n  - name: top_p\n    type: float\n    description: |\n      <em>diversity of the AI response<\/em><br>optional field <br>controls diversity of the response by limiting token selection<br>minimum value: <code>0<\/code><br>maximum value: <code>1<\/code> <br>default value: <code>0.9<\/code>\n  - name: web_search\n    type: boolean\n    description: |\n      <em>enable web search for current information<\/em><br>optional field<br>when enabled, the AI model can access and cite current web information;<br><strong>Note:<\/strong> refer to the <a href=\"https:\/\/docs.dataforseo.com\/v3\/ai_optimization\/gemini\/llm_responses\/models\/\">Models endpoint<\/a> for a list of models that support <code>web_search<\/code>; <br>default value: <code>false<\/code>;<br>The cost of the parameter can be calculated on the <a title=\"Gemini API Pricing\" href=\"https:\/\/ai.google.dev\/gemini-api\/docs\/pricing\" target=\"_blank\" rel=\"noopener noreferrer\">Pricing<\/a> page\n  - name: system_message\n    type: string\n    description: |\n      <em>instructions for the AI behavior<\/em><br>optional field<br>defines the AI's role, tone, or specific behavior <br>you can specify <strong>up to 500 characters<\/strong> in the <code>system_message<\/code> field\n  - name: message_chain\n    type: array\n    description: |\n      <em>conversation history<\/em><br>optional field<br>array of message objects representing previous conversation turns;<br>each object must contain <code>role<\/code> and <code>message<\/code> parameters:<br><code>role<\/code> string with either <code>user<\/code> or <code>ai<\/code> role;<br><code>message<\/code> string with message content (max 500 characters);<br>you can specify <strong> the maximum of 10 message objects<\/strong> in the array;<br>example:<br><code>\"message_chain\": [{\"role\":\"user\",\"message\":\"Hello, what\u2019s up?\"},{\"role\":\"ai\",\"message\":\"Hello! I\u2019m doing well, thank you. How can I assist you today?\"}]<\/code>\n  - name: use_reasoning\n    type: boolean\n    description: |\n      <em>enable reasoning for the AI model<\/em><br>optional field<br>when enabled, the model will perform reasoning before generating a response<br>refer to the <a href=\"https:\/\/docs.dataforseo.com\/v3\/ai_optimization\/gemini\/llm_responses\/models\/\" target=\"_blank\">Models endpoint<\/a> for a list of models that support <code>reasoning<\/code><br>default value: <code>false<\/code><br><strong>Note:<\/strong> if set to <code>true<\/code>, the minimum value for <code>max_output_tokens<\/code> is <code>1024<\/code><br><strong>Note #2:<\/strong> for Gemini Pro models, the <code>use_reasoning<\/code> will automatically be set to <code>true<\/code>\n  - name: tag\n    type: string\n    description: |\n      <em>user-defined task identifier<\/em><br>optional field<br><em>the character limit is 255<\/em><br>you can use this parameter to identify the task and match it with the result<br>you will find the specified <code>tag<\/code> value in the <code>data<\/code> object of the response\n  - name: postback_url\n    type: string\n    description: |\n      <em>URL for sending task results<\/em><br>optional field<br>once the task is completed, we will send a POST request with its results compressed in the <code>gzip<\/code> format to the <code>postback_url<\/code> you specified<br>you can use the \u2018$id\u2019 string as a <code>$id<\/code> variable and \u2018$tag\u2019 as urlencoded <code>$tag<\/code> variable. We will set the necessary values before sending the request.<br>example:<br><code>http:\/\/your-server.com\/postbackscript?id=$id<\/code><br><code>http:\/\/your-server.com\/postbackscript?id=$id&amp;tag=$tag<\/code><br><strong>Note:<\/strong> special character in <code>postback_url<\/code> will be urlencoded;<br>i.a., the <code>#<\/code> character will be encoded into <code>%23<\/code><p>learn more on our <a href=\"https:\/\/dataforseo.com\/help-center\/pingbacks-postbacks-with-dataforseo-api\" target=\"_blank\" rel=\"noopener noreferrer\">Help Center<\/a>\n  - name: pingback_url\n    type: string\n    description: |\n      <em>notification URL of a completed task<\/em><br>optional field<br>when a task is completed we will notify you by GET request sent to the URL you have specified<br>you can use the \u2018$id\u2019 string as a <code>$id<\/code> variable and \u2018$tag\u2019 as urlencoded <code>$tag<\/code> variable. We will set the necessary values before sending the request<br>example:<br><code>http:\/\/your-server.com\/pingscript?id=$id<\/code><br><code>http:\/\/your-server.com\/pingscript?id=$id&amp;tag=$tag<\/code><br><strong>Note:<\/strong> special character in <code>pingback_url<\/code> will be urlencoded;<br>i.a., the <code>#<\/code> character will be encoded into <code>%23<\/code><p>learn more on our <a href=\"https:\/\/dataforseo.com\/help-center\/pingbacks-postbacks-with-dataforseo-api\" target=\"_blank\" rel=\"noopener noreferrer\">Help Center<\/a>","apibase_doc_request_additional_yaml":"","apibase_doc_response_yaml":"","footnotes":""},"class_list":["post-23214","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/docs.dataforseo.com\/v3\/wp-json\/wp\/v2\/pages\/23214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/docs.dataforseo.com\/v3\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/docs.dataforseo.com\/v3\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/docs.dataforseo.com\/v3\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.dataforseo.com\/v3\/wp-json\/wp\/v2\/comments?post=23214"}],"version-history":[{"count":12,"href":"https:\/\/docs.dataforseo.com\/v3\/wp-json\/wp\/v2\/pages\/23214\/revisions"}],"predecessor-version":[{"id":24175,"href":"https:\/\/docs.dataforseo.com\/v3\/wp-json\/wp\/v2\/pages\/23214\/revisions\/24175"}],"wp:attachment":[{"href":"https:\/\/docs.dataforseo.com\/v3\/wp-json\/wp\/v2\/media?parent=23214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}