# Antigravity CLI

Antigravity CLI (`agy`) can send Gemini generation requests to AISIX. The client uses the same Gemini wire protocol for both Google AI Studio and an upstream that serves OpenAI Chat Completions, such as GitHub Copilot Chat. This integration requires AISIX gateway v1.12.0 or later.

## Choose the Upstream[​](#choose-the-upstream "Direct link to Choose the Upstream")

Ask your gateway administrator for the AISIX proxy URL, a caller API key, and a model alias that key can access. To provision the alias, create a [direct model](https://docs.api7.ai/ai-gateway/models/model-aliases.md#create-a-direct-model) with the desired `display_name`, `model_name`, and `provider_key_id`. Grant the caller key access to that model. The examples use `gemini-3.8-flash` as the caller-facing alias. The provider key and upstream model ID determine which service handles the request.

| Upstream         | Provider key in AISIX                                                                                                                                                                                                                                                                                                    | Upstream model and request                                                                                                                                                                           |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Google AI Studio | Use the `google` catalog provider at its official endpoint with a Google API key. In AISIX OSS, set `apis.gemini.base` to `https://generativelanguage.googleapis.com/v1beta`. See the [Gemini provider guide](https://docs.api7.ai/ai-gateway/providers/gemini.md).                                                      | Set `model_name` to an available Google model ID. AISIX calls Google's native generation endpoint with that model and sends the provider credential in `x-goog-api-key`.                             |
| Copilot Chat     | Use your existing Chat Completions provider key, or configure a [BYO provider key](https://docs.api7.ai/ai-gateway/models/provider-keys.md#set-provider-and-adapter) with `provider: byo`, `adapter: openai`, `api_base: https://api.githubcopilot.com`, and a credential for that endpoint. Leave `apis.gemini` absent. | Set `model_name` to a model that your integration can call on `/chat/completions` and that supports tools. AISIX translates the request to Chat Completions and returns the answer in Gemini format. |

## Configure Antigravity[​](#configure-antigravity "Direct link to Configure Antigravity")

In the shell where you run `agy`, set the AISIX proxy origin without a trailing slash or API version. Use the caller key that AISIX issued to you. Antigravity sends this value as a bearer token.

```
export AGY_LLM_GATEWAY_URL="https://gateway.example.com"

export AGY_LLM_GATEWAY_API_KEY="YOUR_AISIX_CALLER_KEY"

export AGY_LLM_GATEWAY_WIRE_PROTOCOL="genai"

export AGY_LLM_GATEWAY_MODELS="gemini-3.8-flash"



agy --model gemini-3.8-flash -p "Reply with PONG."
```

For managed workstations, an administrator can distribute the following `admin_settings.json` (on Linux, `/etc/antigravity/admin_settings.json`). Supply each developer's key through `AGY_LLM_GATEWAY_API_KEY`. The CLI resolves each setting from the administrator file first, then the environment, then the user's `~/.antigravity/settings.json`. See [Google's gateway settings](https://docs.cloud.google.com/gemini/enterprise/docs/ai-developer-tools/deploy-enterprise-gateway#settings-precedence).

admin\_settings.json

```
{

  "gateway": {

    "enabled": true,

    "url": "https://gateway.example.com",

    "wireProtocol": "genai"

  },

  "models": {

    "defaultModelId": "gemini-3.8-flash",

    "list": [{"modelId": "gemini-3.8-flash"}]

  }

}
```

## Verify Generation and Tool Calls[​](#verify-generation-and-tool-calls "Direct link to Verify Generation and Tool Calls")

For a single JSON response, send a request to the gateway with the same alias and caller key.

```
curl -sS "$AGY_LLM_GATEWAY_URL/v1beta/models/gemini-3.8-flash:generateContent" \

  -H "Authorization: Bearer $AGY_LLM_GATEWAY_API_KEY" \

  -H "Content-Type: application/json" \

  -d '{"contents":[{"role":"user","parts":[{"text":"Reply with PONG."}]}]}'
```

A successful response contains text under `candidates[].content.parts[]`. For server-sent events (SSE), use `curl -N` and change the suffix to `:streamGenerateContent?alt=sse`. AISIX accepts both operations as `POST` on either path prefix.

* `/v1beta/models/{alias}`
* `/v1beta1/projects/{project}/locations/{location}/publishers/google/models/{alias}`

Both prefixes resolve the alias in AISIX. If an existing [passthrough route](https://docs.api7.ai/ai-gateway/endpoints/provider-passthrough.md) matches the host or path, it takes precedence over this model routing. To confirm the upstream, check its request log. Google receives `/v1beta/models/{upstream-model}` with the corresponding generation action. Copilot receives `/chat/completions` with the upstream model ID in the JSON body.

To verify a tool round trip, create a file in a fresh workspace and start an interactive session.

```
cd "$(mktemp -d)"

openssl rand -hex 16 > marker.txt

agy --model gemini-3.8-flash -i "Use read_file to read marker.txt and reply with its exact contents."
```

With Google's `gemini-3.6-flash` and Copilot Chat's `claude-haiku-5.5`, `agy` 1.5.15 used `:streamGenerateContent?alt=sse` to receive a `read_file` call, read the file locally, and send its contents back in a `functionResponse`. The final reply matched the file. On the Copilot path, AISIX pairs a result without an ID with the oldest pending call of the same name and supplies the matching Chat Completions `tool_call_id`. On the Google path, it preserves the native tool history, including a model's `thoughtSignature`.
