DataForSEO AI Optimization API icon

DataForSEO AI Optimization API

DataForSEO

Gemini → Get Live Gemini LLM Responses

AI-generated

Summary

Sends a prompt to the specified Google Gemini AI model and returns the structured response.

Inputs

  • user_prompt (required) — The question or task to send to the AI model. Limited to 500 characters.
  • model_name (required) — The name of the Gemini model (e.g., gemini-1.5-pro). If a base name is used, the latest version is applied automatically.
  • max_output_tokens — Maximum number of tokens for the AI response. Optional.
  • temperature — Randomness of the response. Range: 0 to 2. Optional.
  • top_p — Diversity of the response. Range: 0 to 1. Optional.
  • web_search — Enable web search to enhance the response. Defaults to false. Optional.
  • system_message — Instructions defining the AI's role, tone, or behavior. Optional.
  • message_chain (required) — Array of previous messages to include in the conversation history. Each object requires a 'role' ('user' or 'ai') and a 'message'.

Output shape

The raw JSON response from the DataForSEO API, containing the structured output of the Gemini model.

The API returns a response envelope (status_code, tasks array). The actual content is typically nested within tasks[0].result[0].

Examples

Example 1: Simple single-turn question

Set user_prompt to 'What is 2+2?', model_name to 'gemini-1.5-flash', and leave other parameters at defaults.

Example 2: Conversation with system instructions

Set system_message to 'You are a helpful coding assistant.' and message_chain to include previous turns (e.g., user: 'Write a loop' -> ai: 'Here is the loop...').

Links

Discussion