Version: v1.0
Date: March 6, 2026
Scope: OpenCTO OpenAI integrations only
This guide documents how OpenCTO currently uses OpenAI across product surfaces and background services.
- Realtime voice assistant sessions (dashboard + mobile via API Worker token minting).
- OpenAI operational proxy endpoints (
models,usage) for tool-driven platform observability. - Incident/autonomy workflows in orchestrator.
- Multi-channel cloudbot responses and embeddings.
- Voice backend chat completion endpoint.
Client (Dashboard/Mobile/SDK)
|
v
OpenCTO API Worker
- POST /api/v1/realtime/token
- GET /api/v1/cto/openai/models
- GET /api/v1/cto/openai/usage
|
v
OpenAI API
- Endpoint:
POST /api/v1/realtime/token - File:
opencto/opencto-api-worker/src/index.ts - Behavior:
- resolves key by workspace/user via BYOK (
provider=openai) orOPENAI_API_KEYfallback - calls
https://api.openai.com/v1/realtime/client_secrets - returns ephemeral
clientSecretto browser/mobile
- resolves key by workspace/user via BYOK (
- Files:
opencto/opencto-dashboard/src/lib/realtime/openaiAdapter.tsopencto/mobile-app/src/api/realtime.ts
- Behavior:
- connects to
wss://api.openai.com/v1/realtime?model=<model> - uses subprotocol auth:
openai-insecure-api-key.<clientSecret> - streams PCM audio, receives transcript/audio deltas
- executes function tools via backend proxy routes
- connects to
- Routes:
GET /api/v1/cto/openai/modelsGET /api/v1/cto/openai/usage?start=<date>&end=<date>
- File:
opencto/opencto-api-worker/src/index.ts(proxyOpenAI) - Used by dashboard tool execution in
opencto/opencto-dashboard/src/lib/realtime/shared.ts
- File:
opencto/opencto-api-worker/src/providerKeys.ts - Routes:
GET /api/v1/llm/keysPUT /api/v1/llm/keys/openaiDELETE /api/v1/llm/keys/openai
- Security:
- AES-GCM at-rest encryption
- per user + workspace + provider key scope
- only masked hints are returned
| Area | Variables |
|---|---|
| API Worker | OPENAI_API_KEY, RATE_LIMIT_REALTIME_PER_MINUTE, RATE_LIMIT_CTO_OPENAI_PER_MINUTE |
| Voice backend | OPENAI_API_KEY, OPENAI_BASE_URL, OPENAI_MODEL |
| Orchestrator | OPENAI_API_KEY, OPENCTO_OPENAI_MODEL, OPENCTO_AGENT_MODEL |
| Cloudbot worker | OPENAI_API_KEY, OPENCTO_AGENT_MODEL, OPENCTO_EMBED_MODEL |
- Set
OPENAI_API_KEYin API Worker (wrangler secret put OPENAI_API_KEY). - For multi-tenant setups, save per-workspace key via
PUT /api/v1/llm/keys/openai. - Validate realtime path:
- call
/api/v1/realtime/token - confirm non-empty
clientSecret
- call
- Validate ops path:
- call
/api/v1/cto/openai/models - call
/api/v1/cto/openai/usage
- call
- Monitor 429 and 5xx rates on:
realtime_tokencto_openai_proxy
OpenAI. “Realtime API.” OpenAI API Documentation. Accessed March 6, 2026. https://developers.openai.com/api/docs/guides/realtime.
OpenAI. “Text Generation.” OpenAI API Documentation. Accessed March 6, 2026. https://developers.openai.com/api/docs/guides/text.