vmodelclient

package
v1.261026.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: MPL-2.0 Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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

func APIBase(style protocol.APIStyle) string

APIBase returns the canonical APIBase for a vmodel provider serving style.

func HTTPBase added in v0.260903.1

func HTTPBase(apiBase string, style protocol.APIStyle) string

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

func NewTransport(d Dialer) *http.Transport

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.

Types

type Dialer added in v0.260903.1

type Dialer func(ctx context.Context, network, addr string) (net.Conn, error)

Dialer opens a connection to a virtual-model server, typically virtualserver.Server.DialContext. network and addr are ignored by the in-memory listener; there is only one possible peer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL