First API key
There are two ways to get an API key: the admin API for operations and automation, or the SSO-backed developer portal for self-service.
Option A: Admin API
Section titled “Option A: Admin API”All admin endpoints require the PROXY_MASTER_KEY in the Authorization header.
1. Create a team (optional)
Section titled “1. Create a team (optional)”curl -X POST \ 'http://localhost:8000/internal/teams?name=engineering&tpm_limit=200000&daily_token_limit=5000000' \ -H "Authorization: Bearer $PROXY_MASTER_KEY"2. Create a user
Section titled “2. Create a user”curl -X POST \ 'http://localhost:8000/internal/users?external_id=alice%40example.com&team_id=<team-uuid>' \ -H "Authorization: Bearer $PROXY_MASTER_KEY"3. Issue an API key
Section titled “3. Issue an API key”curl -X POST \ 'http://localhost:8000/internal/api-keys?user_id=<user-uuid>&name=dev-laptop&scopes=chat&scopes=responses&scopes=embeddings&scopes=rag%3Arepo%3Amyorg%2Fbackend&expires_at=2026-12-31T23%3A59%3A59Z' \ -H "Authorization: Bearer $PROXY_MASTER_KEY"Response:
{ "id": "<key-uuid>", "key": "gr-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "key_prefix": "gr-xxxxxxxxx", "scopes": ["chat", "responses", "embeddings", "rag:repo:myorg/backend"], "expires_at": "2026-12-31T23:59:59Z"}chat is the default when scopes is omitted. Add responses for /v1/responses. RAG is fail-closed: add
rag:repo:owner/name or rag:* explicitly.
Option B: Developer portal
Section titled “Option B: Developer portal”With general OIDC or Google compatibility credentials configured, users can sign in, see usage and limits, and manage their own scoped keys without admin intervention.
- Create an OAuth 2.0 Web Application client in Google Cloud Console
- Add your proxy URL as an authorised redirect URI:
https://proxy.internal/auth/callback - Set the environment variables:
GOOGLE_CLIENT_ID=123456789-abc.apps.googleusercontent.comGOOGLE_CLIENT_SECRET=GOCSPX-...AUTH_BASE_URL=https://proxy.internalHelm:
secrets: googleClientId: "123456789-abc.apps.googleusercontent.com" googleClientSecret: "GOCSPX-..." authBaseUrl: "https://proxy.internal"User flow
Section titled “User flow”- User visits
https://proxy.internal/auth/login - Redirected to Google consent screen
- On approval, redirected back to
/auth/callback - Proxy verifies the HMAC-signed state parameter, exchanges the code for a Google token
- User’s Google account email is used to upsert the user in the database
- Relay creates a signed user session and redirects to
/portal - The user creates a named, expiring key and sees the raw secret once
The portal also provides ready-to-copy OpenAI, Anthropic, Claude Code, MCP, and Responses API configurations.
Key boundaries
Section titled “Key boundaries”Users may select only scopes listed in oidc.default_key_scopes. Relay enforces the configured active-key count and
maximum self-service TTL, and users can rotate or revoke only keys belonging to their identity. Rotation invalidates
the previous secret immediately.