# xAI

Learn how to connect Buddy with xAI and run the Grok action in your pipelines.

## What is Grok?

Grok is a family of AI models from xAI, including models built for working with code.

By integrating Buddy with xAI you can add the **Grok** action to your [pipelines](/docs/ai-agents/pipelines.md) and use it to review code, fix failing builds, or automate routine tasks.

<Hint type="info">

To use Buddy from the terminal in Grok Build, see [Grok Build with Buddy](/docs/ai-agents/agents/grok-build.md).

</Hint>

## Generating an xAI API key

To connect Buddy with xAI, you need an API key.

1. Open [console.x.ai](https://console.x.ai "seo-nf") and sign in.

![Signing in to the xAI console](/docs/integrations/grok/grok-integration-console-login.png 1400x1542)

2. If you sign in with X, authorize the xAI app to access your account.

![Authorizing the xAI console with an X account](/docs/integrations/grok/grok-integration-authorize-x.png 1400x737)

3. On first sign-in, create a team. API keys and credits belong to the team.

![Creating a team in the xAI console](/docs/integrations/grok/grok-integration-create-team.png 1400x856)

4. Select a plan with API access and set up billing.

![Picking a starting plan in the xAI console](/docs/integrations/grok/grok-integration-plan.png 1400x1139)

5. Go to **API keys** and click **Create API key**.

![API keys section in the xAI console](/docs/integrations/grok/grok-integration-api-keys.png 1400x956)

6. Copy the generated key - the console shows it only once. The key is required when adding the integration in Buddy.

## Setting up Grok integration

1. In Buddy, go to the <u>Integrations</u> tab and click **New integration**.

2. Search for and select **Grok**.

![Grok on the list of available integrations](/docs/integrations/grok/grok-integration-new.png 1400x1482)

3. Fill in the configuration form:

- **Name** and **ID** - the integration name and identifier
- **Scope** - whether the integration is available across the whole <u>Workspace</u>, a single <u>Project</u>, or a specific <u>Environment</u>
- **API key** - the key generated in the xAI console

<Hint type="info">

You can configure who can use the integration and where it is available in the <u>Permissions</u> tab.

</Hint>

4. Click **Add a new integration** to save the configuration.

![Grok integration configuration with the API key](/docs/integrations/grok/grok-integration-form.png 1400x800)

Buddy stores the key as an encrypted secret and passes it to the action at runtime. The key is not stored in your repository.

<Hint type="warning">

xAI API usage is billed per use and charged to the team balance. Create a dedicated key per integration so you can revoke it without affecting other projects, and keep the integration **Scope** as narrow as the projects or environments that need it.

</Hint>

## Running Grok in a pipeline

Once the integration is saved, add the **Grok** action to a [pipeline](/docs/ai-agents/pipelines.md) and select the integration.

<Hint type="info">

Read how to configure [Grok with YAML](/docs/yaml/yaml-actions/grok.md) and [Grok POST parameters](/docs/api/actions/add/grok.md).

</Hint>


---
Original source: https://buddy.works/docs/integrations/xai