How to create a xAI API key to use in Ozeki AI Gateway

This guide demonstrates how to create an xAI API key and configure it in Ozeki AI Gateway. You'll learn how to access the xAI console, generate a new API key with appropriate settings, and set up xAI as a provider in your gateway. By following these steps, you can connect your Ozeki AI Gateway to xAI's Grok models and other AI services through their unified API interface.

API URL: https://api.x.ai/v1/
Example API Key: xai-abcde...

What is xAI?

xAI is an AI company that develops advanced language models, including the Grok series. xAI provides access to their models through a developer API that follows the OpenAI-compatible format, making it easy to integrate with existing applications. When configured with Ozeki AI Gateway, it gives your users access to xAI's powerful language models while maintaining centralized access control and monitoring.

Overview
Overview

Steps to follow

  1. Navigate to xAI Console
  2. Create new API key
  3. Copy the API key
  4. Open Providers page in Ozeki AI Gateway
  5. Create provider

How to Create xAI API key video

The following video shows how to create an xAI API key and configure it in Ozeki AI Gateway step-by-step.

Step 0 - Install Ozeki AI Gateway

Before configuring xAI as a provider, you need to have Ozeki AI Gateway installed and running on your system. If you haven't installed Ozeki AI Gateway yet, follow our Installation on Linux guide or Installation on Windows guide to complete the initial setup.

Step 1 - Navigate to xAI Console

Navigate to the xAI Console. This is the main portal where you can access your xAI dashboard, manage your API keys, and monitor your API usage (Figure 1). Sign in to your xAI account, or create a new account if you don't have one yet.

Navigate to xAI Console
Figure 1 - Navigate to xAI Console

Step 2 - Create new API key

Once logged in to your xAI Console, locate and click on the "API Keys" section in the navigation menu. Then click the "Create API Key" button to begin the API key generation process (Figure 2). This will open a dialog or form where you can configure the settings for your new API key.

Create new API key
Figure 2 - Click to create new API key

In the API key creation dialog, enter a descriptive name for your API key. Choose a name that helps you identify the purpose or project for this key, such as "Ozeki AI Gateway". You may also have options to set permissions or usage limits depending on your xAI account type. After entering the required details, click the Create API key button to create the API key (Figure 3).

Enter details and generate key
Figure 3 - Enter API key details and generate

Step 3 - Copy the API key

After successfully generating your API key, xAI will display it on the screen. Click the "Copy" button to copy the API key to your clipboard (Figure 4). Make sure to store this key securely, as it provides access to your xAI account and services.

The API key is shown only once for security reasons. Make sure to copy and securely store the key before closing this window. If you lose your key, you'll need to create a new one.

Copy API key
Figure 4 - Copy your xAI API key

Step 4 - Open Providers page in Ozeki AI Gateway

Open the Ozeki AI Gateway web interface and navigate to the Providers page. This is where you'll configure xAI as a new provider using the API key you just created (Figure 5).

Open Providers page
Figure 5 - Open Providers page in Ozeki AI Gateway

Step 5 - Create provider

Click the "New" button to begin the provider creation process. This opens a form where you'll enter the connection details for xAI (Figure 6).

Add new provider
Figure 6 - Click add new provider button

Fill in the provider configuration form with xAI's details. Enter a descriptive provider name (e.g., "xAI Grok"), select "OpenAI compatible" as the provider type, specify the API endpoint URL, and paste the API key you copied earlier. Select your preferred model from the dropdown list, then click "Create" to save the configuration (Figure 7).

https://api.x.ai/v1/

Enter provider details and create
Figure 7 - Enter xAI provider details and create

After creation, the xAI provider is added to Ozeki AI Gateway. The provider now appears in the providers list, confirming that your gateway can route requests to xAI's services. You can now create routes that allow users to access xAI's Grok models and other AI services through your gateway (Figure 8).

Provider created successfully
Figure 8 - xAI provider created successfully

Conclusion

You have successfully created an xAI API key and configured it as a provider in Ozeki AI Gateway. Your gateway can now communicate with xAI's services and access their Grok models through a unified interface. This setup allows you to manage access to xAI's advanced language models for multiple users and applications from a single point, while maintaining centralized control over API usage and costs.

More information