> For the complete documentation index, see [llms.txt](https://docs.terrakube.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.terrakube.io/user-guide/workspaces/actions/built-in-actions/terrakube.open-ai.md).

# Open AI

{% hint style="warning" %}
**Security Warning**

The current action shares the state with the OpenAI API, so it's not recommended for sensitive workspaces. Future versions will provide a mask method before sending the data.
{% endhint %}

### Description

The Ask Workspace action allows users to interact with OpenAI's GPT-4o model to ask questions and get assistance related to their Terraform Workspace. This action provides a chat interface where users can ask questions about their Workspace's Terraform state and receive helpful responses from the AI.

### Display Criteria

By default, this Action is disabled and when enabled will appear for all resources. If you want to display this action only for certain resources, please check [display criteria](#display-criteria).

### Setup

This action requires the following variables as [Workspace Variables](/user-guide/workspaces/variables.md#workspace-specific-variables) or [Global Variables](/user-guide/organizations/global-variables.md) in the Workspace Organization:

* **OPENAI\_API\_KEY**: The API key to authenticate requests to the OpenAI API. Please check [this guide](https://platform.openai.com/docs/quickstart/step-2-set-up-your-api-key) in how to get an OPEN AI api key

### Usage

* Navigate to the `Workspace` and click on the `Ask Workspace` button.

<figure><img src="/files/1RmxTpYjKZLkKbmM3KJ7" alt=""><figcaption></figcaption></figure>

* Enter your questions and click the **Send** button or press the **Enter** key.

<figure><img src="/files/K8ElgUpRkgG7ANEdNtZy" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.terrakube.io/user-guide/workspaces/actions/built-in-actions/terrakube.open-ai.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
