PowerTokens OpenAI-compatible gateway integration (follow-up from #1947)
@igordayen @azanux — following up on #1947, here is a tracking issue that incorporates the major points from that discussion.
Context
Embabel already supports China-origin model families (Z.ai / MiniMax / DeepSeek / DashScope) on the wire, but many JVM users outside China cannot obtain those upstream keys (mainland phone / Alipay barriers).
PowerTokens is a hosted OpenAI-compatible gateway (not an in-process library): one baseUrl + one apiKey + modelName, aimed at that access gap.
Approach (agreed direction in #1947)
Reuse Embabel’s existing OpenAI-compatible Factory / BYOK path (OpenAiCompatibleModelFactory / starter-byok).
- No new Embabel module or HTTP client
- No new abstraction — PowerTokens is another OpenAI-compatible endpoint
- Same pattern as other OpenAI-compatible providers: different URL + key + model ids
Suggested config shape
# host (docs / OpenAPI)
baseUrl: https://api.powertokens.ai
# OpenAI-compatible Factory / SDK base (includes /v1)
OPENAI_BASE_URL=https://api.powertokens.ai/v1
OPENAI_API_KEY=<PowerTokens key>
# model id examples below
Rate limits / retries: use Embabel’s existing OpenAI-compatible client behavior; PowerTokens does not require gateway-specific retry wiring for MVP.
Artifacts we can deliver
- Docs section — “Using an OpenAI-compatible gateway (PowerTokens)” covering host, Factory base
/v1,apiKey, and catalog model ids. - Sandbox key for
starter-byok/ local IT — request via email to[email protected], or tell us your preferred private channel; we will not post keys on GitHub. - No Embabel code module from our side for MVP.
IT expectations
Following OpenAiCatalogIT.kt (thanks @azanux):
- Small live catalog check, e.g.
MiniMax-M3,qwen3.8-max,glm-5.3,deepseek-v3-2-251201(deprecated ids should fail the test) - Run locally / manually, outside CI/CD, within a reasonable time (a few chat calls, not a full model sweep)
- We can either add a PowerTokens IT in the same style, or supply key + model list if you prefer to keep the test in-tree
- 401 and exhausted-credits stay on the smoke checklist; the catalog IT stays focused on availability
Ask
Please confirm acceptance criteria on this issue (docs PR vs in-tree IT ownership, any preferred model-id list, and how you’d like the sandbox key delivered). Happy to align and deliver against whatever you set here.
Relates to #1947.
@PowerTokens - thank you, assigned milestone.
@igordayen Quick update: an invalid API key now returns 401 (instead of 500) on both /v1/chat/completions and /v1/models. Please retest when convenient — thanks!
@PowerTokens - could you please update? Perhaps I'm missing a PR? thank you
@igordayen Thanks for the nudge — sorry for the silence.
Status:
- Invalid API key now returns 401 (not 500) on
/v1/chat/completionsand/v1/models(noted on Oct 10). - For MVP we still intend docs + sandbox key only (reuse Embabel’s existing OpenAI-compatible Factory / BYOK) — no new Embabel provider module from our side.
We haven’t opened an Embabel PR yet because we were waiting on acceptance criteria. Happy to open a docs PR (“Using an OpenAI-compatible gateway (PowerTokens)”) against this milestone if that helps, and we can email a sandbox key to whatever private channel you prefer ([email protected]).
Quick check: do you want (a) docs PR from us, (b) in-tree IT in the OpenAiCatalogIT style, or (c) both — or should we wait for 1.5.4 packaging on your side?
@PowerTokens, would you please provide an update on:
- latency
- rate limits
- resilience
RE: (b) in-tree IT in the OpenAICatalogIT style - eventually, yes. Would it be self-contained or require changes in main/src?
@igordayen Thanks for the concrete questions — updating on the three items and the IT shape.
Latency / rate limits / resilience (public docs only)
We do not currently publish numeric latency SLAs (p50/p99) or fixed RPM/TPM quotas on docs.powertokens.ai / powertokens.ai. What is documented for clients:
- Auth: invalid / missing keys return 401 on
/v1/chat/completionsand/v1/models(the Oct 10 fix we noted earlier). - Rate / quota: endpoints document HTTP 429 with codes such as
rate_limit_exceeded(“Too many requests, please try again later”) andinsufficient_user_quota(“Insufficient account quota, please retry later”) — see e.g. the chat model pages under Model APIs. - Transient failures: 5xx responses ask clients to retry later (
gen_relay_info_failed,get_channel_failed,bad_response_status_code). Guide examples use a bounded client timeout (e.g. 30s on curl samples) rather than an open-ended wait. - Resilience guidance we recommend for Embabel: treat 401 as non-retryable; on 429/5xx use exponential backoff with jitter; keep Embabel’s existing OpenAI-compatible client retry settings (no PowerTokens-specific retry wiring needed for MVP).
If you need formal latency numbers for capacity planning, we can gather measured sandbox figures offline — they are not in the public docs today, so I will not invent them here.
In-tree IT (b) — self-contained vs main/src
Looking at the tree: OpenAiCatalogIT lives under
embabel-agent-autoconfigure/models/embabel-agent-openai-autoconfigure/src/test/kotlin/.../OpenAiCatalogIT.kt
and is gated by @EnabledIfEnvironmentVariable(OPENAI_API_KEY) + profile openai-catalog-test, using the existing AgentOpenAiAutoConfiguration / catalog loader.
Proposal: self-contained IT, no main/src changes for MVP.
- Add something like
PowerTokensCatalogIT(or a parameterized sibling) next toOpenAiCatalogITin that same test module. - Point the OpenAI-compatible client at
https://api.powertokens.ai/v1via test properties / env (same Factory / BYOK path we agreed — no new provider module). - Gate on
POWERTOKENS_API_KEY(or reuseOPENAI_API_KEY+OPENAI_BASE_URL), keep it out of CI unless the secret is present. - Smoke a small live set (e.g.
glm-5.2,MiniMax-M3,deepseek-v3-2-251201) for id resolve + one tool-bearing call, mirroring the catalog-IT intent rather than a full sweep.
That should stay entirely under src/test of the openai-autoconfigure (or byok-autoconfigure) module. We would only touch main/src if you later want a first-class catalog YAML entry rather than BYOK — which we are still not proposing for MVP.
Status vs our 10-16 note
Unchanged from the last update: 401 for bad keys is in place; MVP remains docs + sandbox key + optional in-tree IT, no new Embabel provider module. Happy to open the IT PR once you confirm the env-var / property naming you prefer, and we can email a sandbox key to whatever private channel you use ([email protected]).
Happy to adjust if you would rather keep the IT on your side and only take docs from us.
@PowerTokens - thanks for the update. Creating a self-contained test should be fine.
@igordayen Self-contained IT is up: https://github.com/embabel/embabel-agent/pull/2170
- Lives next to
OpenAiCatalogITunder openai-autoconfiguresrc/test— nomain/srcchanges - Base URL
https://api.powertokens.ai/v1, gated byPOWERTOKENS_API_KEY - Smoke: model ids resolve + READY chat + one tool-bearing round-trip on
deepseek-v3-2-251201/glm-5.2/MiniMax-M3, plus unknown-key 401
Happy to tweak the smoke set or placement if you prefer BYOK-module instead.
@PowerTokens - thank you, will be planning to re-test it.
Closed by #2170