Documentation
¶
Overview ¶
Package vmodelclient is the client side of the virtual-model server: how a provider record names it (the vmodel:// APIBase scheme), how that address is turned into a URL an SDK accepts, and the http.RoundTripper that reaches the private in-process listener. The gateway's internal/client wraps these pieces (NewVModelOpenAIClient / NewVModelAnthropicClient, chosen by ClientPool) so a vmodel provider runs through the same SDK + transport chain as a real upstream. Server side: vmodel/virtualserver. Design: .design/vmodel-transport.md.
Index ¶
Constants ¶
const Host = "vmodel.internal"
Host is the placeholder host the SDKs are pointed at. It never resolves on any network; Transport ignores it and dials the in-memory listener directly.
const Scheme = "vmodel"
Scheme is the URL scheme of a virtual-model provider's APIBase. The host names the protocol root served by virtualserver.Server:
vmodel://openai → /openai/v1/{models,chat/completions,responses}
vmodel://anthropic → /anthropic/v1/{models,messages}
Variables ¶
This section is empty.
Functions ¶
func APIBase ¶ added in v0.260903.1
APIBase returns the canonical APIBase for a vmodel provider serving style.
func HTTPBase ¶ added in v0.260903.1
HTTPBase translates a vmodel APIBase into the http base URL handed to the SDKs, e.g. http://vmodel.internal/openai/v1. Like a real provider's APIBase it ends in /v1: the OpenAI SDK uses it as-is, the Anthropic client strips it.
The protocol root comes from the URL host. The legacy "vmodel://local" sentinel, or any unrecognised host, falls back to style so existing rows keep working until the builtin seed rewrites them.
func NewTransport ¶ added in v0.260903.1
NewTransport returns the base transport for vmodel providers served by the given dialer. It carries real HTTP — status codes, headers, SSE framing — and is meant to sit under the gateway's generic provider chain (rule flags, logging, ...). The owner of the virtualserver hands it to its ClientPool (ClientPool.SetVModelTransport) so each server instance dials its own registry.