BYOK
Register, test and revoke your own vendor credentials.
Overview
Base path:
/v1/byokPython namespace:
account.byoktext
# Python
from infrai import account
# TypeScript
import { InfraiClient } from "@infrai/sdk";
const client = new InfraiClient({ apiKey: process.env.INFRAI_API_KEY! });
// → client.byokMethods
byok.register
POST /v1/byok
Register a vendor credential for dispatch through your own key.
Python
python
account.byok.register(provider=..., alias=..., credentials={...}, idempotency_key=None)TypeScript
typescript
client.byok.register(opts: ByokRegisterOptions): Promise<ByokKey>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
provider | ByokProvider | string | Required | Vendor provider id, e.g. openai. |
alias | string | Required | A label you choose for this credential. |
credentials | Record<string, string> | Required | Vendor credential fields (write-only). |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
ByokKey { byok_id, provider, alias, state, created_at, test_result? }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import account
# Register your own vendor key; it is stored server-side after registration.
reg = account.byok.register(
provider="openai",
alias="team-main",
credentials={"api_key": "sk-..."},
)
byok_id = reg.get("byok_id") or reg.get("id")
print("id:", byok_id, "| state:", reg.get("state"))
# Test the key end-to-end (server-side).
tested = account.byok.test(id=byok_id)
print("test ok:", tested.get("ok") or tested.get("status"))byok.list
GET /v1/byok
List your registered BYOK credentials.
Python
python
account.byok.list()TypeScript
typescript
client.byok.list(): Promise<{ items }>Returns
{ items: ByokKey[] }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import account
for k in account.byok.list().get("items", []):
print(k.get("byok_id"), k.get("provider"), k.get("state"))byok.test
POST /v1/byok/{id}/test
Test a BYOK credential's connectivity.
Python
python
account.byok.test(id=byok_id)TypeScript
typescript
client.byok.test(byokId: string): Promise<{ ok, latency_ms?, error? }>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Required | The BYOK credential id. |
Returns
{ ok, latency_ms?, error? }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import account
res = account.byok.test(id="byok_...")
print("ok:", res.get("ok"), "| latency_ms:", res.get("latency_ms"))byok.revoke
DELETE /v1/byok/{id}
Revoke a BYOK credential.
Python
python
account.byok.revoke(id=byok_id)TypeScript
typescript
client.byok.revoke(byokId: string): Promise<{ ok }>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Required | The BYOK credential id. |
Returns
{ ok: boolean }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import account
print("revoked:", account.byok.revoke(id="byok_...").get("ok"))