# PRime usage guide (prime) > Written for people and agents. The URLs and values below are for this stage only. ## Overview The PRime serves Amazon Bedrock models in Tokyo (ap-northeast-1) through an **OpenAI-compatible API**. Call the Lambda Web Function with your `aau-sk-…` key. Published SDKs can continue using compatibility `POST /v1/connect`, which returns the web origin. The gateway picks the model, applies key and team limits, caches prompts, and records usage and cost. This guide is for the **prime** stage. The values below apply to this stage only. | Item | Value | | --- | --- | | Stage | `prime` | | Gateway URL | `https://gateway.prime.megazone.com` | | Connect endpoint | `POST https://gateway.prime.megazone.com/v1/connect` | | Authentication | `Authorization: Bearer aau-sk-…` | | Management console (keys) | `https://admin.llmgateway.prime.megazone.com` (local development console) | | Region | `ap-northeast-1` (Amazon Bedrock) | | Endpoints | Web function: `POST /v1/messages`, `/v1/chat/completions`, `/v1/responses`, `/v1/embeddings`, `/v1/jev` · `GET /v1/models` · SDK compatibility `/v1/connect` | | This guide as Markdown | `https://admin.llmgateway.prime.megazone.com/llms.txt` (English), `https://admin.llmgateway.prime.megazone.com/llms-ko.txt` (한국어) | > Keys belong to one stage: a prod key does not work here. LLM clients never call the management API (`https://rri26701uc.execute-api.ap-northeast-2.amazonaws.com/prime`); it is for the console only. ## 1. Get an API key Click a key name or prefix in the key list, or a key name in a dashboard, to open its dedicated dashboard at `/api-keys/`. Subscription keys show lifetime Claude Code/Codex tokens and subscription/Bedrock usage; standard keys show billed spend, budgets and limits in a separate component. Both show this key’s 7/30/90-day usage and performance, including revoked/expired history. Owners can view their own keys; admins can also view other owners’ keys. Choose a **subscription key** (`aau-sk-personal-` prefix) for Claude Code and Codex. One key works with both clients; usage combines by user and distinguishes each client. Use a standard key (`aau-sk-`) for general API calls. Subscription keys require the subscription routes in section 7; Bedrock calls are not allowed. Assign up to 20 tags per key, such as `prod`, `project:aau`, and `team:platform`. Search keys by tag, group personal usage by tag or tag/client, or filter the dashboard by tag. Current tags also apply to historical usage. Multi-tag keys contribute to each tag, so tag totals overlap. Tags do not change access permissions or billing scope. 1. Sign in to the management console (`https://admin.llmgateway.prime.megazone.com`) with Google. A new account can be used after an admin approves it. 2. On **API keys**, create a key. Organization members must choose the organization/team that pays for it. 3. You can set allowed models, the default `auto` strategy, a monthly or weekly budget with its reset day, a requests-per-minute limit, and an expiry. Standard users get class defaults and maximums and can only tighten an existing key. 4. The full key (`aau-sk-` plus 40 characters) is shown **once**. Store it as a secret (environment variable, Secrets Manager); never in code or a repository. **Environment** ```bash export AAU_API_KEY="aau-sk-..." # your key export GATEWAY_URL="https://gateway.prime.megazone.com" ``` ## 2. How calls work (Lambda Web Function) **Flow** ```text client → https://gateway.prime.megazone.com/v1/chat/completions | messages | responses | jev → Lambda Web Function → Bedrock / TypeSafe ``` The production gateway serves every API on a Lambda Web Function, behind its own CloudFront distribution and Route 53 domain. No MicroVM pool or ingress token is needed. - For general APIs use the OpenAI SDK with the base URL plus `/v1`. Personal-key Claude Code and Codex use the subscription routes in section 7. - Published Python SDKs keep working. Compatibility `/v1/connect` returns one web endpoint and empty `headers`; it never creates a MicroVM. - Keepalive is unnecessary. `/health/liveliness` accepts legacy SDK pings as a compatibility endpoint. - The request limit is 15 minutes. Streams include heartbeats. For long non-streamed calls use the raw web origin returned as `/v1/connect` base_url to avoid CloudFront idle timeouts. **Connection response for published SDKs** ```json { "object": "gateway.connection", "runtime": "lambda-web-function", "microvm_id": "web-function", "base_url": "https:///v1", "headers": {}, "expires_at": "", "microvms": [ { "microvm_id": "web-function", "base_url": "https:///v1", "headers": {}, "expires_at": "" } ], "pool_refresh_seconds": 300 } ``` > Browser CORS preflight is supported. API keys are secrets; do not embed them in public web apps. ## 3. API reference | Method · path | Description | | --- | --- | | `POST https://gateway.prime.megazone.com/v1/connect` | SDK compatibility connection: web `base_url`, empty headers, `expires_at` | | `POST /chat/completions` | OpenAI Chat Completions: streaming, tools, images, automatic prompt caching | | `POST /responses` | OpenAI Responses API | | `POST /embeddings` | OpenAI Embeddings on Titan and Cohere Embed models. See the embeddings section | | `GET /models` | Enabled models and `auto` aliases the key may use | | `GET /health/liveliness` | Optional legacy SDK health check (no key, not billed) | | `POST https://gateway.prime.megazone.com/v1/jev` | TypeSafe Jev typed questions (call the gateway URL directly, no connect). See the Jev section | **Chat Completions request fields** (standard OpenAI fields plus gateway fields): | Field | Description | | --- | --- | | `model` | Required. A model alias (e.g. `claude-sonnet-5`), a registered Bedrock ID, or `auto`, `auto:balanced`, `auto:cheap`, `auto:quality`, `auto:jev` | | `messages` | Required. OpenAI messages (text, `image_url` and `file` parts; files as base64 data URL `file_data`: PDF, Word, Excel, CSV, HTML, text, Markdown) | | `max_tokens` / `max_completion_tokens` | Output cap. **It sizes the team-allowance reservation, so ask only for what you need.** GPT models need at least 16 | | `stream` | `true` for SSE; a final usage chunk is always included | | `tools`, `tool_choice` | OpenAI tool calling. `auto` skips models without tool support | | `fallbacks` | Aliases to try if an explicit model fails (gateway extension) | | `cache_control` | `false` (no caching) or `{"type":"ephemeral","ttl":"5m"\|"1h"}` (gateway extension; in OpenAI SDKs use `extra_body`) | | `aau_region` | Preferred Bedrock region (e.g. `ap-northeast-2`); same as the `x-aau-region` header, which wins. See the regions section (gateway extension) | **Sampling parameters:** the gateway forwards `temperature`, `top_p` and `stop` to Bedrock as sent. A model that does not accept one **does not ignore it**: Bedrock rejects the request with `400 bedrock_validation` and the model does not run (for example "`temperature` is deprecated for this model."). This error does not move on to `fallbacks` or `auto` fallbacks. Other OpenAI parameters (`seed`, `n`, `presence_penalty`, `frequency_penalty`, `logit_bias`, `logprobs`, `response_format`, ...) are not forwarded, so they are ignored without an error and have no effect. | Models | `temperature` | `top_p` | Both | | --- | --- | --- | --- | | Claude Sonnet 5 · 5.5, Opus 4.7 · 4.8 · 5 · 5.5, Haiku 5.5 | Rejected | Rejected | Rejected | | Claude Sonnet 4.6, Opus 4.5 · 4.6, Haiku 4.5 | Accepted | Accepted | Rejected (send only one) | | OpenAI GPT-5.4 and later (`gpt-5.x`, `gpt-6.x`), Grok 4.6, Kimi K3 | Rejected | Rejected | Rejected | | gpt-oss, DeepSeek, Qwen, Mistral/Ministral/Devstral, Amazon Nova, Gemma, GLM, MiniMax, Nemotron, Kimi K2.x | Accepted | Accepted | Accepted | > Table checked directly against Bedrock in Tokyo on 2026-11-25. New models or versions may differ: call once with the parameter before relying on it. `auto` can pick a different model per request, so `temperature` sent with `auto` may land on a model that rejects it. **When the same input must give the same result:** - Pin a model alias instead of `auto`. A different model changes both the result and the parameters it accepts. - On a model that accepts `temperature`, send `temperature: 0`; send nothing to a model that rejects it. Even `0` does not guarantee identical output. - Take verdicts as fixed choices, not free text: force the shape with a tool call (`tools` + `tool_choice`), or use `POST /v1/jev` (section 9) for classification and pass/fail checks. - If the same input need not be judged again, store the result by input hash and reuse it. ## 4. Choosing a model | `model` value | Behaviour | | --- | --- | | A model alias or registered Bedrock ID | **Exactly that model.** Fallbacks only if you send `fallbacks` | | `auto` | The key's default strategy (`balanced` unless changed) | | `auto:balanced` | Default model, then balanced, quality, fast tiers | | `auto:cheap` | Cheapest model the key may use | | `auto:quality` | Quality, then balanced, then fast tiers | | `auto:jev` | TypeSafe Jev rates the latest user message and picks cheap / auto / quality (experimental) | - `auto` routes skip models that cannot serve the request (no tools or images, context too small) and add up to two fallbacks. - List what you may use with `GET /models`; it reflects the key's allowlist and team policy. - The response `model` field is the name you sent (e.g. `auto`); the model that served it is in the `x-litellm-model-name` response header. - Jev (`jev`) is not a chat model: it never appears in the model list or chat routing. Call it only with `POST /v1/jev`. - Embedding models (e.g. `titan-embed-text-v2`) answer only `POST /v1/embeddings`, and `auto` routing never picks them. In the model list their `aau.apis` is `["embeddings"]`. ## 5. Quick start **Python (OpenAI SDK + aau_llm_gateway)** ```python from aau_llm_gateway import openai_client # install: section 6 (pip install "...[openai]") import os client = openai_client("https://gateway.prime.megazone.com", os.environ["AAU_API_KEY"]) # openai.OpenAI -compatible; connects and refreshes for you reply = client.chat.completions.create( model="auto", max_tokens=512, messages=[{"role": "user", "content": "Hello"}], ) print(reply.choices[0].message.content) # async: from aau_llm_gateway import async_openai_client ``` **cURL** ```bash CONN=$(curl -s -X POST "https://gateway.prime.megazone.com/v1/connect" -H "Authorization: Bearer $AAU_API_KEY") BASE=$(echo "$CONN" | jq -r .base_url) AUTH=$(echo "$CONN" | jq -r '.headers["X-aws-proxy-auth"]') PORT=$(echo "$CONN" | jq -r '.headers["X-aws-proxy-port"]') curl "$BASE/chat/completions" \ -H "Authorization: Bearer $AAU_API_KEY" -H "X-aws-proxy-auth: $AUTH" -H "X-aws-proxy-port: $PORT" \ -H "Content-Type: application/json" \ -d '{"model": "auto", "max_tokens": 256, "messages": [{"role": "user", "content": "Hello"}]}' ``` **TypeScript / Node (OpenAI SDK, streaming)** ```typescript import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://gateway.prime.megazone.com/v1", apiKey: process.env.AAU_API_KEY }); const stream = await client.chat.completions.create({model:"auto:cheap", max_tokens:512, stream:true, messages:[{role:"user",content:"Summarize this in one line: ..."}]}); for await (const chunk of stream) process.stdout.write(chunk.choices[0]?.delta?.content ?? ""); ``` > Region, routing and admission errors return machine-readable `error.code` values. Authentication and older responses may use numeric codes; also check the HTTP status and `type`. ## 6. Agents (Strands) For agents, use `AauGatewayModel` from the Python client `aau-llm-gateway-client`. It is a drop-in replacement for Strands' `BedrockModel` and supports streaming, tools and metering through the web function. Use `mode="proxy"` to call it without discovery. `aau-llm-gateway-client` is **not on public PyPI.** Build the wheel from the private GitHub repository `https://github.com/mzc-ai-architect/aau-llm-gateway-client`. If you cannot open it, ask your gateway administrator for read access for your GitHub account. Building needs Git, Yarn and [uv](https://docs.astral.sh/uv/). **Install** ```bash git clone https://github.com/mzc-ai-architect/aau-llm-gateway-client.git cd aau-llm-gateway-client && yarn build # dist/aau_llm_gateway_client--py3-none-any.whl # Pick the newest wheel, whatever its version WHEEL=$(ls dist/aau_llm_gateway_client-*-py3-none-any.whl | sort -V | tail -n 1) pip install "$WHEEL[strands]" # [openai] if you only need the OpenAI helper ``` **uv** ```toml # pyproject.toml (uv) — Vendor the wheel inside the app folder (AgentCore CodeZip installs built wheels only) # mkdir -p vendor && cp "$WHEEL" vendor/ [project] dependencies = ["aau-llm-gateway-client[strands]"] [tool.uv.sources] # Replace with the version of the wheel you copied to vendor/ (uv paths take no wildcards) aau-llm-gateway-client = { path = "vendor/aau_llm_gateway_client--py3-none-any.whl" } ``` **Environment** ```bash # credentials.env / .env (never commit a real key) AAU_LLM_GATEWAY_URL=https://gateway.prime.megazone.com AAU_LLM_GATEWAY_API_KEY=aau-sk-... # or pass api_key= in code AAU_LLM_GATEWAY_MODE=proxy AAU_LLM_GATEWAY_MODEL=auto # or claude-sonnet-5, auto:cheap, auto:jev ... AAU_LLM_GATEWAY_MAX_TOKENS=8000 # default max_tokens; larger values reserve more team allowance ``` **Python (Strands)** ```python import os from strands import Agent from aau_llm_gateway.strands import AauGatewayModel def load_model(): # Use the gateway when its URL and key are set; otherwise call Bedrock directly if AauGatewayModel.configured(): return AauGatewayModel.from_env() from strands.models.bedrock import BedrockModel return BedrockModel(model_id=os.getenv("MODEL_ID", "global.anthropic.claude-sonnet-5")) agent = Agent(model=load_model(), tools=[...]) print(agent("Summarize the request briefly")) # or build it explicitly model = AauGatewayModel( gateway_url="https://gateway.prime.megazone.com", api_key=os.environ["AAU_LLM_GATEWAY_API_KEY"], model_id="auto:balanced", mode="proxy", params={"max_tokens": 8000, "extra_body": {"cache_control": {"type": "ephemeral", "ttl": "1h"}}}, ) ``` | Variable | Meaning | Default | | --- | --- | --- | | `AAU_LLM_GATEWAY_URL` | Gateway URL | required | | `AAU_LLM_GATEWAY_MODE` | Set proxy to call the web function directly | `proxy` | | `AAU_LLM_GATEWAY_API_KEY` | `aau-sk-…` key; or pass `api_key=` from wherever your application keeps it | required | | `AAU_LLM_GATEWAY_KEEPALIVE_SECONDS` | Legacy SDK ping interval (set 0 on web functions) | `60` | | `AAU_LLM_GATEWAY_MODEL` | Model or `auto*` alias | `auto` | | `AAU_LLM_GATEWAY_MAX_TOKENS` | Default `max_tokens` | model default | > Do not pass `openai_client_args(...)` to Strands' `OpenAIModel` as `client_args`: Strands closes that client after the first call and the second call fails. Use `AauGatewayModel`. ## 7. Codex and Claude Code **Subscription keys allow subscription mode only.** Sign in to Codex with your ChatGPT subscription and Claude Code with your Claude subscription. Bedrock API requests with subscription keys return `403 personal_key_subscription_only`; subscription failures never fall back to Bedrock. | Client | Base URL | Login | | --- | --- | --- | | Codex CLI / exec / Desktop | https://gateway.prime.megazone.com/subscription/codex | ChatGPT | | Claude Code CLI / Desktop | https://gateway.prime.megazone.com/subscription/claude | Claude | **1. Download the setup script** — install Node.js 18 or later and create a subscription key (`aau-sk-personal-…`) in the console. **Windows PowerShell** ```powershell Invoke-WebRequest 'https://admin.llmgateway.prime.megazone.com/tools/aau-gateway-setup.mjs' -OutFile aau-gateway-setup.mjs $env:AAU_LLM_GATEWAY_API_KEY = 'aau-sk-personal-...' [Environment]::SetEnvironmentVariable('AAU_LLM_GATEWAY_API_KEY', $env:AAU_LLM_GATEWAY_API_KEY, 'User') ``` **macOS / Linux** ```bash curl -fsS 'https://admin.llmgateway.prime.megazone.com/tools/aau-gateway-setup.mjs' -o aau-gateway-setup.mjs export AAU_LLM_GATEWAY_API_KEY='aau-sk-personal-...' ``` > The Windows command persists the key in your user environment for newly started apps. On macOS/Linux, set the same variable in the environment used to launch the app. Codex reads the key from the environment. **2. Configure Codex CLI, exec and Desktop** — first sign in with ChatGPT using `codex login`. This command backs up the files and changes the default provider, so Desktop uses it too. ```bash codex login node aau-gateway-setup.mjs --gateway-url https://gateway.prime.megazone.com --mode subscription --codex --codex-model gpt-6.1-sol ``` > **Fully quit and reopen Codex Desktop.** A running app/chat may retain its previous configuration. Adding `--codex-profile aau-subscription` creates a CLI profile and leaves the Desktop default provider unchanged. Use `codex --profile aau-subscription` or `codex --profile aau-subscription exec ...` for that profile. **Manual setup** — set the top-level model/provider and provider block in `~/.codex/config.toml` (Windows: `%USERPROFILE%\.codex\config.toml`). If existing chats use provider `aau`, retain that ID and update its block. Remove `env_key` and keep your ChatGPT login. **~/.codex/config.toml** ```toml model = "gpt-6.1-sol" model_provider = "aau" [model_providers.aau] name = "AAU subscription gateway" base_url = "https://gateway.prime.megazone.com/subscription/codex" wire_api = "responses" requires_openai_auth = true env_http_headers = { "X-AAU-Personal-Key" = "AAU_LLM_GATEWAY_API_KEY" } stream_idle_timeout_ms = 300000 ``` **3. Configure Claude Code CLI** — sign in to your subscription with `claude auth login`, then run this command. The Claude Desktop Code tab also needs the separate Gateway profile in section 7.1 below. ```bash claude auth login node aau-gateway-setup.mjs --gateway-url https://gateway.prime.megazone.com --mode subscription --claude-code ``` Claude ANTHROPIC_AUTH_TOKEN, ANTHROPIC_API_KEY, apiKeyHelper and Bedrock/Vertex/Foundry overrides must not replace subscription authentication. Setup backs up files and removes those settings; clear inherited shell overrides yourself. X-AAU-Personal-Key carries the AAU key and Authorization carries provider login. AAU does not store provider tokens. **4. Verify ```bash codex exec "Reply exactly pong." claude -p "Reply exactly pong." ``` Click the key name in the console and verify access mode subscription. Request, token, cache, error and performance statistics distinguish Claude Code CLI/Desktop and Codex CLI/exec/Desktop. Earlier Bedrock records remain as history. Requests without identifying markers have an unknown variant. The key dashboard subscription account panel lists all observed accounts sharing the key and provider-reported plans, usage percentages and resets. Five-hour/weekly windows appear only when reported; they are never estimated from tokens. New subscription requests update snapshots; dashboard refresh reads the latest saved snapshot. Limits cover the whole account, including usage outside the gateway. | Error | Fix | | --- | --- | | 403 personal_key_subscription_only | A subscription key called a Bedrock route. Apply subscription setup and restart the app. | | 401 subscription_login_required | Refresh your ChatGPT/Claude subscription login. Provider API keys are not accepted. | | 403 personal_key_required | Subscription routes require a subscription key. | | 403 subscription_region_policy_unsupported | Provider subscriptions cannot guarantee required AWS region policies. Contact your administrator. | | 429 | Check provider subscription limits or AAU request limits and wait for reset/retry time. | Company Bedrock setup with a standard key (`aau-sk-`) remains available using --mode bedrock. Subscription keys cannot use that option. With mode omitted, subscription keys select subscription and standard keys select Bedrock. See the official [Codex ChatGPT login through a gateway](https://developers.openai.com/codex/enterprise/sign-in-with-chatgpt-through-a-gateway) documentation. ## 7.1 Claude Desktop with your subscription **These steps were verified with the Claude Desktop Code tab on Windows.** CLI settings alone do not configure Desktop: it needs a separate Gateway profile. This setup forwards your own Claude subscription authentication through AAU using a subscription key and records usage in AAU. It is separate from Bedrock mode and does not fall back to Bedrock on subscription errors. 1. Create a subscription key (`aau-sk-personal-…`) in the console and download the section 7 setup script first. Install Node.js 18 or later and sign in to the Claude Code CLI with your subscription. 2. Configure CLI subscription mode below first. Replace the example key with your own; do not paste provider OAuth tokens. Clear any shell ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN overrides. **Windows · PowerShell** ```powershell $env:AAU_LLM_GATEWAY_API_KEY = 'aau-sk-personal-...' node .\aau-gateway-setup.mjs --gateway-url https://gateway.prime.megazone.com --mode subscription --claude-code claude auth login ``` **1. Install or update the tracked Desktop helper** — fully quit Desktop, then run these commands. The helper verifies the provider profile using the actual CLI OAuth token and supplies account and selected-organization markers to AAU. Personal Pro/Max and Team/Enterprise stay separate. AAU does not store OAuth credentials or raw account/organization IDs. **Windows · PowerShell** ```powershell Invoke-WebRequest 'https://admin.llmgateway.prime.megazone.com/tools/aau-desktop-credentials.cjs' -OutFile .\aau-desktop-credentials.cjs node .\aau-desktop-credentials.cjs --install node "$env:USERPROFILE\.claude\aau-desktop-credentials.cjs" --check ``` Installation updates the helper and Desktop Gateway profile and backs up existing files and profile selection in the printed backup directory. Reopen Desktop afterward. Normal helper output contains credentials: never paste it into logs or chat. --check prints only verification status and the actual subscription type. Repeat the same download/install commands to update. **2. Select personal or Team subscription** — Desktop Gateway mode has no ordinary Team selector. Run claude auth login, choose the intended personal or company organization, verify pro/max/team/enterprise with --check, and restart Desktop. Team organization type takes precedence even when its seat has a Max rate tier. Token rotation preserves the account/organization history; switching organizations creates a separate entry. > Desktop third-party mode uses a separate local profile. Existing ordinary Claude conversations and login are retained; switch back to that profile to access them if needed. Organization-managed settings can override local configuration; contact your administrator in that case. Adjust the explicit model list to models your subscription supports; model discovery is disabled on this subscription route. **3. Inspect the gateway and verify a real request** 1. Reopen Desktop. Click Open in the Gateway in use banner, or open inference configuration from the bottom-left user / Gateway menu. If unavailable, enable Developer Mode under Help → Troubleshooting, then use Developer → Configure Third-Party Inference…. Confirm the Gateway URL below. 2. In the Code tab select an empty test folder and send: `Reply exactly aau-desktop-gateway-ok. Do not read or change files or run tools.` Verify attribution in the next step as well as the response. 3. Check that subscription key’s usage records in the AAU console: the same key UUID, client `claude-code`, access mode `subscription`, and status 200. Click the key name to open its dedicated dashboard. **Gateway URL** ```text https://gateway.prime.megazone.com/subscription/claude ``` **Usage and remaining allowance:** Desktop’s usage settings show device token statistics, not remaining subscription percentage. Generic provider-billing text does not establish Bedrock billing; verify `subscription` in AAU. The AAU key dashboard shows the last provider-reported account quota percentages and resets. New subscription requests update snapshots; unreported windows are unavailable. Sign in to [Claude subscription usage](https://claude.ai/settings/usage) with the same account to see five-hour/weekly limits and resets. Allowances are shared across conversations and devices; token totals may also differ in cache accounting. While visible, key dashboards reload recorded usage and quotas every 30 seconds and on returning to the tab; this does not make new provider requests. Unidentified history from before helper installation stays separate because it may contain multiple subscriptions. Only the latest provider snapshot supplies current limits; personal and Team allowances are never combined. > The helper automatically refreshes expired or nearly expired CLI OAuth tokens, saves rotated credentials to the CLI login file and verifies the selected subscription profile again. Personal Pro/Max and Team/Enterprise remain separate. Run claude auth login only if no refresh token exists or the provider rejects refresh. A provider 429 may indicate subscription or model limits: resolve the provider error and retry without switching to Bedrock. **4. Revert whenever needed** — fully quit Desktop, replace the path below with the backup folder printed in step 2, run, and reopen. This restores the previous profile selection without deleting conversations or login. It affects Desktop only; use section 7’s backup/disable instructions separately for CLI settings. **Windows · PowerShell** ```powershell $backup = 'C:\Users\YOUR_USER\.claude\aau-desktop-backup\SAVED_BACKUP_ID' Copy-Item -LiteralPath (Join-Path $backup '_meta.json') -Destination (Join-Path $env:LOCALAPPDATA 'Claude-3p/configLibrary/_meta.json') # Reopen Desktop; choose ordinary Claude sign-in if prompted. ``` See [Anthropic Desktop configuration](https://claude.com/docs/third-party/claude-desktop/configuration) for configuration fields and managed policy behavior. The helper and AAU subscription route above are AAU-specific integration steps. ## 8. Regions (data residency) Every model is invoked in Tokyo (`ap-northeast-1`) by default, and most are cross-region inference profiles (`global.`, `apac.`), so AWS computes them wherever it has capacity. Some models also have a **regional deployment**: a model ID that runs on-demand inside another region, such as Seoul (`ap-northeast-2`). | Setting | Behaviour | | --- | --- | | Request header `x-aau-region: ap-northeast-2` (or body field `aau_region`) | **Preference**: models with a Seoul deployment run inside Seoul; the others are invoked from Tokyo as usual (cross-region profiles compute outside one region anyway) | | Team or organization policy "Data region" | **Requirement**: only models that run inside the region are served; others get `403 region_unavailable`, and `auto` chooses among the in-region ones | - Supported regions: `ap-northeast-1` (Tokyo, default) and `ap-northeast-2` (Seoul). Anything else is `400 unsupported_region`. - Which regions a model can run in is listed in `aau.regions` of `GET /models`. - A regional deployment is billed at that region's price; usage rows record the region actually invoked in `bedrock_region`. - Proxy and direct responses carry `x-aau-region: ; compute=in-region|cross-region` for the serving model, including after a fallback. **Python client** ```python from aau_llm_gateway import async_openai_client from aau_llm_gateway.strands import AauGatewayModel client = async_openai_client(GATEWAY_URL, AAU_API_KEY, region="ap-northeast-2") # OpenAI SDK, direct mode model = AauGatewayModel(gateway_url=GATEWAY_URL, api_key=AAU_API_KEY, model_id="auto", region="ap-northeast-2") # or AAU_LLM_GATEWAY_REGION=ap-northeast-2 with AauGatewayModel.from_env() ``` ## 9. TypeSafe Jev (typed questions) Jev does not generate text: it **answers typed questions about a `state` with probabilities**. It is far cheaper than a chat model for classification, routing, triage and scoring ($0.042 per million input tokens; output is free). The same `aau-sk` keys, limits and usage records apply. Call the gateway URL directly; no `/v1/connect` is needed. | Type | `criteria` | Answer | | --- | --- | --- | | `noul` | Optional: `{"true": "…", "false": "…"}` | `noul`: probability of yes (0-1) | | `choice` | Option label → description (2-255) | `choice`, `confidence`, `probabilities` | | `score` | Array of levels, lowest first (2-10) | `score` (may fall between levels), `legend`, `probabilities`, `confidence` | **cURL** ```bash curl "https://gateway.prime.megazone.com/v1/jev" \ -H "Authorization: Bearer $AAU_API_KEY" -H "Content-Type: application/json" \ -d '{ "state": "Hi, I was charged twice for my October invoice and need a refund today.", "questions": { "urgent": {"type": "noul", "instructions": "Does the customer need a response today?"}, "team": {"type": "choice", "instructions": "Which team should handle this ticket?", "criteria": {"billing": "Payments, refunds", "technical": "Bugs, login problems"}}, "anger": {"type": "score", "instructions": "How upset is the customer?", "criteria": ["Calm", "Frustrated", "Very angry"]} } }' ``` **Response** ```json { "model": "jev-1.14.0", "answers": { "urgent": {"type": "noul", "noul": 0.95}, "team": {"type": "choice", "choice": "billing", "confidence": 1.0, "probabilities": {"billing": 1.0, "technical": 0.0}}, "anger": {"type": "score", "score": 0.62, "confidence": 0.43, "legend": {"0": "Calm", "1": "Frustrated", "2": "Very angry"}, "probabilities": {"0": 0.38, "1": 0.62, "2": 0.0}} }, "usage": {"input_tokens": 409, "output_tokens": 68} } ``` - `state` may be a string, object or array (up to about 32k tokens). Send an object to refer to fields by name. - 1-32 questions per request; ids use letters, digits, `_`, `-`, `.`. Each question is judged independently. - Omit `model` or send `"jev"` for the default version (`jev-1.14.0`). To choose a version, send a version ID from the table below. - Errors: 400 `invalid_jev_request` (gateway checks), 422 `jev_validation_error` (TypeSafe), 403 `model_not_allowed`, 429, 503 `jev_unavailable`, 504 `jev_timeout`. Rejected calls are not billed. - Jev is weak at arithmetic, counting and date comparison. Ask what the content *decides*, not whether it *mentions* something. | `model` in the request | Version used | | --- | --- | | Omitted, `null`, `"jev"` | Default: the registered TypeSafe model (`jev-1.14.0`) | | `"jev-1.14.0"` | Jev 1.14.0 (2026-10-14, better multilingual answers) | | `"jev-1.13.0"` | Jev 1.13.0, for callers whose thresholds were tuned on it | | Anything else (including `"jev-latest"`, `"jev-preview"`) | 404 `model_not_found`. The message lists the available versions; nothing is billed. | - Versions are chosen by pinned ID only: moving aliases such as `jev-latest` are refused so answers cannot change when TypeSafe ships a release. Re-check your thresholds when moving from 1.13 to 1.14. - Key and team model allowlists, limits and prices apply to the alias `jev`, so choosing a version needs no extra permission. The version used is in the response `model`, the `x-aau-provider-model` header and the usage record. - Admins set the default version on the Models page by changing the provider model ID of the TypeSafe Jev model. ## 9.1 Embeddings (`/v1/embeddings`) Create vectors for RAG, search and similarity with the OpenAI-compatible `POST /embeddings`. OpenAI SDKs, LangChain `OpenAIEmbeddings` and similar clients work unchanged, with the same `aau-sk` keys, limits and usage records. There are no output tokens; only input tokens are billed. | Model alias | Per million input tokens | Notes | | --- | --- | --- | | `titan-embed-text-v2` | $0.029 | 8,192 tokens per text; `dimensions` 1024 (default), 512, 256; normalized vectors | | `cohere-embed-multilingual-v3` | $0.10 | Multilingual (including Korean), 1024 dimensions, 512 tokens per text (longer text is truncated) | | `cohere-embed-english-v3` | $0.10 | English, 1024 dimensions, 512 tokens per text | | `cohere-embed-v4` | $0.12 | Multilingual; `dimensions` 1536 (default), 1024, 512, 256; long texts | **Python (OpenAI SDK)** ```python import os from openai import OpenAI client = OpenAI(base_url="https://gateway.prime.megazone.com/v1", api_key=os.environ["AAU_API_KEY"]) result = client.embeddings.create( model="titan-embed-text-v2", input=["희림 건축 법규 검토", "building code review"], dimensions=512, ) vectors = [item.embedding for item in result.data] ``` **cURL** ```bash curl "https://gateway.prime.megazone.com/v1/embeddings" \ -H "Authorization: Bearer $AAU_API_KEY" -H "Content-Type: application/json" \ -d '{"model":"cohere-embed-multilingual-v3","input":["검색할 문장"],"input_type":"search_query"}' ``` | Field | Description | | --- | --- | | `model` | Required. An embedding model alias. `auto` is not accepted: vectors from different models are not comparable | | `input` | A string or an array of up to 2048 non-empty strings | | `dimensions` | Optional. Titan V2 and Cohere v4 only | | `encoding_format` | `float` (default) or `base64` | | `input_type` | Cohere only (gateway extension): `search_document` (default) for stored documents, `search_query` for queries, or `classification`, `clustering` | - Embed stored documents and queries with **the same model and `dimensions`**. - Errors: 400 `auto_not_supported`, `not_an_embedding_model`, `dimensions_not_supported`, `invalid_input`, 403 `model_not_allowed`, 429. Rejected calls are not billed. ## 10. Prompt caching Requests to Claude models are **prompt-cached automatically** (cache points after the tools, after the system prompt, and on the latest message). An agent that re-sends its conversation each turn reads most of it from the cache at about a tenth of the input price. | Send | Effect | | --- | --- | | Nothing | Automatic caching | | `"cache_control": {"type": "ephemeral", "ttl": "5m" \| "1h"}` | Automatic caching with that TTL | | `"cache_control": false` | No caching; markers are removed | | `cache_control` on your own messages, parts or tools | Forwarded as is; the gateway adds none (at most 4) | > Cache points are added only for Claude and Amazon Nova models. Other models such as OpenAI GPT (Sol, Terra, Luna, ...) and Grok are cached **implicitly** by Bedrock and reject explicit cache points, so the gateway removes them. Cache reads are billed at the cache-read price of the model. - **Keep the prefix byte-identical.** Do not put timestamps or request ids in the system prompt. - Sonnet-class models need about 1,024+ tokens to cache. Entries expire after 5 minutes (or 1 hour) without a hit. - Check Chat response `prompt_tokens_details.cached_tokens` for cache reads; writes are recorded in usage dashboards. Messages uses Anthropic cache fields, and Responses reports provider cache usage. - Billing: 1-hour cache writes are charged at the 1-hour write price of the model (2x input for Claude), 5-minute writes at the write price. Some models (for example Claude Sonnet 4/4.5 above 200k and GPT-5.x above 272k prompt tokens) charge every token of a request at a higher long-context rate; `GET /v1/models` does not list these tiers; the model registry in the console does. ## 11. Limits and billing | Limit | When exceeded | | --- | --- | | Key budget (monthly/weekly, resets 00:00 KST) | `429 insufficient_quota` | | Key requests per minute (fixed one-minute window) | `429 rate_limit_exceeded` with `retry-after` | | Key allowed models (fallbacks too) | `403 model_not_allowed` | | Organization/team shared cost, token, request caps | `429 shared_allowance_exceeded` | | Organization/team shared requests per minute | `429 rate_limit_exceeded` | | Expired, revoked or temporarily disabled key, disabled owner | `401 expired_api_key`, `401 revoked_api_key`, `403 disabled_api_key`, `403 user_disabled` | | Request time | Up to 900 seconds (15 minutes) per HTTP request, including one stream; this does not cap the whole agent session | | CloudFront idle timeout | Up to 60 seconds before the first response or between chunks. Heartbeats run every 15 seconds once streaming starts. Use the raw web origin returned by connect for long silent non-streamed requests | | Codex and Claude Code usage (section 7) | Zero internal billed cost. Company resource cost consumes key, monthly user and shared funding limits. Per-minute limits apply | - Keys under team caps **reserve the worst case** (input size + `max_tokens`) per request and settle the real cost afterwards (within about a minute). Lower `max_tokens` when the remaining allowance is small. - A team cap is a ceiling inside the parent organization's balance, not extra money. Every ancestor's limits apply. - Cost is estimated from registry prices; it is not the AWS bill. ## 12. Errors and retries Errors use the OpenAI format: `{"error": {"message", "type", "code", "param"}}`. | Status | `code` | Meaning · action | | --- | --- | --- | | 400 | `invalid_json`, `messages_required`, `model_required` | Malformed request; fix it | | 400 | `tools_not_supported`, `vision_not_supported`, `no_eligible_model` | The model cannot serve it; use `auto` or another model | | 400 | `unsupported_region` | A region the gateway does not serve; **do not retry** | | 403 | `region_unavailable`, `region_not_allowed`, `region_policy_conflict` | Team data-region policy: the model does not run inside the required region, or another region was asked for; **do not retry** | | 401 | `missing_api_key`, `invalid_api_key`, `revoked_api_key`, `expired_api_key` | Key problem; **do not retry** | | 403 | `model_not_allowed`, `disabled_api_key`, `user_disabled` | Not permitted; **do not retry** | | 404 | `model_not_found` | Unknown or disabled model | | 429 | `insufficient_quota`, `shared_allowance_exceeded` | Budget or allowance spent; **do not retry** | | 429 | `rate_limit_exceeded` | Per-minute limit; retry after `retry-after` seconds | | 503 / 504 | `gateway_upstream_unavailable`, `gateway_capacity_unavailable`, `upstream_timeout` | Transient; retry with backoff | | 400 | `bedrock_validation` | Bedrock rejected the request and the model **did not run**. Usually a parameter the model does not accept (table in section 3). Read the Bedrock text in `message` and fix the request; **do not retry** | | 403 / 404 | `bedrock_access_denied`, `bedrock_resource_not_found` | The stage lacks Bedrock access to, or a deployment of, that model; use another model or contact your administrator | | 429 | `bedrock_throttling`, `bedrock_service_quota_exceeded`, `bedrock_model_not_ready` | Bedrock capacity; retry with backoff (`fallbacks` are tried when sent) | | 502 / 503 / 504 | `bedrock_internal_server`, `bedrock_model_error`, `bedrock_model_stream_error`, `bedrock_service_unavailable`, `bedrock_model_timeout` | Transient Bedrock error; retry with backoff | Codes prefixed `bedrock_` come from the Bedrock error name (`ValidationException` → `bedrock_validation`); `message` holds Bedrock's own text. > **Do not let a failed AI call pass silently.** If an application that uses a model to review or judge falls back to a simple check on error, items pass without review and look normal. Mark them "not judged" or hold them, and log and alert. > Errors that waiting cannot fix carry `x-should-retry: false`; OpenAI SDKs honour it, and your own client should too. ## 13. Checklist for agents - Gateway URL: `https://gateway.prime.megazone.com` (stage `prime`). Connect with `POST /v1/connect`, then call `base_url`; in Python `aau_llm_gateway` does this for you. - Read the key from `AAU_LLM_GATEWAY_API_KEY` (or `AAU_API_KEY`); never log or echo it. - Call the web function directly; legacy connection users refresh metadata before expires_at. - Web functions need no keepalive. For long non-streamed calls use the origin URL returned by compatibility discovery. - Start with `auto`; name a model only when you need one. List models with `GET /models`. - Set `max_tokens` to what you need (it sizes team-allowance reservations). - Keep the system prompt and tools stable so prompt caching hits. - Do not retry 401, 403, `insufficient_quota` or `shared_allowance_exceeded`; report them. Retry `rate_limit_exceeded` after `retry-after`. - For classification, checks and scores, consider `POST /v1/jev` instead of a chat model. - For search and RAG vectors, call `POST /embeddings` with an embedding model alias. - When asking for help, quote the request time, the model and the `x-litellm-call-id` response header.