Thanks to visit codestin.com
Credit goes to github.com

Skip to content

docs: add standalone AI Gateway docs - #27592

Merged
pawbana merged 9 commits into
mainfrom
pawel/aigov-322-update-documentation-about-standalone-gateway-deployment
Jul 29, 2026
Merged

docs: add standalone AI Gateway docs#27592
pawbana merged 9 commits into
mainfrom
pawel/aigov-322-update-documentation-about-standalone-gateway-deployment

Conversation

@pawbana

@pawbana pawbana commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Documents standalone AI Gateway deployment, Gateway key authentication, monitoring, and the updated embedded vs standalone topology in the AI Gateway docs.

@pawbana
pawbana requested a review from a team as a code owner July 28, 2026 15:03
@linear-code

linear-code Bot commented Jul 28, 2026

Copy link
Copy Markdown

AIGOV-322

@pawbana
pawbana requested a review from johnstcn July 28, 2026 15:03
@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

@coderagents

coderagents Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Documentation Check

Reviewed through 77c1a680 (docs: review 1 fixes, branch rebased onto current main).

Updates Needed

  • docs/admin/infrastructure/architecture.md - "hold no state" is now "hold no durable state" (:146) and the stray double blank line is gone.
  • docs/ai-coder/ai-gateway/reference.md - the new OpenAI route lists double the version segment. OpenAI.RoutePrefix() already includes /v1 (aibridge/provider/openai.go:71-74), and the routes registered on top of it are /chat/completions, /responses, /conversations(/), /models(/), /responses/ (:77-96). Relative to the stated base URL https://ai-gateway.example.com/openai/v1, the listed /v1/chat/completions, /v1/models(/*), /v1/responses/*, /v1/conversations(/*) resolve to /openai/v1/v1/.... Drop the /v1 from the OpenAI entries, or state that OpenAI paths are relative to the provider root. Anthropic (anthropic.go:104-118) and Copilot (copilot.go:80-99) entries are correct as written.
  • docs/ai-coder/ai-gateway/reference.md - two smaller precision issues in the same section: the path segment is the provider name, which defaults to the type, so /openai and /anthropic are only the default-name examples; and "Any route that is not listed above returns 404" (aibridge/bridge.go:196-199) needs a carve-out for the standalone listener's /healthz and /readyz (enterprise/cli/aigatewaystart.go:478-490).
  • docs/ai-coder/ai-gateway/monitoring.md - the rewritten "Capture logs in traces" section is now incorrect. Trace.CaptureLogs / CODER_TRACE_LOGS is declared and registered but never read (codersdk/deployment.go:1042, :3165-3174; no other non-test reference). Log capture is attached whenever clilog.Builder.Trace is true, which comes from vals.Trace.Enable (cli/clilog/clilog.go:88, :143-145), including for the standalone process (enterprise/cli/aigatewaystart.go:134). So: setting CODER_TRACE_LOGS=true has no effect, CODER_TRACE_ENABLE=true alone already captures logs, leaving CODER_TRACE_LOGS unset does not opt out, and the Honeycomb-only path creates spans (cli/server.go:2874-2879) but never sets b.Trace, so it emits no log events. The "recording spans only" statement is accurate (coderd/tracing/slog.go:21-26).
  • docs/admin/infrastructure/validated-architectures/index.md - the chart README link added at :134 uses an absolute https://github.com/coder/coder/blob/main/... URL. The style guide requires relative paths for non-docs repo locations (docs/.style/style-guide/formatting.md:379-383), and this PR already links the same file relatively from standalone.md:109 and monitoring.md:136,150. Use ../../../helm/ai-gateway/README.md. The same applies to the blob/main link to coderd/aibridged/proto/version.go in reference.md:49.
  • docs/ai-coder/ai-gateway/standalone.md - still confirm the "Coder v2.36.0 or later" prerequisite and the 2.36.0 chart example against the actual release train. The newest tag in the tree is still v2.35.3.
  • docs/ai-coder/ai-gateway/standalone.md - the "returns HTTP 503 for any new client request" claim was corrected to the blocking behavior, matching Server.ClientContext (coderd/aibridged/aibridged.go:174-186).
  • docs/ai-coder/ai-gateway/reference.md - AI budget checks added to the control-connection list, matching Authorizer.IsBudgetExceeded (coderd/aibridged/proto/aibridged.proto:33-39).
  • docs/ai-coder/ai-gateway/clients/index.md - standalone base URL form added.
  • docs/admin/integrations/prometheus.md - standalone listener and scrape-discovery gap documented, coder_ai_gateway_cost_control_* marked coderd-only, and the stale forbidden key-pool reason removed from both the generated table and scripts/metricsdocgen/metrics.
  • docs/ai-coder/ai-gateway/setup.md - per-replica API dumps and the coderd-only structured logging note added to the linked target sections.
  • docs/ai-coder/ai-gateway/providers.md - seeding scoped to coderd, per-replica provider reloads noted.
  • docs/install/kubernetes.md - "Standalone AI Gateway Chart" section added.
  • docs/admin/infrastructure/validated-architectures/index.md - AI Gateway sizing guidance added; chart specifics now deferred to the chart README (see the link-style item above).
  • helm/ai-gateway/README.md - pre-rebrand aibridgeproxyd name removed.

Verified accurate in the new commit: the OpenAI-serves-azure/google/openai-compat/openrouter/vercel and Anthropic-serves-bedrock mappings (cli/aibridged.go:250-313), the legacy /v1/completions not-passed-through note (openai.go:84-87), the Anthropic and Copilot route sets, and the new clients/index.md cross-link.


Automated review via Coder Agents

@pawbana
pawbana force-pushed the pawel/aigov-322-update-documentation-about-standalone-gateway-deployment branch from 3e7e013 to 5cff57c Compare July 28, 2026 17:07

@johnstcn johnstcn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

Comment on lines +130 to +135
run as a [standalone deployment](../../../ai-coder/ai-gateway/standalone.md)
that scales independently of the control plane. The standalone Helm chart
requests 1 vCPU and 1 GiB of memory per replica, sets no limits. It ships
without a HorizontalPodAutoscaler nor a PodDisruptionBudget. Size replicas from
your own AI request volume and `CODER_AI_GATEWAY_MAX_CONCURRENCY`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to become stale quickly. Just link to the README.md for the Helm chart.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated.

Comment thread docs/admin/infrastructure/architecture.md Outdated
Comment thread docs/ai-coder/ai-gateway/auth.md Outdated
No separate AI Gateway login or credential is required.
that a user uses for the rest of the Coder API.
No separate AI Gateway login is required for client traffic.
For token creation, expiration, and revocation, refer to [Sessions and API tokens](../../admin/users/sessions-tokens.md).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does AI Gateway check token scopes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When starting the process or when Gateway connects to coderd, no. Only Gateway key is required for connection.

When authenticating users it re-uses the same method as embedded, scope is not checked, only that key exists and user is not deleted / is active / is not a system user:

func (s *Server) IsAuthorized(ctx context.Context, in *proto.IsAuthorizedRequest) (*proto.IsAuthorizedResponse, error) {
//nolint:gocritic // AIBridged has specific authz rules.
ctx = dbauthz.AsAIBridged(ctx)
var (
keyID string
keySecret string
// delegated requests skip the secret check: the caller never
// has the secret. Trust is established at the in-process
// transport boundary, not in this RPC.
delegated bool
)
switch {
case in.GetKey() != "" && in.GetKeyId() != "":
return nil, ErrAmbiguousAuth
case in.GetKeyId() != "":
keyID = in.GetKeyId()
delegated = true
default:
var err error
keyID, keySecret, err = httpmw.SplitAPIToken(in.GetKey())
if err != nil {
return nil, ErrInvalidKey
}
}
// Key exists.
key, err := s.store.GetAPIKeyByID(ctx, keyID)
if err != nil {
s.logger.Warn(ctx, "failed to retrieve API key by id", slog.F("key_id", keyID), slog.Error(err))
return nil, ErrUnknownKey
}
// Key has not expired.
now := dbtime.Now()
if key.ExpiresAt.Before(now) {
return nil, ErrExpired
}
// Key secret matches (skipped for delegated callers).
if !delegated && !apikey.ValidateHash(key.HashedSecret, keySecret) {
return nil, ErrInvalidKey
}
// User exists.
user, err := s.store.GetUserByID(ctx, key.UserID)
if err != nil {
s.logger.Warn(ctx, "failed to retrieve API key user", slog.F("key_id", keyID), slog.F("user_id", key.UserID), slog.Error(err))
return nil, ErrUnknownUser
}
// User is active, not deleted, and not a system user.
if user.Deleted {
return nil, ErrDeletedUser
}
if user.Status != database.UserStatusActive {
return nil, ErrInactiveUser
}
if user.IsSystem {
return nil, ErrSystemUser
}
return &proto.IsAuthorizedResponse{
OwnerId: key.UserID.String(),
ApiKeyId: key.ID,
Username: user.Username,
}, nil
}

Comment on lines +212 to +222
For example, if the Gateway is reachable at `https://ai-gateway.example.com` and the providers are configured, configure Claude Code with:

```sh
ANTHROPIC_BASE_URL=https://ai-gateway.example.com/anthropic
```

Configure an OpenAI-compatible client with:

```sh
OPENAI_BASE_URL=https://ai-gateway.example.com/openai/v1
```

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to set ANTHROPIC_AUTH_TOKEN=${CODER_TOKEN} / OPENAI_API_KEY=${CODER_TOKEN} / etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph is only about how to reach the Gateway. I'm not sure about adding whole configuration here. Better examples are in clients docs, eg: https://github.com/coder/coder/blob/5d2a69d85a2e47b37d1369fe77809cf348c7e161/docs/ai-coder/ai-gateway/clients/claude-code.md

I could add link to that part of documentation, something like "For full configuration examples refer to [docs/ai-coder/ai-gateway/clients/index.md]".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds good to me!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added link.

Comment thread docs/admin/infrastructure/architecture.md Outdated
Comment thread docs/manifest.json Outdated
Comment on lines +94 to +96
Each [standalone Gateway](./standalone.md) replica accepts the same API dump
settings and writes dumps to its own local disk.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it also support the YAML config form, or just the CLI flag and environment variable?

@pawbana pawbana Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, ai-gateway start command doesn't have -c --config flag so it is not possible to use YAML config.
Created followup issue.

Comment thread docs/ai-coder/ai-gateway/standalone.md Outdated
Comment thread docs/ai-coder/ai-gateway/monitoring.md Outdated
@pawbana
pawbana force-pushed the pawel/aigov-322-update-documentation-about-standalone-gateway-deployment branch from 0978e40 to 77c1a68 Compare July 29, 2026 15:28
@pawbana
pawbana requested a review from johnstcn July 29, 2026 15:30
@pawbana
pawbana merged commit 18128b7 into main Jul 29, 2026
31 of 32 checks passed
@pawbana
pawbana deleted the pawel/aigov-322-update-documentation-about-standalone-gateway-deployment branch July 29, 2026 17:38
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants