[AI Gateway] Add wrangler auth token hint to cURL examples#31406
[AI Gateway] Add wrangler auth token hint to cURL examples#31406superhighfives wants to merge 4 commits into
Conversation
The cURL code examples in the AI Gateway docs reference $CLOUDFLARE_API_TOKEN and $CF_AIG_TOKEN but never tell readers how to mint one. Surface 'Run `wrangler auth token` to get an auth token to replace $CLOUDFLARE_API_TOKEN for use with the API.' in two places per page so readers hit it whichever way they read the block: - A shared partial (partials/ai-gateway/auth-token-hint.mdx) linking to the wrangler CLI reference, rendered once above the first cURL block on each affected page. - An inline shell comment as the first line inside every cURL block, so the hint survives copy-paste. The token name in the comment matches whichever env var the block uses ($CLOUDFLARE_API_TOKEN or $CF_AIG_TOKEN). Covers 31 cURL blocks across 11 pages: get-started, REST API reference, caching, unified billing, logging, the Workers tutorial, custom providers, custom metadata, request handling, authentication, and the Workers AI provider page. Companion change in the Cloudflare dashboard: https://gitlab.cfdata.org/cloudflare/fe/stratus/-/merge_requests/39025
Review⏸️ Automatic reviews for this PR are paused. This PR has already received 2 automatic reviews. To run another review, a codeowner can comment
✅ No style-guide issues found in commit CommandsOnly codeowners can run commands. Post a comment with the command to trigger it.
|
|
This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:
|
There was a problem hiding this comment.
Pull request overview
Adds a reusable “how to get a token” hint to AI Gateway docs so readers can quickly obtain an auth token for the cURL examples, and annotates relevant cURL snippets with an inline reminder.
Changes:
- Added a new partial (
auth-token-hint.mdx) linking towrangler auth token. - Rendered the partial above the first relevant cURL block on each affected AI Gateway doc page.
- Added a leading shell comment to each cURL snippet that references
$CLOUDFLARE_API_TOKENor$CF_AIG_TOKEN.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/content/partials/ai-gateway/auth-token-hint.mdx | New shared hint snippet linking to wrangler auth token. |
| src/content/docs/ai-gateway/usage/rest-api.mdx | Imports/uses the hint partial and adds token reminder comments to multiple cURL examples. |
| src/content/docs/ai-gateway/usage/providers/workersai.mdx | Renders the hint partial and adds token reminder comment to the Workers AI cURL example. |
| src/content/docs/ai-gateway/tutorials/create-first-aig-workers.mdx | Renders the hint partial within the tutorial flow and adds token reminder comment to the cURL example. |
| src/content/docs/ai-gateway/observability/logging/index.mdx | Renders the hint partial and adds token reminder comments to logging-related cURL examples. |
| src/content/docs/ai-gateway/observability/custom-metadata.mdx | Updates imports, renders the hint partial, and adds token reminder comment to the metadata cURL example. |
| src/content/docs/ai-gateway/get-started.mdx | Renders the hint partial and adds token reminder comments to getting-started cURL examples. |
| src/content/docs/ai-gateway/features/unified-billing.mdx | Updates imports, renders the hint partial, and adds token reminder comments to Unified Billing cURL examples. |
| src/content/docs/ai-gateway/features/caching.mdx | Updates imports, renders the hint partial, and adds token reminder comments to caching cURL examples. |
| src/content/docs/ai-gateway/configuration/request-handling.mdx | Renders the hint partial and adds a token reminder comment to the timeout cURL example. |
| src/content/docs/ai-gateway/configuration/custom-providers.mdx | Updates imports, renders the hint partial, and adds token reminder comments across custom provider API cURL examples (incl. $CF_AIG_TOKEN blocks). |
| src/content/docs/ai-gateway/configuration/authentication.mdx | Imports/uses the hint partial and adds token reminder comment to the example request. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Review for PR #31406Title: [AI Gateway] Add wrangler auth token hint to cURL examples What changedThis PR improves the AI Gateway documentation by helping readers understand how to generate the auth tokens referenced in cURL examples. It introduces:
The token name in each inline comment correctly matches the env var used in that block ( Validation results
Issues flaggedLine highlight off-by-one in The Expressive Code block at line 38 uses Everything else looks good
Suggested labels
|
The previous commit added a second shell-comment line (`wrangler whoami`) without preserving the 3-space indent the block needed to stay inside its parent numbered-list item. That broke the code fence: the second comment and the cURL body spilled out as plain MDX, the closing fence became four backticks, and the next code block on the page got its own fences mangled. Restore the indent so the entire block sits inside the list-item code fence.
- Fix line-highlight `{4}` -> `{6}` in configuration/request-handling.mdx
so the highlight still points to the `cf-aig-request-timeout` header
after the two-line shell comment shifted everything down. Flagged by
Copilot and the docs-bot reviewer.
- Expand the auth-token-hint partial and the inline shell comments to
also cover `wrangler whoami` for the account ID, mirroring the pattern
in the cURL blocks.
The AI Gateway cURL code examples reference
$CLOUDFLARE_API_TOKEN/$CF_AIG_TOKENbut never tell readers how to mint one. This surfaceswrangler auth tokenin two places per page so readers hit it whichever way they read the block.This pairs with a dashboard change that adds the same hint to the AI Gateway in-app code examples: stratus!39025 (AIG-1220).
What changed
src/content/partials/ai-gateway/auth-token-hint.mdxwith one sentence linkingwrangler auth tokento the wrangler CLI reference.# Run \wrangler auth token` to get an auth token to replace $TOKEN for use with the API.shell comment as the first line inside every cURL block that references one of the two env vars (31 blocks). The token name in each comment matches the block —$CLOUDFLARE_API_TOKENfor most blocks,$CF_AIG_TOKENfor the two blocks inconfiguration/custom-providers.mdx` that use the per-gateway auth header.Pages touched
ai-gateway/get-started.mdxai-gateway/usage/rest-api.mdxai-gateway/configuration/custom-providers.mdxai-gateway/configuration/authentication.mdxai-gateway/configuration/request-handling.mdxai-gateway/features/caching.mdxai-gateway/features/unified-billing.mdxai-gateway/observability/custom-metadata.mdxai-gateway/observability/logging/index.mdxai-gateway/tutorials/create-first-aig-workers.mdxai-gateway/usage/providers/workersai.mdxOut of scope
configuration/custom-providers.mdxthat only reference$PROVIDER_API_KEYor$INTERNAL_API_KEY(not Cloudflare-issued tokens) — these aren't replaced bywrangler auth token.production— left alone to keep this diff focused.View AI session