Skip to content

Any other endpoint

Privyx does not need to know a provider by name. It needs to know two things: where to send requests, and which wire schema a path speaks: openai, responses, anthropic, embeddings, gemini, or ollama. A path without a masking route is forwarded unchanged by default; setting proxy.passthrough_unknown: false refuses it instead.

A compatible API on standard paths

If the service uses the standard paths (/v1/chat/completions, /v1/messages, /v1/responses), an upstream is all it takes:

privyx proxy --upstream https://llm.example.com
export OPENAI_BASE_URL=http://localhost:8000/v1

A compatible API on other paths

Three options, described in Proxy modes and routes:

  • Map an upstream prefix, when the client uses standard API paths but the upstream has a prefix:

    proxy: {}
    provider:
      path_mapping:
        mode: prefix
        strip_prefix: /v1
      base_url: https://llm.example.com/api/v1
    

    A client request to /v1/chat/completions is masked using the default route and sent to /api/v1/chat/completions upstream. This also works for privyx run.

  • Add a route, when the client can send the provider's path itself:

    proxy:
      routes:
        /api/v1/chat/completions: openai
    
  • Use gateway mode, when the client cannot, and every request should go to one fixed URL:

    proxy:
      mode: gateway
      routes:
        /v1/chat/completions: openai
    provider:
      type: generic
      base_url: https://llm.example.com/some/base/path/chat/completions
    

The generic provider type

provider.type decides the default upstream and how a key held by Privyx is sent. generic is the default type:

provider:
  type: generic
  base_url: http://localhost:20128   # the default when nothing else is set
  api_key: ""                        # or PRIVYX_API_KEY; sent as a bearer token
  headers: {}                        # extra headers for every upstream request

Use openai, anthropic, or google instead to get that provider's default URL and the header it expects for a key: x-api-key for anthropic, x-goog-api-key for google.

A provider of your own

A provider is the transport the gateway uses to reach an upstream. To add one, subclass BaseProvider (or reuse GenericProvider) in a plugin and select it with provider.type. If its stream is not SSE, it also needs a stream adapter in streaming/adapters/.