Skip to content

docs: add Regional endpoints page (Global + US) for the inference API - #58

Open
sejori wants to merge 1 commit into
mainfrom
docs/cor-585-regional-endpoints
Open

docs: add Regional endpoints page (Global + US) for the inference API#58
sejori wants to merge 1 commit into
mainfrom
docs/cor-585-regional-endpoints

Conversation

@sejori

@sejori sejori commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

What

Adds a Regional endpoints page at /inference-api/regional-endpoints covering:

  • The two regions: Global (served by api.doubleword.ai) and US (served by api.us.doubleword.ai), each with its own console, accounts, keys, and credits.
  • API keys are region-bound and carry no region prefix, so a key's region cannot be read off the key string.
  • A wrong-region key surfaces as a plain 401 (same response as an invalid key) — with the exact error body the API returns.
  • Guidance to pair every key with its base URL, plus a triage checklist for unexpected 401s.
  • The region badge shown in the US console header as the way to tell consoles apart.

This page is the link target of the control-layer 401 copy change (doublewordai/control-layer#1541), which points users here instead of enumerating base URLs in the error body.

How

Doc content normally lives in Sanity (AGENTS.md), but this page's URL is now part of the API's error-copy contract, so the content is version-controlled in-repo and rendered through the same pipeline as the synthesized model pages:

  • src/lib/regional-endpoints.ts — page content + metadata (new).
  • src/app/[product]/[...slug]/page.tsx — static param, metadata, and content hooks (mirrors the models special-case).
  • src/app/api/markdown/[product]/[...slug]/route.ts — serves /inference-api/regional-endpoints.md.
  • src/lib/inference-api-sidebar.ts — sidebar entry anchored beside "Creating an API Key" under Using the Platform.
  • src/app/sitemap.ts — sitemap entry.

If the page is later migrated into Sanity under the same slug, the sidebar and page route already prefer the Sanity version; the hooks can then be removed.

Not included: an llms.txt entry (that route iterates Sanity docs directly; can follow when/if the page moves to Sanity).

Verification

  • ESLint: clean on all changed files (the 25 pre-existing problems on main are unchanged).
  • Vitest: same result as main (the one pre-existing search.test.ts stripMarkdown failure exists on main and is unrelated).

Status

HELD per release policy — do not merge yet. The control-layer 401 copy (doublewordai/control-layer#1541) links to this page's URL; this PR should merge as part of the coordinated release.

The dwctl wrong-region 401 copy links to
/inference-api/regional-endpoints, so the page content is
version-controlled here next to that URL contract rather than in Sanity.
It renders through the same pipeline as the synthesized model pages:
static param + content override in the doc page route, the .md endpoint,
a sidebar entry anchored beside Creating an API Key, and a sitemap
route. A Sanity page with the same slug takes over if one is created
later.
Copilot AI lite review requested due to automatic review settings August 28, 2026 14:46
@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
documentation Ready Ready Preview Aug 28, 2026 2:47pm

Request Review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new version-controlled, in-repo documentation page at /inference-api/regional-endpoints describing Global vs US Inference API regions (base URLs, consoles, region-bound API keys, and wrong-region 401 behavior). This extends the existing “synthesized page” pattern used for model artifacts so the URL/content can be treated as part of an external error-copy contract.

Changes:

  • Introduces src/lib/regional-endpoints.ts with the page slug/title/description and the synthesized markdown body.
  • Hooks the synthesized page into the main doc route (page.tsx) and the raw markdown endpoint (/api/markdown/...) so both HTML and .md variants work.
  • Adds navigation + indexing integration via the inference API sidebar organizer and the sitemap.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/lib/regional-endpoints.ts Defines the synthesized “Regional endpoints” page slug/metadata and its markdown content.
src/app/[product]/[...slug]/page.tsx Adds static params + metadata + content resolution hook for the synthesized regional-endpoints page.
src/app/api/markdown/[product]/[...slug]/route.ts Serves /inference-api/regional-endpoints.md from the synthesized markdown source.
src/lib/inference-api-sidebar.ts Injects the synthesized page into the inference-api sidebar (anchored near “Creating an API Key”), unless a Sanity page exists for the slug.
src/app/sitemap.ts Adds the synthesized page to the generated sitemap.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

sejori added a commit to doublewordai/control-layer that referenced this pull request Aug 29, 2026
…#1541)

## What

Rewrites the `Invalid API key` 401 copy so a key rejected because it was
created in the other region no longer reads as "your key is broken". The
message now suggests checking that the request's base URL matches the
region the key was created in, and links the regional-endpoints docs
page:

> Invalid API key. API keys are region-bound: if you expected this key
to work, check that your base URL matches the region the key was created
in. See https://docs.doubleword.ai/inference-api/regional-endpoints

Status code (401) and error schema (`authentication_error` /
`invalid_api_key`) are unchanged.

## Where

- `dwctl/src/errors.rs`: new shared `INVALID_API_KEY_MESSAGE` constant
so the copy cannot drift between surfaces.
- `dwctl/src/api/handlers/ai_models.rs`: the `GET /ai/v1/models`
unknown-key 401 (the first endpoint people hit when smoke-testing a
key).
- `dwctl/src/auth/current_user.rs`: the `CurrentUser` extractor's
unknown-bearer-key rejection, which gates every other
dwctl-authenticated surface. The extractor previously accumulated
per-method auth errors but always returned a message-less generic 401
("Authentication required"), so the specific copy never reached the
client; it now propagates the first specific failure message (API-key
auth is attempted first).
- `dwctl/src/openapi/ai.rs`: the documented error example, kept in sync
with the live copy.

The realtime proxy path (onwards) is deliberately untouched: it rejects
unknown keys with a 403 key-set miss, so changing it would not be a
copy-only 401 change.

## Notes

The error body intentionally does **not** enumerate regional base URLs —
it stays generic and defers to the docs page, which pairs each key with
its base URL. The docs page ships in doublewordai/documentation#58 (held
until release).

Tests assert the new copy on both surfaces and that no regional API base
URL appears in the error body.

COR-585
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants