Supported methods
- Body field
user— recommended (works with OpenAI‑compatible SDKs) - Header
X-Openstack-User— easy to inject via middleware/proxy - URL prefix
/{user}/…— fallback when body/headers cannot be modified
- Base URL:
https://api.openstack.ai/v1 - Header:
Authorization: Bearer $OPENSTACK_API_KEY
- Body `user` (recommended)
- Header `X-Openstack-User`
- URL prefix `/{user}/...` (fallback)
TypeScript (OpenAI SDK)
- Body `user`
- Header `X-Openstack-User`
Python (OpenAI SDK)
- Body `user`
- Header `X-Openstack-User`
Behavior summary
On each request OpenStack extracts the user id (body > header > URL), checks authorization and (if billing is on) balance, and either:- Returns an assistant message with an authorization/top‑up link (no charge), or
- Forwards the request, meters usage, optionally deducts balance, and streams the model response.
Best practices
- Use body
userwhen possible; header is a great middleware fallback. - Keep IDs stable across sessions and retries. Avoid PII.
- Ensure your server/edge passes the user on every billable request.
What makes a good user id
A short, pseudonymous, stable string (e.g.,user_abc123) that you reuse across sessions and retries. Avoid emails/phone numbers or other PII and keep the id unique within your app or tenant.
If your auth system changes, keep a mapping in your app so you can continue sending a stable id to OpenStack.
Special cases
For guests, mint and persist a random id early. On shared devices, prefer logins; if not, map the device in your system but keep the id stable. Give service/bot accounts dedicated ids rather than reusing human ones.Rotation & migration
If you must rotate, maintain a mapping so the effective id you send stays the same. Avoid mid-session changes to prevent fragmented balances and analytics.Test & staging users
Label staging/test ids clearly (e.g.,test_alice) so you can filter them. Keep keys off the browser; use server or edge calls.