This document answers common questions about the Conversational Analytics API, such as which data sources it supports and how it helps protect your data. For an introduction to the API, see Build data agents and chat with your data.
What data sources does the Conversational Analytics API support?
The Conversational Analytics API supports the following data sources:
- BigQuery (including tables and graphs with BigQuery Graph)
- Looker Explores
- Data Studio
- Database data sources (Preview): AlloyDB for PostgreSQL, GoogleSQL for Spanner, Cloud SQL for MySQL, and Cloud SQL for PostgreSQL
You can also connect to sources such as SAP and Salesforce through BigQuery, and to CSVs and Google Sheets through Data Studio.
Can the Conversational Analytics API alter or delete my data?
The Conversational Analytics API is designed with safeguards to prevent altering or deleting your data.
Here's how data safety is handled for different data sources:
- BigQuery: The API blocks Data Definition Language (DDL) and Data Manipulation Language (DML) statements. Specifically, the system performs a test run on generated SQL and only permits
SELECTtype queries. - Looker: The API interacts with Looker by using methods such as
run_inline_query, which are restricted to read operations such as selections, filters, and limits. These methods don't support DDL or DML operations and don't include delete or drop operations. - Data Studio (for CSVs and Google Sheets): Data Studio uses a structured format to define and fetch data for visualizations and reports. Any queries that are executed with this method are read-only and don't support data mutations.
- Databases: The system only permits
SELECTtype queries. To prevent data alteration or deletion, make sure that the service account or user interacting with the Conversational Analytics API has read-only permissions to your database.
The Conversational Analytics API is designed to be read-only across these data sources. For more information about the security of the Conversational Analytics API, see the Chat with confidence: Unpacking security in Looker Conversational Analytics blog post.
How much does the Conversational Analytics API cost?
The Conversational Analytics API is generally available (GA) for BigQuery, Looker, and Data Studio data sources. Database data sources are in Preview. For more information about pricing, see Data Cloud Agent pricing and free trial.
Additionally, queries that data agents execute against data sources such as BigQuery might incur costs from those services. For BigQuery, you can manage costs by setting quotas or limiting bytes billed per query by using the big_query_max_billed_bytes parameter.
What quotas do I need to be aware of for Google Cloud projects?
For request quotas and limits, see Quotas and limits for the Conversational Analytics API. For the locations where you can use the API, see Conversational Analytics API locations.
Does the Conversational Analytics API support data residency?
Yes, the Conversational Analytics API supports data residency. To control where your data is processed and stored, specify a regional or multi-regional service endpoint when making API requests. For detailed information about specific location support and configuration details, see Data residency.
What are the known limitations of the Conversational Analytics API?
To learn more about the known limitations of the Conversational Analytics API, see the Conversational Analytics API known limitations documentation page.
Does the Conversational Analytics API support languages other than English?
The only officially supported language for the Conversational Analytics API is English. Although the underlying Gemini models support many languages, and some users have reported anecdotal success with non-English queries, the Conversational Analytics API doesn't officially support languages other than English.
How do I handle authentication and permission errors?
Here are some common authentication and permission errors you might encounter when using the Conversational Analytics API:
Error:
PERMISSION_DENIEDor403 Write access to project ... was denied- Likely Cause: This message often indicates issues with Google Cloud IAM roles. The user or service account that is attempting to use the API lacks the necessary permissions on the Google Cloud project.
- Troubleshooting:
- The Google Cloud project owner must ensure that the user or service account has the correct IAM roles assigned in the Google Cloud project. For example, enabling the API or testing its functions might require a role such as Project Editor.
- If you encounter a 403 error such as
Write access to project 'us-gcp-project-name' was deniedwhen switching regions, verify your project's IAM configuration.
Error:
500 Internal Server Errorwhen a Looker user with a User role tries to chat with a data agent.- Likely Cause: The Looker user might not have sufficient permissions.
- Troubleshooting: Make sure that users are granted the appropriate roles in IAM and in Looker to chat with a data agent. See the answer to What are the Looker requirements for using the Conversational Analytics API? in this FAQ for more information.
Why do I see 503 or 500 errors when streaming responses?
If you use a basic HTTP or REST client (such as the Python requests library) to call the streaming :chat endpoint, the API might return a generic error message, such as 503 Connection reset by peer or 500 Internal error.
These generic errors occur because the streaming API sends an HTTP 200 OK header as soon as the stream opens. If the data agent encounters a fatal error during the stream (such as a timeout for a long-running query or a sudden permission denial), it terminates the stream and includes the specific error code in the HTTP/2 trailers. Standard HTTP or REST clients cannot parse these trailing headers and instead interpret the abrupt termination as a socket crash.
To handle errors that occur during a stream, we strongly recommend using the official Google Cloud client libraries (SDKs), such as the Python SDK. These gRPC-based SDKs parse HTTP/2 trailers and return the specific error code (such as DEADLINE_EXCEEDED or PERMISSION_DENIED) instead of a generic network error.
What are the Looker requirements for using the Conversational Analytics API?
To use the Conversational Analytics API, you need appropriate permissions both in Google Cloud IAM and within Looker, depending on the data source and the actions that you want to perform:
Google Cloud IAM roles:
- You need sufficient IAM roles on your Google Cloud project to interact with the
geminidataanalytics.googleapis.comAPI. Misconfigured IAM roles often lead toPERMISSION_DENIEDerrors. - The specific roles required can depend on the actions, but general roles such as Project Editor might be necessary for certain operations.
- You need sufficient IAM roles on your Google Cloud project to interact with the
Looker permissions and roles:
- Model level permissions: To use Conversational Analytics and the Conversational Analytics API, a Looker user must be assigned a Looker role that contains the
gemini_in_lookerpermission for the models that they interact with.
- Model level permissions: To use Conversational Analytics and the Conversational Analytics API, a Looker user must be assigned a Looker role that contains the
To learn more about the permissions and roles that are required to use the Conversational Analytics API, see the Grant Conversational Analytics API IAM roles and permissions documentation page for more information.
Additionally, your Looker instance must meet specific requirements:
To use the Conversational Analytics API with Data Studio Pro, your Pro subscription must be outside of a VPC-SC perimeter.
What are the database requirements for using the Conversational Analytics API?
To use the Conversational Analytics API with database data sources (AlloyDB, GoogleSQL for Spanner, Cloud SQL for MySQL, and Cloud SQL for PostgreSQL), the following requirements apply:
- The Data Analytics API with Gemini (
geminidataanalytics.googleapis.com) and the Gemini for Google Cloud API (cloudaicompanion.googleapis.com) are enabled in your Google Cloud project. For more information, see Enable the Conversational Analytics API. - The user or service account that queries the database has the required IAM roles to connect to and query that database. For the list of roles, see Database roles.
To set up IAM database authentication, see the page for your database:
How do I migrate from the Data QnA API to the Conversational Analytics API?
If you used the older, experimental version of the Data QnA API (dataqna.googleapis.com), see the migration guide for how to migrate to the new, official endpoint for the Conversational Analytics API (geminidataanalytics.googleapis.com).
What is the difference between a data agent's name and its ID?
The data agent's ID, which is defined as the value for data_agent_id, is the unique identifier for the data agent. The data agent's name, data_agent.name, is derived automatically from the data_agent_id as a fully qualified name (FQN), taking the form projects/PROJECT_ID/locations/LOCATION/dataAgents/DATA_AGENT_ID.
When creating a data agent, any value that you may have entered for data_agent.name is ignored. When performing get, update, or delete operations, the full data_agent.name is treated as the unique identifier of the data agent.
When using the Conversational Analytics API to create data agents, the following scenarios apply:
- If you don't define
data_agent_id, a unique ID is generated automatically. - If you define
data_agent_idas, for example,test-id, any value that you may have entered fordata_agent.nameis overwritten withprojects/PROJECT_ID/locations/LOCATION/dataAgents/test-id. - If you define
data_agent_idwith an FQN, the request fails because the value doesn't match the required ID format.
What is the accepted format for an ID in Create Agent or Create Conversation?
For data agents:
projects/PROJECT_ID/locations/LOCATION/dataAgents/DATA_AGENT_ID
Replace the following:
PROJECT_ID: your Google Cloud project ID.LOCATION: the location of the data agent, such asglobal.DATA_AGENT_ID: the resource ID of the data agent. It should be 63 characters or fewer and must match the format that's described in AIP-122: Resource ID segments.
Example: projects/1234567890/locations/global/dataAgents/my-agent
We recommend that you skip setting this field during agent creation because it's inferred automatically and overwritten with projects/PROJECT_ID/locations/LOCATION/dataAgents/DATA_AGENT_ID.
For conversations:
projects/PROJECT_ID/locations/LOCATION/conversations/CONVERSATION_ID
Replace the following:
PROJECT_ID: your Google Cloud project ID.LOCATION: the location of the conversation, such asglobal.CONVERSATION_ID: the resource ID of the conversation. It should be 63 characters or fewer and must match the format that's described in AIP-122: Resource ID segments.
Example: projects/1234567890/locations/global/conversations/my-conversation
We recommend that you skip setting this field during conversation creation because Conversational Analytics automatically identifies and then overwrites it with projects/PROJECT_ID/locations/LOCATION/conversations/CONVERSATION_ID.
How do I use updateMask?
In the data agent patch method, the updateMask parameter takes a FieldMask format string that specifies which dataAgent fields the update overwrites. The updateMask parameter is optional and works as follows:
- If you omit
updateMask, every field that has a non-default value in the request body is overwritten. - If all the fields in
updateMaskare validdataAgentfields, only those fields are updated. - If
updateMaskcontains any field that isn't a validdataAgentfield, the request fails with a400 INVALID_ARGUMENTerror, and no fields are updated.
How do I use getIAMPolicy and setIAMPolicy to set the IAM policy for a data agent?
You can use the getIamPolicy method and setIamPolicy method to assign IAM roles to users for a specific agent.
The following code samples demonstrate how to fetch the IAM policy for a data agent:
The following code samples demonstrate how to assign IAM to a data agent:
What are the Conversational Analytics API data agent's memory capabilities?
- Within a single session: The Conversational Analytics API supports multi-turn conversations, meaning it can reference earlier parts of the current conversation.
- Across multiple sessions: The Conversational Analytics API includes features for managed conversation history, allowing users to chat over multiple sessions. It also supports stateful agents with Google-managed multi-turn conversations.
- Long-term memory: Conversational Analytics API data agents don't support explicit long-term memory capabilities.
Will a Conversational Analytics API data agent give me the same answer every time I ask the same question?
- Natural language responses from the Conversational Analytics API data agent aren't deterministic, so the natural language answer provided by the agent may vary even for an identically worded question.
- Data query responses: However, for a specific data-seeking question, the underlying generated query (SQL or Looker query) is expected to be deterministic. The data that's retrieved should be the same, assuming that the underlying data hasn't changed.
How can I improve the accuracy of the responses from a Conversational Analytics API data agent?
One way to improve the accuracy of data agent responses is to provide the data agent with robust contextual information. You can add context in the following ways:
- In Looker's semantic layer, you can provide context within the LookML definitions. For more information and examples, see the Guide agent behavior with authored context in Looker documentation page.
- For BigQuery data sources, you can provide authored context through structured context fields — such as table-level and column-level descriptions, synonyms, tags, and example queries — and through system instructions. Providing this context also helps to improve response accuracy and can enable agents to cite sources in their responses. For more information, see Define data agent context for BigQuery data sources.
- In AlloyDB for PostgreSQL, Cloud SQL for MySQL, Cloud SQL for PostgreSQL, and Spanner data sources, you can provide context by adding table, column, schema descriptions, and constraints as guidance for the data and how to interpret that data.
When you create a data agent, you can provide system instructions, verified queries, and advanced context:
- System instructions, which are user-defined guidance that can shape the behavior of a data agent. This guidance includes business-specific logic, response formatting, or data presentation.
- You can provide verified queries (also referred to as golden queries depending on the data source), which are sample natural language questions that are paired with their correct SQL or Looker queries.
- For AlloyDB, Cloud SQL for MySQL, Cloud SQL for PostgreSQL, and Spanner data sources, you can provide advanced context, which helps you optimize your agents' data understanding and accuracy.
For more information, see Guide agent behavior with authored context.
See the Ask effective questions page for guidance about asking questions for more effective and accurate responses.
How can I safely inspect and handle agent-generated Python code?
If you have enabled advanced analysis with Python, your data agent might return Python code. The Python code that data agents return is designed to execute within a secure, Google-managed sandbox. Executing this code in a local or other unverified environment bypasses the sandbox's security protections and can expose your system to security risks, such as the execution of malicious code.
To safely inspect and handle agent-generated Python code, follow these guidelines:
- Manually inspect the generated code before running it. Look for suspicious patterns such as unexpected network requests (for example,
socket,requests, orurllib), system-level commands (for example,os.systemorsubprocess), or heavily obfuscated string literals and variables. - Never run unverified code directly on a local machine or within a production environment. Use a secure, isolated sandbox — such as a Colaboratory notebook, an ephemeral Docker container, or a virtual machine — that doesn't have access to sensitive credentials, internal networks, or local file systems.
- Where possible, before you run the code, you should run static analysis tools or linters on the code to flag potentially unsafe operations or known malicious patterns.
Can I integrate the Conversational Analytics API with third-party applications?
Integrating the Conversational Analytics API with third-party applications allows users to interact with their data directly within the tools that they use daily.
Any third-party application that interacts with the geminidataanalytics.googleapis.com API endpoints must be able to send user messages from the application to the agent and display the responses.
To build an integration, see the Conversational Analytics Quickstarts repository for examples or libraries. You can also visit the Google Developer Forums to search for examples from other users.