Connecting PrimaLabs Open-Weight Models with AlloyDB Data via CData Connect AI Gateway

Somya Sharma
Somya Sharma
Technical Marketing Engineer
Route PrimaLabs open-weight models through CData Connect AI Gateway and query live AlloyDB data with governed, permissioned access, per-team budgets, and a full audit log.

PrimaLabs runs serverless inference for open-weight models such as Kimi K3.1 Pro, GLM 5.3 Flash, MiMo-V2.6-Pro, and DeepSeek V4.1 Flash. The API is OpenAI-compatible and priced per token, so you can point an existing client at PrimaLabs and compare results on your own traffic. Many teams now send the routine steps of an agent run, like classifying a request, drafting a query, or summarizing a result, to models like these, because those steps make up most of the calls and rarely need a frontier model.

Lower inference cost brings its own problem. Open-weight pilots often stall because the model has no governed path to company data, no spend or access controls by team, and no audit trail of what the agent asked and saw. CData Connect AI Gateway closes those gaps. It routes any OpenAI-compatible provider through one governed endpoint, while CData Connect AI connects your agent to live data in hundreds of sources through the Model Context Protocol (MCP) and applies the requesting user's permissions to every query.

This guide shows you how to configure a AlloyDB connection in Connect AI, add PrimaLabs as a custom LLM provider in the Gateway, route requests to a PrimaLabs model, and run a live AlloyDB query through that model.

Note: CData Connect AI Gateway is available through an early access program. You can request early access to get 14 days of full Connect AI access. After the 14 days, you keep Gateway routing and budget controls at no cost through December 31, 2026.

Prerequisites

Before you start, make sure you have:

  1. A CData Connect AI account with Gateway early access enabled
  2. A PrimaLabs account and API key
  3. Access to AlloyDB
  4. Python 3.9+ to run the test script in this guide
  5. Claude Code installed

Credentials checklist

Keep these values ready. You'll use each one in the steps below.

CData Connect AI

  1. USERNAME: Your CData email login
  2. PAT: In Connect AI, go to Settings and click Personal Access Tokens (copy once)
  3. MCP_BASE_URL: https://mcp.cloud.cdata.com/mcp
  4. GATEWAY_ENDPOINT and VIRTUAL_KEY: The Gateway endpoint and the revocable virtual key your callers use (see Step 4)

PrimaLabs

  1. PRIMALABS_API_KEY: Your PrimaLabs API key
  2. PRIMALABS_BASE_URL: https://api.primalabs.ai/v1 (shown in the Start building panel of your PrimaLabs dashboard)
  3. MODEL_ID: The model ID exactly as PrimaLabs lists it, prefix included (for example, primalabs-ai/GLM-5.3-Flash)

Step 1: Configure AlloyDB connectivity for PrimaLabs

Your PrimaLabs model reaches AlloyDB through CData Connect AI Remote MCP. To work with AlloyDB from an agent, start by creating and configuring a AlloyDB connection in Connect AI.

  1. Log into Connect AI, click Sources, and then click Add Connection
  2. Adding a Connection
  3. Select "AlloyDB" from the Add Connection panel
  4. Selecting a data source
  5. Enter the necessary authentication properties to connect to AlloyDB.

    The following connection properties are usually required in order to connect to AlloyDB.

    • Server: The host name or IP of the server hosting the AlloyDB database.
    • User: The user which will be used to authenticate with the AlloyDB server.
    • Password: The password which will be used to authenticate with the AlloyDB server.

    You can also optionally set the following:

    • Database: The database to connect to when connecting to the AlloyDB Server. If this is not set, the user's default database will be used.
    • Port: The port of the server hosting the AlloyDB database. This property is set to 5432 by default.

    Authenticating with Standard Authentication

    Standard authentication (using the user/password combination supplied earlier) is the default form of authentication.

    No further action is required to leverage Standard Authentication to connect.

    Authenticating with pg_hba.conf Auth Schemes

    There are additional methods of authentication available which must be enabled in the pg_hba.conf file on the AlloyDB server.

    Find instructions about authentication setup on the AlloyDB Server here.

    Authenticating with MD5 Authentication

    This authentication method must be enabled by setting the auth-method in the pg_hba.conf file to md5.

    Authenticating with SASL Authentication

    This authentication method must be enabled by setting the auth-method in the pg_hba.conf file to scram-sha-256.

    Authenticating with Kerberos

    The authentication with Kerberos is initiated by AlloyDB Server when the ∏ is trying to connect to it. You should set up Kerberos on the AlloyDB Server to activate this authentication method. Once you have Kerberos authentication set up on the AlloyDB Server, see the Kerberos section of the help documentation for details on how to authenticate with Kerberos. Configuring a connection (Salesforce is shown)

  6. Click Save & Test
  7. Open the Permissions tab on the Add AlloyDB Connection page and update the user-based permissions. The Gateway and the MCP server enforce these permissions on every request, whichever model handles it. Updating permissions

Add a Personal Access Token

A Personal Access Token (PAT) authenticates your agent's connection to Connect AI. Create a separate PAT for each service to keep access granular.

  1. Click the Gear icon () at the top right of the Connect AI app to open the settings page.
  2. On the Settings page, go to the Personal Access Tokens section and click Create PAT.
  3. Give the PAT a name and click Create. Creating a new PAT
  4. Copy the PAT and store it securely. Connect AI shows it only once, at creation.

With the connection configured and a PAT generated, you're ready to bring PrimaLabs into the Gateway.

Step 2: Get your PrimaLabs credentials

PrimaLabs exposes an OpenAI-compatible API, which is the only requirement for bring your own model in Connect AI Gateway.

  1. Log in to PrimaLabs. In the Start building panel on your dashboard, click Reveal key and copy your API key
  2. Copy the base URL from the same panel (https://api.primalabs.ai/v1)
  3. In the model list on your dashboard, find the model you want to route to and copy its ID exactly as PrimaLabs shows it. The ID includes the primalabs-ai/ prefix and can end with a suffix for some models (for example, primalabs-ai/GLM-5.3-Flash or primalabs-ai/Nemotron-3.5-Lightning-NVFP4)
PrimaLabs API key and model ID

PrimaLabs publishes its data retention terms. Review them before you send business data to any third-party inference provider.

Step 3: Add PrimaLabs as a custom LLM provider

  1. Log into Connect AI and click LLM Providers under Manage in the left navigation
  2. Add a custom LLM provider and name it PrimaLabs
  3. Enter your PrimaLabs API key and base URL (https://api.primalabs.ai/v1)
  4. Save the provider
Adding PrimaLabs as a custom LLM provider

Connect AI stores the provider key, so your callers never handle it directly.

Step 4: Create a routing rule and set controls

A routing rule tells the Gateway which model handles a request, and a project applies that rule to your callers. Point a rule at your PrimaLabs models, then apply the controls that make them safe for enterprise use.

  1. Click Routing under LLM Gateway, click Add Project, and name the project
  2. On the Routing Rule tab, choose a routing rule or create one that targets your PrimaLabs model. Enter the model ID exactly as PrimaLabs lists it, for example primalabs-ai/GLM-5.3-Flash. Add a failover model, and under CData MCP, enable Search Context Tool/Skill and Data Source Instructions.
  3. On the Spend Limits tab, set a budget for the project. The Gateway checks the budget before it spends any tokens
  4. On the Rate Limits tab, cap the requests and tokens your callers can send
  5. On the Virtual Keys tab, generate a virtual key for your callers. You can revoke a virtual key at any time without touching the provider key
  6. Click View Endpoints to copy the Gateway endpoint your callers will use
Routing rule, budget, and virtual key

Use these values for the required settings:

Setting Value
Provider name PrimaLabs
Provider API key Your PrimaLabs API key
Provider base URL https://api.primalabs.ai/v1
Rule type Priority Failover
Primary model primalabs-ai/GLM-5.3-Flash
Failover model A second model, from PrimaLabs or another provider you've added
Caller credentials The Gateway endpoint and the virtual key from your project

From this point, the Gateway logs every request and attributes it to the person or agent that made it.

Step 5: Send a test request through the Gateway

Moving an existing agent onto the Gateway takes two changes: the base URL and the API key. This script confirms that your routing rule reaches PrimaLabs.

Run these commands in a terminal on your machine (PowerShell or Command Prompt on Windows, Terminal on macOS or Linux). Install the client:

pip install openai

Save the script below as test_gateway.py in any folder you can easily find, such as a new folder named primalabs-test in your Documents folder. Replace the two placeholder values. In the terminal, go to that folder with cd and run the script with python test_gateway.py:

from openai import OpenAI

client = OpenAI(
    base_url="your_GATEWAY_ENDPOINT",
    api_key="your_VIRTUAL_KEY",
)

response = client.chat.completions.create(
    model="primalabs-ai/GLM-5.3-Flash",
    messages=[
        {"role": "user", "content": "Reply with one sentence to confirm you are reachable."}
    ],
)

print(response.choices[0].message.content)

A reply from the model confirms the route. To see the request in the Gateway log, click Logs under Manage in the left navigation, select the LLM Log tab, and click Refresh. The entry shows the user, the project, the model you requested and the model that served the request, the token counts, and the cost.

Gateway log showing the test request

Step 6: Connect Claude Code to the Gateway and Connect AI

The Gateway covers the model side. Connect AI covers the data side. Claude Code can use both: it sends its model calls to the Gateway, and it connects to the Connect AI MCP server with Basic authentication, which combines your Connect AI email and your PAT.

Create a project folder. Inside it, create a .claude folder with a file named settings.local.json, and replace the placeholder with your virtual key:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://cloud.cdata.com/gateway",
    "ANTHROPIC_AUTH_TOKEN": "your_Connect_AI_virtual_key",
    "ANTHROPIC_MODEL": "primalabs-ai/GLM-5.3-Flash"
  }
}

From the project folder, register the Connect AI MCP server. Replace the placeholder with your email and PAT, joined by a colon and base64-encoded (for example, [email protected]:your_PAT):

claude mcp add --transport http connect-ai https://mcp.cloud.cdata.com/mcp --header "Authorization: Basic your_base64_encoded_email_PAT"

Connect AI runs queries, joins, and filters in the data layer, so the model receives only the result it needs. That keeps token counts down on any model you route to.

Step 7: Ask a question in Claude Code

Start Claude Code from the project folder with claude and enter a sample prompt:

List the tables available in my AlloyDB connection and summarize the first five rows of the most relevant one.

The agent queries AlloyDB through Connect AI with your permissions applied, and the Gateway records the request, the model, and the token usage.

Run open-weight models against live AlloyDB data with CData Connect AI Gateway

PrimaLabs supplies low-cost inference for open-weight models, and CData Connect AI Gateway adds one governed endpoint, spend limits, and a full request log. CData Connect AI gives those models live, permissioned access to AlloyDB through MCP.

Request early access to Connect AI Gateway or start a free trial of CData Connect AI today.

Ready to get started?

Learn more about CData Connect AI or sign up for free trial access:

Free Trial