Skip to content

feat(voice): support custom gateway and local realtime providers - #68461

Open
nickoloss wants to merge 1 commit into
anomalyco:devfrom
the-ai-r-project:custom-voice-providers
Open

nickoloss wants to merge 1 commit into
anomalyco:devfrom
the-ai-r-project:custom-voice-providers

Conversation

@nickoloss

Copy link
Copy Markdown

Issue for this PR

Related to #65647, #66627.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Today voice sessions only work with direct openai, xai, google, or hosted opencode endpoints: Realtime.connect ignores baseURL/headers outside openai-live, and Voice.Service only offers models.dev voice models for those fixed providers. That blocks teams routing traffic through an AI gateway (for example LiteLLM + Vertex AI Gemini Live) and users running local OpenAI-Realtime-compatible servers (such as vLLM /v1/realtime without an API key).

Changes:

  • Schema & config overlay (packages/schema, packages/core): Add optional realtime (protocol, transports, auth) on Model.Info and Config.Model, and copy it in ConfigProviderPlugin. Regenerated OpenAPI, client types, Rust api-types, plugin .d.ts, and API skill docs.
  • Realtime.connect (packages/ai/src/experimental/realtime.ts): Honor baseURL and headers across all four engines (openai-live, openai-realtime, xai-realtime, gemini-live), make apiKey optional for keyless local servers, and support WebSocket auth modes:
    • "ephemeral" (default): mint short-lived tokens via /realtime/client_secrets or /auth_tokens as before.
    • "none": skip token minting and return ws(s)://... with an empty token for keyless local servers.
    • "direct": opt-in for gateways or authenticated local servers without client_secrets, passing the configured API key (never OAuth) as the WebSocket token.
  • Voice.Service (packages/core/src/voice.ts): Offer configured type: "realtime" models with a realtime.protocol as <provider>/<id> (requiring settings.baseURL for non-built-in providers so custom/local models never hit upstream defaults), forward configured baseURL/headers/auth, and reject OAuth credentials under auth: "direct".

No feature flag: existing built-in behavior is unchanged, and custom/local realtime models are opt-in via opencode.jsonc.

Example config:

{
  "providers": {
    "litellm": {
      "settings": { "baseURL": "https://litellm.example.com/v1", "apiKey": "{env:LITELLM_API_KEY}" },
      "models": {
        "vertex-gemini-live": {
          "type": "realtime",
          "modelID": "vertex_ai/gemini-live-2.5-flash",
          "realtime": { "protocol": "openai-realtime", "transports": ["websocket"], "auth": "direct" }
        }
      }
    },
    "vllm": {
      "models": {
        "mistralai/Voxtral-Mini-4B-Realtime-2602": {
          "type": "realtime",
          "realtime": { "protocol": "openai-realtime", "transports": ["websocket"], "auth": "none" }
        }
      }
    }
  }
}

How did you verify your code works?

  • bun --cwd packages/ai test test/realtime.test.ts --rerun-each 10 (40 pass)
  • bun run --cwd packages/core script/test.ts test/voice.test.ts --rerun-each 10 (70 pass)
  • bun run --cwd packages/core script/test.ts test/config/provider.test.ts (43 pass)
  • bun --cwd packages/schema test && bun run --cwd packages/schema typecheck:tsc (99 pass)
  • bun --cwd packages/protocol test && bun run --cwd packages/protocol check:generated (17 pass)
  • bun run --cwd packages/client check:generated
  • bun run --cwd packages/core typecheck:tsc
  • bun --cwd packages/server test test/voice.test.ts (1 pass)
  • bun run lint & oxlint on all touched files (0 errors)
  • bun run --cwd services/site generate && bun run --cwd services/site src/docs/script/build.ts (1944 pages built)

Screenshots / recordings

N/A (backend, schema, and docs change only).

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Copilot AI balanced review requested due to automatic review settings December 5, 2026 11:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants