> ## Documentation Index
> Fetch the complete documentation index at: https://gproxy.leenhawk.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Providers & Credentials

> Choose a channel, add providers and credentials, and configure login, allowance queries, and connections.

This chapter is for the administrator who connects GPROXY to its upstreams: it
covers choosing a channel, creating providers, adding and maintaining their
credentials, and the outbound connection settings they use.

A *channel* is the adapter, compiled into the binary, for one upstream family.
A *provider* is one saved connection on a channel: a name, an optional base
URL, the channel's own `config` JSON, and a pool of credentials. A channel can
carry any number of providers; `openai-main` and `openai-eu` can both be on the
`openai` channel.

## Choosing a channel

Only the channels compiled into your binary exist. The default build includes
every channel in the repository; a binary built with individual channel
features carries only those. `GET /admin/api/channels` answers from the binary,
not from the database. Each entry lists the channel's login modes, its
capabilities and the `config` keys a provider form should render; the
[channel catalogue](https://gproxy.leenhawk.com/reference/channel-catalog.md) prints the same data for the
current release.

| Channel | Upstream | Credential |
| - | - | - |
| `aistudio` | Google AI Studio: the native Gemini methods and the `/v1beta/openai` compatibility layer on one origin | `{"api_key"}` |
| `playground` | AI Studio Playground web session: Gemini generation/streaming and model discovery; built-in WAA signing, native deployments only | `{"cookie"}` |
| `antigravity` | A Google account through the Code Assist host the Antigravity editor talks to | OAuth |
| `aws_bedrock` | AWS Bedrock. The wire depends on the model: `InvokeModel` for Anthropic models (the event stream is translated to Claude SSE), OpenAI-compatible Chat Completions for GPT, Grok, Qwen, DeepSeek and the rest | AWS key pair, or a Bedrock API key |
| `azure` | Azure OpenAI, and the Anthropic models Azure AI Foundry hosts | `{"api_key"}` |
| `claudeapi` | Anthropic's own API, its OpenAI compatibility layer and the cost report. `workspace_id` is required for a key that is not scoped to one workspace | `{"api_key", "quota_api_key"?, "workspace_id"?}` |
| `claudecode` | A Claude.ai subscription, using the requests the Claude Code CLI makes | OAuth |
| `claudeweb` | A claude.ai browser session, rendered as Claude Messages SSE | session cookie + organization |
| `cline` | Cline's own account at `api.cline.bot` | `{"api_key"}` or OAuth |
| `cloudflare_ai_gateway` | Cloudflare AI Gateway over the REST API, with account and gateway per credential; embeddings, reranking, Workers AI model discovery and the credit balance | `{"api_key", "account_id"?, "gateway_id"?}` |
| `codex` | A ChatGPT account through the Codex backend: Responses over SSE and WebSocket, `/wham/usage` | OAuth |
| `commandcode` | Command Code CLI: native generation, model catalogue, credit balance, billing-period spend and request counts, usage windows | `{"api_key"}`, or browser authorization (you paste the issued key) |
| `copilotcli` | GitHub Copilot through the `copilot` CLI | GitHub OAuth token |
| `custom` | Any API-key endpoint that speaks OpenAI, Claude or Gemini natively | `{"api_key"}` |
| `dashscope` | Alibaba DashScope: the OpenAI and Anthropic modes, rerank, native image generation | `{"api_key"}` |
| `deepseek` | DeepSeek: Chat under `/v1`, Responses at the root, Claude Messages under `/anthropic` | `{"api_key"}` |
| `devin` | Devin (Windsurf) at `server.codeium.com`: Connect-RPC over protobuf | session token |
| `factory` | Factory Droid (`https://api.factory.ai`): Claude Messages, Responses, Chat Completions and Gemini on one origin, chosen per model; WorkOS device login; Standard and Droid Core usage windows | `{"api_key"}` or device login |
| `geminicli` | A Google account through the Code Assist endpoints the Gemini CLI talks to | OAuth |
| `google_ai_plan` | A Google AI Ultra plan through the Gemini API's per-user quota endpoint (Interactions) | OAuth |
| `glm` | GLM pay-as-you-go API, with the live official ZCode model catalogue | `{"api_key"}` |
| `glmcode` | GLM Coding Plan: separate catalogue, Chat, Messages and Responses, subscription quota | `{"api_key"}` |
| `grokbuild` | An xAI account through the Grok Build CLI | OAuth |
| `kimi` | Moonshot's platform with a key, or the Kimi Code subscription through a device login | `{"api_key"}` or OAuth |
| `kiro` | AWS CodeWhisperer through the Kiro desktop app | OAuth |
| `minimax` | MiniMax text API and Token Plan; H3 video creation, query, listing, cancellation or deletion, and download | `{"api_key"}` |
| `nvidia` | NVIDIA NIM: Chat Completions, models and embeddings | `{"api_key"}` |
| `openai` | OpenAI's own platform: the full surface, including Responses and Realtime over a socket | `{"api_key", "quota_api_key"}` |
| `opencodego` | OpenCode Go: the subscription, open models, usage windows | `{"api_key"}` |
| `opencodezen` | OpenCode Zen: pay-as-you-go from the Console balance | `{"api_key"}` or OAuth |
| `opendesign` | OpenDesign Go / Cloud subscription: Chat Completions, Responses and Claude Messages on one origin (`https://amr-link.open-design.ai`); no quota query | `{"api_key"}` |
| `openrouter` | OpenRouter: routing preferences in the body, the price the reply reports | `{"api_key"}` |
| [`orcaterm`](#orcaterm) | OrcaTerm account: LightAI text and image conversations, streamed reasoning, live built-in models and the AI question quota | Browser OAuth (WeChat, Tencent Cloud, Google, GitHub), optional cookie import |
| `trae` | Trae China and international: native raw chat, account models and entitlement usage | OAuth |
| `vercel` | Vercel AI Gateway: Chat, Responses, Claude Messages, embeddings and the team credit balance | `{"api_key"}` |
| `vertex` | Google Vertex AI: the Google, Anthropic and OpenAI-compatible publishers | service-account key |
| `vertexexpress` | Vertex AI Express: the Gemini surface on one global origin | `{"api_key"}` |
| [`volcengine_agent`](#volcengine-ark) | Volcengine Ark Agent Plan: Chat, Responses, Claude Messages, embeddings, images, video tasks and HTTP speech; plan quota | `{"api_key"}`, plus an IAM key pair for discovery and quota |
| [`volcengine_coding`](#volcengine-ark) | Volcengine Ark Coding Plan: Chat, Responses, Claude Messages and embeddings; plan usage | `{"api_key"}`, plus an IAM key pair for discovery and quota |
| `workbuddy` | Tencent Copilot through its editor plugin | OAuth |
| `xai` | xAI (Grok): OpenAI Chat and Responses, plus xAI's own TTS, STT and video | `{"api_key"}` |

### AI Studio Playground

`playground` uses a Google session from [AI Studio](https://aistudio.google.com/).
It supports Gemini generation, streaming, inline media, function calls and
model discovery. The API-key channel remains `aistudio`.

Google requires a WAA proof with every generation request. GPROXY generates
the proof in process: no separate signing service is needed, and the cookies
and request contents are not sent to a third party. The signer embeds QuickJS.

The first generation for an account initializes the signing environment and is
slower than the ones that follow.

#### Creating the provider

In the Console, create a provider with the channel **Google AI Studio
Playground**. No other configuration is needed.

The same through the admin API:

```sh theme={null}
curl -s -X POST http://127.0.0.1:8787/admin/api/providers \
  -H "Authorization: Bearer $GPROXY_KEY" -H 'content-type: application/json' \
  -d '{"name":"playground","channel":"playground"}'
```

By default the channel sends its requests with Firefox's TLS and HTTP/2
identity, which matches the browser environment the proof declares. A
connection profile set on the provider or the credential replaces this default
and is normally not needed.

#### Importing the cookies

1. Sign in to [AI Studio](https://aistudio.google.com/) in a browser, then open
   `www.google.com` once. Google issues the rotating session cookies at that
   point; without them GPROXY cannot rotate the session.
2. Return to the AI Studio page. In Cookie-Editor, export the site's cookies as
   JSON or Header, including HttpOnly cookies.
3. Optional: `LSID`, `__Host-1PLSID`, `__Host-3PLSID` and `__Host-GAPS`
   belong to `accounts.google.com` only. Cookie-Editor exports the current
   page's cookies and cannot reach them, and opening `accounts.google.com`
   redirects to `myaccount.google.com`. To include them, use an extension that
   exports across domains, such as
   [Cookie Editor](https://chromewebstore.google.com/detail/cookie-editor/dhdfnoenjedcedipmdoeibpnmpojjpce)
   by navbytes in the Chrome Web Store: in its cookie manager select
   `.google.com`, `.aistudio.google.com` and `accounts.google.com` and export
   them together as JSON. If you export them separately, paste the exports one
   after another; the import merges them into one credential. GPROXY sends
   these cookies only when it rotates the session; if step 1 issued the
   session cookies, rotation works without them.
4. In the provider's credentials, choose **Import credentials → Cookie-Editor /
   Cookie Header**, paste the export, and import. The entire cookie jar becomes
   one credential. To import several accounts at once, paste their exports one
   after another, or one Cookie header per line; each becomes its own
   credential. For another signed-in Google identity, import
   `{"cookies": [...], "auth_user": "1"}`; the default login index is `0`.

Test the credential from its details once, then add the provider to a model
route.

Import validates the session and discovers its subscription tier. While the
credential is enabled, GPROXY saves the cookies Google replaces in its
responses and rotates the session cookies about every 10 minutes, whether or
not requests arrive. Rotation does not restore a login that Google has signed out or
revoked: import fresh cookies in that case.
Files API references, Live WebSockets, batch jobs, and dedicated
speech/video configuration are not supported by this channel yet. Send media
as Gemini `inlineData` rather than `fileData`.

`countTokens` uses GPROXY's existing local tokenizer and returns `totalTokens`.
It does not call Google or generate a proof. The result is a local estimate and
may differ from Google's official count.

#### Common errors

| Symptom | Cause and action |
| - | - |
| Google answers 403 `The caller does not have permission` | Google refused the request. Open AI Studio in a browser with the same account and the same exit and send a message; if that fails too, the cause is the account or the exit, not GPROXY. |
| Google answers 503 `This model is currently experiencing high demand` | Google has no capacity for the model at the moment. Retry later or use another model. |

### Compatible vendors

A vendor that differs from a stock API only in its origin and headers does not
need its own channel. Configure it as a `custom` provider and list the wire
formats it speaks:

```json theme={null}
{ "name": "example-vendor", "channel": "custom",
  "baseUrl": "https://api.example-vendor.com",
  "config": { "dialects": ["openai_chat"] } }
```

A dedicated channel is written only when a provider row cannot express what
the vendor needs. NVIDIA NIM, Vercel AI Gateway and Cloudflare AI Gateway used
to be configured as `custom` providers; each now has a channel, which adds its
own authentication and balance queries, and should be preferred.

## Creating a provider

In the Console, open **Providers**, choose **New provider**, pick the channel,
fill in the name and the fields the channel's form shows, and **Save**. Then
add credentials (see [Credentials](#credentials)) and test one before you add
the provider to a model route.

The same through the admin API:

```sh theme={null}
curl -s -X POST http://127.0.0.1:8787/admin/api/providers \
  -H "Authorization: Bearer $GPROXY_KEY" -H 'content-type: application/json' \
  -d '{"name":"example-vendor","channel":"custom",
       "baseUrl":"https://api.example-vendor.com",
       "config":{"dialects":["openai_chat"]}}'
```

No restart is needed. A provider or credential write is committed in the same
transaction as the configuration revision bump, and the instance reloads its
own configuration before it notifies its peers, so the next request already
sees the change.

## Provider configuration

| Field | Meaning |
| - | - |
| `name` | The operator's label, unique. It is also the provider mount (`/{name}/...`) and the left half of the `provider/model` form. |
| `channel` | One of the channel ids above. |
| `baseUrl` | The upstream origin, for channels that take one. |
| `config` | The channel's own JSON. Each channel declares which keys it reads; `GET /admin/api/channels` lists them. |
| `connectionProfileId` | The outbound stack (proxy, TLS emulation) this provider's calls use. See [Connection profiles](#connection-profiles). |
| `enabled` | A disabled provider is left out of resolution. |

For `custom`, `config` carries `dialects` (the wire formats the endpoint
speaks), static `headers`, `allowed_headers` and the two magic-cache switches.
Channels that impersonate a vendor CLI set their own identity headers and do
not let a client override them.

The sections below describe the options of individual channels.

### Claude model fallback

`fallback_mode` is `off` (the default), `default` or `models`.
`fallback_models` is an ordered list of upstream model IDs. The Console renders
both fields from the channel descriptor. Blank entries, duplicates and the
primary model are skipped, and at most three fallback models are used.

How the fallback runs depends on the channel:

* Claude API, Claude Code and custom Claude endpoints send Anthropic's
  `fallbacks` field with the matching beta header. In `default` mode Anthropic
  chooses the fallback model.
* OpenRouter receives `fallbacks` for Claude Messages or `models` for Chat
  Completions, and runs the fallback itself. This does not change
  `provider.allow_fallbacks`, which controls supplier routing for the same
  model. If the client already sent `fallbacks` or `models`, the client's value
  is used. Responses requests get no fallback parameter, because OpenRouter
  documents none for them.
* Vercel, Azure, Vertex and AWS Bedrock: GPROXY itself retries a Claude
  `refusal` on the next configured model through the same credential, preparing
  and signing the request again. `default` mode selects `claude-opus-4-8` in
  the primary model's namespace. For cloud-specific model IDs, configure the
  full IDs that upstream accepts.

The gateway's fallback also applies to requests converted to Claude from
another protocol. It reacts only to refusals, not to arbitrary HTTP errors.
Streamed content is delivered as it arrives; once output has been sent, the
request can only continue if the upstream issued a credit with a prefill
claim, and a server tool is never replayed without a redeemable credit. Each
physical attempt is observed and priced separately by its own model, and a
refusal that reports zero output is not billed. The final response keeps the
top-level usage of the last attempt.

### Claude Code usage-limit modes

Two `claudecode` switches control what happens when the subscription runs
into its limits. Both default to `false`.

* `low_priority: true`: After a five-hour limit rejection, accept the lower-priority offer the server
  makes. The session then sends `anthropic-usage-limit: slow` until that window
  resets or the server ends the mode. Weekly limits and the separate
  lower-priority allowance still apply.

* `extended_usage: true`: Send `anthropic-usage-limit: extended` on tool-result continuations when paid
  extra usage is not known to be enabled. The server decides whether grace is
  available; it does not reset the subscription quota.

A client that sends `slow` or `extended` itself is honoured even with both
switches off; the two values are mutually exclusive. CountTokens and control
requests never carry the header. For clients other than Claude Code, a
tool-result message is what marks a continuation: the CLI's private task-depth
and experiment flags are not visible to the gateway.

While it is sending `slow`, GPROXY waits on `429 slot_busy` and overload
responses and retries the same buffered request on the same credential. As in
CLI 2.1.302, the default delay is 20 seconds with 30% jitter, and the default
maximum wait is 20 minutes. Server hints are clamped to 5–600 seconds per delay
and 1–360 minutes in total. The host deadline or a cancellation can end the
wait earlier. Budget, weekly-limit and eligibility refusals are returned
without retrying, and a response stream that has started, a body that cannot
be replayed, or an opaque fallback-credit redemption is never replayed.

The quota view also records the lower-priority and grace allowances the server
reports. They do not block normal traffic. An explicit mode exempts only the
subscription windows it applies to, for that request; local budgets, scoped
model limits and upstream failure or rate-limit cooldowns still apply.

### Claude Code client identity

`client_identity` selects which first-party client the `claudecode` channel
presents itself as. Both identities are the same CLI binary on the same OAuth
token.

* `cli` (default): The interactive CLI, `claude-cli/2.1.318 (external, cli)`. A valid CLI user
  agent and billing `cc_entrypoint` sent by the client are kept.

* `agent_sdk`: The Claude Agent SDK 0.3.318,
  `claude-cli/2.1.318 (external, sdk-ts, agent-sdk/0.3.318)`. A client's own
  Agent SDK user agent (`sdk-ts` or `sdk-py` with `agent-sdk/…`) is kept; any
  other is replaced. The billing block's `cc_entrypoint` follows the user
  agent, and the turn is marked as an SDK turn (`cc_turn_origin=sdk`,
  `cc_prompt_index=0`).

`identity_system_block: true` (default `false`) places the identity system
block directly after the billing block, matching the billing `cc_entrypoint`:
`You are Claude Code, Anthropic's official CLI for Claude.` for `cli`, and
`You are a Claude agent, built on Anthropic's Claude Agent SDK.` for `sdk-*`.
A client's own SDK identity, including the `running within the Claude Agent SDK`
variant, is kept. An identity block of the other kind is rewritten, and one is
inserted when the client sent none. With the switch off, the client's system
blocks are left as sent.

The billing checksum (`cch`), the `cc_version` suffix and `metadata.user_id`
are computed the same way for both identities. Anthropic may meter Agent SDK
traffic on a subscription separately from interactive use; the entrypoint is
what it reads to tell them apart.

### Antigravity identity

The `antigravity` channel always presents as the Antigravity hub (the
`antigravity --hub` process the IDE runs): the hub's user agent, `userAgent`,
`requestId`, `labels` and `sessionId`.

`agent_kind` selects which of the hub's agents a generation request presents
as. A `requestType` the client already put in the envelope is kept.

* `custom_agent` (default): A Markdown custom agent whose frontmatter sets
  `excludeDefaultComponents: true`. `requestType` is `custom_agent`, and the
  system instruction is only the client's own prompt, enclosed in
  `<System Prompt>` tags, with no Antigravity identity. The CLI imports Claude
  Code subagents the same way, keeping the body as the prompt, so any
  client's prompt fits this shape.
* `antigravity`: The built-in agent. `requestType` is `agent`, and the hub's
  identity block,
  `<identity>You are Antigravity, a powerful agentic AI coding assistant …</identity>`,
  opens the system instruction, as CLI 1.5.20 renders its
  `antigravity_identity` template. It is not added when the system
  instruction already carries that identity.

Either way, turns the user typed are enclosed in `<USER_REQUEST>` tags;
tool-result turns and text that already carries the tags are left alone. The
hub's `<ADDITIONAL_METADATA>` local time is not added. These shapes come from
an offline capture of CLI 1.5.20 (2026-12-01).

The body is also spelled the way the hub spells it, without changing what it
asks:

* Claude Code's `x-anthropic-billing-header:` line is removed from the system
  instruction.
* The system instruction is written as `systemInstruction` with
  `role: "user"`; several plain-text parts are joined into one, a line apart,
  and blank parts are dropped.
* `type` in a tool declaration's `parameters` is upper-cased (`OBJECT`,
  `STRING`). `parametersJsonSchema` is JSON Schema and keeps lower case.

### Per-operation URL overrides

`operation_endpoints` replaces the complete method URL for one
`(operation, dialect, transport)` on one provider. The URL is used as given;
it is not a base URL with the channel's default path appended. The channel
resolves its own path parameters for that method:

```sh theme={null}
curl -s -X POST http://127.0.0.1:8787/admin/api/operation-endpoints \
  -H "Authorization: Bearer $GPROXY_KEY" -H 'content-type: application/json' \
  -d '{"providerId":"…","operation":"generate_content","dialect":"openai_chat",
       "url":"https://elsewhere.example/v1/chat/completions"}'
```

For surfaces that put the model in the path, `{model}` in the URL is replaced
with the upstream model name, percent-encoded as a single path segment:
`https://relay.example/v1beta/models/{model}:generateContent`.

`operation_rules` overrides, per provider, what the channel does for an
operation. Channel defaults stay in code and are not copied into each new
provider, so a provider without overrides follows later changes to the
defaults. `POST /admin/api/providers/{id}/routing-defaults/reset` removes both
kinds of override in one commit.

### Gemini Interactions

The `aistudio` channel speaks two Gemini dialects: `gemini` (GenerateContent)
and `gemini_interactions` (the Interactions API). Both serve the
`generate_content` and `stream_generate_content` operations, but Interactions
has its own request shape, step events and response type.

Clients call `POST /v1beta/interactions` or `POST /v1/interactions`, with or
without a provider mount in front. `stream: true` gives native SSE.
`GET /interactions/{id}`, `POST /interactions/{id}/cancel` and
`DELETE /interactions/{id}` take the same version prefix, and query parameters
such as `stream` and `last_event_id` are passed through so that a client can
retrieve or resume a stream. An interaction id, and any
`previous_interaction_id` that refers to it, is only valid for the gateway
caller that created it and stays on the credential that created it. An
`agent` target goes through model routing and permission checks like a model
name, and the `agent` field is kept on the upstream request.

Responses, Chat Completions and Claude Messages convert to and from
Interactions directly, without stored state. To use it, set
`gemini_interactions` as the target dialect in the provider's operation
mappings, or create a `custom` provider that speaks only Interactions:

```json theme={null}
{ "channel": "custom", "baseUrl": "https://generativelanguage.googleapis.com",
  "config": { "dialects": ["gemini_interactions"] } }
```

Conversion covers function calls and results, signed thinking history, inline
images, and text and JSON output schemas. Interactions step signatures are
carried separately from GenerateContent signatures. Optional fields that
cannot be converted are reported as conversion diagnostics. File ids have to
be turned into inline data or URLs before the request.

Some features need an upstream that speaks Interactions natively: agents,
background execution, continuing a conversation stored in another dialect,
and an explicit `store: true`. When an Interactions client is converted to a
different upstream, send the full history with `store: false`; the response
id it gets back does not name an interaction stored upstream.

Native streaming is incremental. A stream that crosses protocols is collected
in full from the upstream first and then replayed as the client's events, so
it does not shorten the time to the first token. Polling and resumed
retrieval do not bill the cumulative usage a second time. Background work
whose creation response carries no usage is not reported by the gateway.

### Decisions

The `openai` channel serves OpenAI Decisions (`POST /v1/decisions`) and the
`aistudio` channel serves Gemini Decisions (`POST /v1beta/decisions`). Either
client can be routed to either upstream; the request and the answers are
converted, and the probabilities are those of the upstream model that
answered.

An OpenAI client on a Gemini upstream:

* Questions keep their order and names. A question with no name, or a name
  Gemini cannot use as a key, is sent under a placeholder and answered under
  its original name.
* Boolean choice values are sent as text and returned as booleans.
* A score level's `label` and `description` are sent as one description.
* Messages other than user messages, and tool calls with their outputs, are
  written out as text, because Gemini Decisions takes no conversation
  history.
* Images in question instructions are refused. Prompt-cache fields are
  dropped.

A Gemini client on an OpenAI upstream:

* The `criteria` of a yes/no question are appended to its instructions.
* Audio, video and document input, more than 10 score levels, and more than
  400 questions are refused.
* If the upstream refuses to answer one question, the whole request fails,
  because a Gemini answer has no refusal type.

### GLM

`glm` is the pay-as-you-go API and `glmcode` the GLM Coding Plan. Both take an
`api_key` credential and default to `https://open.bigmodel.cn`; global
accounts set `baseUrl: "https://api.z.ai"`. `glmcode` uses the plan's
dedicated Chat, Claude Messages and Responses endpoints and does not fall back
to paid API usage when the plan is exhausted.

Both model lists come from ZCode's live official catalogue: the channel
requests `/api/v1/client/configs`, downloads the returned
`builtin_provider_config_json`, and selects the regional platform API or
Coding Plan template. There is no bundled model list and no fallback to a
stale list if the download fails. The catalogue is the vendor's product list;
it does not prove that a given key may use every model in it.

`glmcode` reads `/api/monitor/usage/quota/limit` for the reported percentages,
the independent windows and their reset times. Platform `glm` does not yet
query the account balance.

### MiniMax

`minimax` defaults to `https://api.minimax.io`; accounts on the Chinese
platform set that platform's API origin. OpenAI Chat and Claude Messages accept
either a Subscription Key (Coding Plan / Token Plan) or a pay-as-you-go API key
in `api_key`. Model discovery and model details use the official `/v1/models`
and `/v1/models/{id}` endpoints. You can put the two kinds of key on separate
providers to route subscription text and paid video independently.

Following the official CLI, the quota query reads `/v1/token_plan/remains` or
`/account/query_balance` depending on the key type. The readings (and those
of `glmcode`) are for display; whether a credential is exhausted is decided by
the upstream's responses.

Video covers H3 V2 (`MiniMax-H3`, `MiniMax-H3-Max`) and requires a
pay-as-you-go API key. Submit GPROXY's OpenAI video extension JSON to
`/v1/videos`:

```json theme={null}
{
  "model": "MiniMax-H3",
  "prompt": "A cat running through a garden",
  "duration": 5,
  "resolution": "2K",
  "aspect_ratio": "16:9"
}
```

Query `/v1/videos/{id}` with the returned ID and download the finished video
from `/v1/videos/{id}/content`. `frame_images` sets first and last frames;
`input_references` supplies image, video and audio references. MiniMax's
native `content` is accepted too. Sora multipart, `seconds`, `size` and the
legacy Hailuo 2.x V1 endpoints are not supported.

Listing uses `page_num` and `page_size` (`limit` maps to `page_size`); the
`after` and `order` cursors are not supported. Deletion reports the upstream's
`action`: `cancelled` means a queued task was cancelled, `deleted` that a task
record was removed. The channel does not poll on its own and does not store
video files.

Sources: [ZCode catalogue implementation](https://github.com/zai-org/ZCode/blob/29628c9acdb81b703bbd4080c207a0e7ce5e276e/packages/provider-node/src/zcode-builtin-download.ts), [MiniMax official CLI](https://github.com/MiniMax-AI/cli), [GLM Coding Plan](https://docs.z.ai/devpack/tool/others), [MiniMax text](https://platform.minimax.io/docs/api-reference/text-anthropic-api), [MiniMax H3 V2](https://platform.minimax.io/docs/api-reference/video-generation-v2-create).

### OrcaTerm

`orcaterm` speaks the desktop LightAI protocol for text and image
conversations, with model-specific thinking settings. Create the provider,
then sign in through the browser or import an OAuth credential. Set
`international=true` for the international service; its account origin is
`https://orcaterm.ai` and its LightAI origin `https://lightai.tencentcloud.com`.

Images are sent as Base64 data URLs (PNG, JPEG, WebP or GIF), including images
in history and user messages that contain only an image. Oversized static
images are resized and compressed before upload, and an identical image reuses
the credential's earlier upload while its preview URL is still valid. The
available models and thinking levels come from the live model catalogue.
Request options the upstream does not support are ignored. Token counts are
local character estimates, marked as estimated and partial in metering; the
account quota reports AI question counts.

The client's terminal, file and web-fetch tools, where GPROXY recognises them,
are mapped onto OrcaTerm's native review/reportToolResult protocol. The
original client still executes each call under its own permission checks.
Tool continuations use the same provider, credential and model; registering
arbitrary functions is not supported. Answer text and tool arguments are
released after the agent has finished revising its response. Standalone web
requests from Codex use OrcaTerm's server-side search and fetch tools and
return their real results.

### Volcengine Ark

`volcengine_agent` (Agent Plan) and `volcengine_coding` (Coding Plan) share
one implementation and use the products' own paths (`/api/plan` and
`/api/coding`); they never fall back to the pay-as-you-go `/api/v3` endpoint.
Agent Plan needs its dedicated API key. Coding Plan personal uses a platform
API key with Coding Plan enabled; Coding Plan enterprise uses its seat API key.

Inference needs only `{"api_key"}`. Model discovery, quota and plan
information also need an IAM key pair in the same secret
(`access_key_id`, `secret_access_key`, optionally `session_token`). The key
pair is sent only to the control plane, and the API key only to inference.
Without the key pair, inference still works with manually configured model
rows.

`config.edition` is `personal` (default) or `enterprise`; enterprise quota
needs `seat_id` in the credential's metadata. The origins can be overridden
with the provider's base URL (default `https://ark.cn-beijing.volces.com`),
`config.control_base_url` (`https://ark.cn-beijing.volcengineapi.com`) and,
for Agent Plan speech, `config.speech_base_url`
(`https://openspeech.bytedance.com`). Agent credentials can set metadata
`allow_paid_usage: true` to keep routing past the subscription windows when
the account has postpaid usage enabled upstream.

## Credentials

A credential is one secret in a provider's pool: an API key, an OAuth token
set, or a browser session. In the Console, open the provider and use its
**Credentials** tab; through the API, `POST /admin/api/credentials` creates
one, and its batch endpoint creates several.

| Field | Meaning |
| - | - |
| `label` | Optional. When a login creates the credential, the label is derived from the channel and the account. |
| `authKind` | `api_key`, `oauth` or `cookie`: the type of the stored credential, independent of how it was obtained. |
| `secret` | The fields the channel declares. Never returned; a listing reports only `hasSecret`. |
| `organizationId` / `teamId` / `userId` | The owner: exactly one of them, or none for a shared credential. |
| `connectionProfileId` | Overrides the provider's outbound stack. |
| `expiresAtMs` | When the secret is due for refresh. |
| `status` | `active` or `dead`. A dead credential is no longer used. |
| `version` | The compare-and-swap guard under which a refresh writes. |

Secrets are sealed with AES-256-GCM under the master key. The seal is bound to
the row's own id, so a sealed blob copied onto another row cannot be opened.
Reading a secret back is a separate call, and it is audited:

```sh theme={null}
curl -s -X POST http://127.0.0.1:8787/admin/api/credentials/{id}/reveal \
  -H "Authorization: Bearer $GPROXY_KEY"
```

Without a master key, secrets are stored unencrypted. That is a supported
deployment; the binary logs it once at startup.

### Credential visibility

A credential is visible to a caller when it has no owner, or when its owner
matches the binding of the calling key: the key's own user, team, or effective
organization. The key's binding is used rather than the user's memberships
because a user can belong to two organizations while a key belongs to one. If
membership decided, every key of a user in several organizations would reach
every one of those organizations' subscriptions, and no key could be narrower
than its holder.

Visibility only removes credentials from the set a request may use; it never
adds any.

## Logging in to obtain a credential

Channels that hold an account rather than a key let you create the credential
by signing in to the upstream.

1. Open the provider's **Credentials** tab and choose **Add by signing in**.
2. For a browser (authorization code) login, open the authorization link,
   sign in, and paste the full callback URL from the browser's address bar
   back into the dialog.
3. For a device-code login, enter the displayed code on the vendor's page; the
   Console polls until the login completes.

The new credential appears in the list. See also
[Console administration](https://gproxy.leenhawk.com/guides/console.md#credentials-and-upstream-sign-in).

A channel offers one or both of these flows, reported as `loginModes` in
`GET /admin/api/channels`. Requesting a mode the channel does not offer is
refused.

Some channels also list `loginVariants`: named choices inside those flows,
each with an `id`, a `label` and the `mode` it runs. Kiro lists `github` and
`google` (device code) and `aws` (authorization code, Builder ID or IAM
Identity Center). Pass the chosen `id` as `variant` in the start request.
Without it the channel uses its provider configuration.

| Flow | Steps | For |
| - | - | - |
| Authorization code | start → complete | A browser redirect with PKCE |
| Device code | start → poll, repeatedly | A code typed on another device |

The four POST operations live under `/admin/api/credential-login`. The pending
login is bound to the user who started it and to that user's administrative
scope.

### Importing an existing credential

If you already have the token or cookie, import it with
`POST /admin/api/credentials` (or the batch endpoint) and initialise it with
`POST /admin/api/credentials/{id}/refresh`. The Console refreshes pending
imports after saving; if initialisation fails, the saved row stays and you can
retry from its details. Claude Web uses `authKind: "cookie"`; Claude Code and
OrcaTerm use `authKind: "oauth"`, including imports given as
`secret: {"cookie": "..."}`. Older kind labels are still read. Initialisation
and refresh store the secret, the expiry and optional public metadata together
under the version check, so no database migration or backfill is involved.

### How a login is protected

GPROXY generates and checks everything that is not the upstream's business.
The PKCE verifier is 32 random bytes generated locally and never sent; only
its S256 digest goes into the authorize URL, so an intercepted code is useless
without it. The CSRF state is also generated and compared locally. A state
that does not match is refused and destroys the pending session, so a replay
cannot be retried until it succeeds.

The pending session is kept in the shared cache, not in the process. Any
instance can therefore finish a login another instance started (behind a load
balancer that is the usual case), and an abandoned login leaves nothing
behind: its key expires, and an expired key looks the same as one that was
never issued.

A device poll performs one step and returns; the server does not sleep or
loop, and the caller does the polling. Each answer carries the interval to
wait, and an upstream `slow_down` raises it for all later polls.

A successful login is an ordinary credential insert through the same commit
path a management write uses. The secret is sealed before the statement is
built, so nothing between the channel and the database sees it in clear, and
the answer contains only the new credential's id.

### Refreshing a credential

Channels that hold OAuth tokens declare when a secret is due. A refresh returns
a complete replacement secret, not a partial update to merge. The host writes
it with a compare-and-swap on `version` and publishes a credential-changed
notice. To refresh by hand:

```sh theme={null}
curl -s -X POST 'http://127.0.0.1:8787/admin/api/credentials/{id}/refresh?force=true' \
  -H "Authorization: Bearer $GPROXY_KEY"
```

When the upstream definitively refuses the credential (`invalid_grant`, a
revoked token), the credential is marked dead. A transient transport error or
a 5xx does not mark it dead; it is reported as a transport error and the host
retries later.

The version check matters because Claude rotates the refresh token on every
refresh. If two refreshes raced and one write were lost, the stored refresh
token would already be invalid.

## Credential health and quota windows

When a request is resolved, disabled, retired and dead credentials are left
out. A blocked credential, one the upstream has rate-limited, is left out while
its provider still has an unblocked one. If every credential of a provider is
blocked, they are kept, and the provider is ordered after all healthy
providers, so that it is tried only when nothing else is available.

The admin API reports and resets this state per credential:

```sh theme={null}
# the quota windows the upstream reports for this credential
curl -s http://127.0.0.1:8787/admin/api/credentials/{id}/quota -H "Authorization: Bearer $GPROXY_KEY"
# query the upstream now
curl -s -X POST http://127.0.0.1:8787/admin/api/credentials/{id}/quota-probe -H "Authorization: Bearer $GPROXY_KEY"
# redeem a quota reset (only vendors that sell them)
curl -s -X POST http://127.0.0.1:8787/admin/api/credentials/{id}/quota-reset -H "Authorization: Bearer $GPROXY_KEY"
# clear the recorded health state
curl -s -X POST http://127.0.0.1:8787/admin/api/credentials/{id}/health-reset -H "Authorization: Bearer $GPROXY_KEY"
# the operator limits that apply to this credential
curl -s http://127.0.0.1:8787/admin/api/credentials/{id}/limits -H "Authorization: Bearer $GPROXY_KEY"
```

`POST /admin/api/credentials/{id}/status` sets `active` or `dead` by hand,
with a reason.

## Connection profiles

A connection profile is the outbound stack a call uses: the proxy, and the TLS
and HTTP/2 identity it presents. The profile is chosen from the credential
first, then the provider, then the channel's own default, then the instance
default.

The identity presets can be stored as a profile's `emulation`:

```sh theme={null}
curl -s http://127.0.0.1:8787/admin/api/tls-presets -H "Authorization: Bearer $GPROXY_KEY"
```

Six presets reproduce vendor CLIs:

```text theme={null}
claude / Claude CLI    codex / Codex CLI       gemini / Gemini CLI
antigravity            kiro / Kiro CLI         copilot / GitHub Copilot CLI
```

The list also contains one `wreq:{profile}` preset for each browser and HTTP
client profile the emulation library ships (Chrome, Edge, Firefox, Safari,
Opera, OkHttp).

Only the `wreq` transport presents an emulated identity. A channel that
impersonates a CLI supplies its own default profile; an explicit profile on
the credential or the provider still takes precedence.

## Testing a provider

Two kinds of management call reach outside the process: the connectivity test
and the model test with discovery.

### Connectivity test

The connectivity test asks Cloudflare's trace endpoint how this deployment
looks from outside, through the client chain the scope selects:

```sh theme={null}
curl -s -X POST http://127.0.0.1:8787/admin/api/connectivity/test \
  -H "Authorization: Bearer $GPROXY_KEY" -H 'content-type: application/json' \
  -d '{"scope":"global"}'
```

```json theme={null}
{"ok":true,"latencyMs":803,"ip":"223.166.167.192","colo":"LAX","error":null}
```

The scope is `global`, `{"scope":"provider","provider_id":"…"}`,
`{"scope":"credential","credential_id":"…"}` (the same transport that
credential's calls use), or `{"scope":"proxy","url":"…"}` for a proxy that is
not configured anywhere yet. A network failure is reported as `ok: false` with
a reason, not as an HTTP error, since an unreachable upstream is a valid
result of the test.

### Model test and discovery

Model test and discovery run through the engine in the same way as a caller's
request:

```sh theme={null}
curl -s -X POST http://127.0.0.1:8787/admin/api/models/test \
  -H "Authorization: Bearer $GPROXY_KEY" -H 'content-type: application/json' \
  -d '{"providerId":"…","model":"gpt-4o-mini"}'

curl -s -X POST http://127.0.0.1:8787/admin/api/models/discover \
  -H "Authorization: Bearer $GPROXY_KEY" -H 'content-type: application/json' \
  -d '{"providerId":"…"}'
```

> [!WARNING]
>
> Both calls use a real credential: they consume upstream quota, are settled
> against any budget that applies to the credential, and write a usage row.
> There is no dry-run mode, because a test that does not call the upstream would
> not test anything.

Discovery asks in the provider's own dialect, so the model names are the
upstream's. Each result says whether the provider already has a row for the
model and whether the bundled catalogue can price it.
`POST /admin/api/models/discover/apply` inserts the models you select and
skips those that already exist.

## Request header allow-lists

By default, client request headers are not forwarded upstream. Settings →
Network holds the global request-header allow-list, and each provider can add
names with `config.allowed_headers`. The effective set is the union of the
global list, the provider's list and the channel's defaults, plus
`content-type`. A missing or empty list adds nothing.

Source credentials and hop-by-hop headers are removed even when listed.
Authentication the channel injects and the static `headers` in `config` are
not affected by this policy. Changes take effect on the next configuration
reload; the provider's saved list is not rewritten with the merged result.

## Moving configuration

```sh theme={null}
gproxy export --out config.json --include-secrets
gproxy import --in  config.json --mode merge --source-master-key '…'
```

An export carries the configuration of the deployment: connection profiles,
providers, credentials, the model catalogue, routing, operation overrides,
rewrite rules, quotas, pricing and the settings row. It does not carry
identity (users, keys, organizations, teams, permissions and subscriptions
belong to the product layer), and it does not carry usage or captures, which
would otherwise appear as history the destination never had. See
[Configuration](https://gproxy.leenhawk.com/reference/configuration.md#moving-a-configuration) for the
master-key rules.


## Related topics

- [Architecture](https://gproxy.leenhawk.com/development/architecture.md)
- [Console](https://gproxy.leenhawk.com/guides/console.md)
- [Models and routes](https://gproxy.leenhawk.com/guides/models.md)
- [Cloudflare Workers, Netlify, and Vercel](https://gproxy.leenhawk.com/deployment/lite.md)
- [Channel Catalogue](https://gproxy.leenhawk.com/reference/channel-catalog.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.